From 7005f7f81cef31bda895d3274c13854c143d3d8d Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Wed, 3 Aug 2016 11:07:21 +0800 Subject: [PATCH] kvm-irqchip: only commit route when irqchip is used Reported from Alexey Kardashevskiy: 3f1fea0fb5bf "kvm-irqchip: do explicit commit when update irq" produces a crash on pseries guest running with VFIO on POWER8 machine as it does not support KVM_CAP_IRQCHIP (KVM_CAP_IRQ_XICS is there instead). At the result, KVMState::irq_routes is NULL when VFIO calls kvm_irqchip_commit_routes. This makes the routing update conditional. Reported-by: Alexey Kardashevskiy Tested-by: Alexey Kardashevskiy Signed-off-by: Peter Xu Signed-off-by: David Gibson --- kvm-all.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kvm-all.c b/kvm-all.c index ef81ca532a..65608def36 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1047,6 +1047,14 @@ void kvm_irqchip_commit_routes(KVMState *s) { int ret; + if (kvm_gsi_direct_mapping()) { + return; + } + + if (!kvm_gsi_routing_enabled()) { + return; + } + s->irq_routes->flags = 0; trace_kvm_irqchip_commit_routes(); ret = kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes); -- 2.11.4.GIT