From 65569bbf37a68ea957819fc489dab708308e1588 Mon Sep 17 00:00:00 2001 From: Daniel Henrique Barboza Date: Mon, 6 Jan 2020 15:24:07 -0300 Subject: intc/s390_flic_kvm.c: remove unneeded label in kvm_flic_load() 'out' label can be replaced by 'return' with the appropriate value that is set by 'r' right before the jump. Cc: Christian Borntraeger Signed-off-by: Daniel Henrique Barboza Message-Id: <20200106182425.20312-42-danielhb413@gmail.com> Reviewed-by: Thomas Huth Signed-off-by: Cornelia Huck --- hw/intc/s390_flic_kvm.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'hw/intc') diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index dddd33ea61..2e1e70c61d 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -439,17 +439,14 @@ static int kvm_flic_load(QEMUFile *f, void *opaque, size_t size, count = qemu_get_be64(f); len = count * sizeof(struct kvm_s390_irq); if (count == FLIC_FAILED) { - r = -EINVAL; - goto out; + return -EINVAL; } if (count == 0) { - r = 0; - goto out; + return 0; } buf = g_try_malloc0(len); if (!buf) { - r = -ENOMEM; - goto out; + return -ENOMEM; } if (qemu_get_buffer(f, (uint8_t *) buf, len) != len) { @@ -460,7 +457,6 @@ static int kvm_flic_load(QEMUFile *f, void *opaque, size_t size, out_free: g_free(buf); -out: return r; } -- cgit v1.2.3 From 3c5fd8074335c67777d9391b84f97070c35d9c63 Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Thu, 16 Jan 2020 13:10:35 +0100 Subject: s390x: adapter routes error handling If the kernel irqchip has been disabled, we don't want the {add,release}_adapter_routes routines to call any kvm_irqchip_* interfaces, as they may rely on an irqchip actually having been created. Just take a quick exit in that case instead. If you are trying to use irqfd without a kernel irqchip, we will fail with an error. Also initialize routes->gsi[] with -1 in the virtio-ccw handling, to make sure we don't trip over other errors, either. (Nobody else uses the gsi array in that structure.) Fixes: d426d9fba8ea ("s390x/virtio-ccw: wire up irq routing and irqfds") Reviewed-by: Thomas Huth Acked-by: Christian Borntraeger Message-Id: <20200117111147.5006-1-cohuck@redhat.com> Signed-off-by: Cornelia Huck --- hw/intc/s390_flic_kvm.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'hw/intc') diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index 2e1e70c61d..a306b26faa 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -331,6 +331,10 @@ static int kvm_s390_add_adapter_routes(S390FLICState *fs, int ret, i; uint64_t ind_offset = routes->adapter.ind_offset; + if (!kvm_gsi_routing_enabled()) { + return -ENOSYS; + } + for (i = 0; i < routes->num_routes; i++) { ret = kvm_irqchip_add_adapter_route(kvm_state, &routes->adapter); if (ret < 0) { @@ -358,6 +362,10 @@ static void kvm_s390_release_adapter_routes(S390FLICState *fs, { int i; + if (!kvm_gsi_routing_enabled()) { + return; + } + for (i = 0; i < routes->num_routes; i++) { if (routes->gsi[i] >= 0) { kvm_irqchip_release_virq(kvm_state, routes->gsi[i]); -- cgit v1.2.3