[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/12] kvm-all: kvm_irqchip_create is not expected t
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 08/12] kvm-all: kvm_irqchip_create is not expected to fail |
Date: |
Thu, 18 Jun 2015 18:30:15 +0200 |
KVM_CREATE_IRQCHIP should never fail, and so should its userspace
wrapper kvm_irqchip_create. The function does not do anything
if the irqchip capability is not available, as is the case for PPC.
With this patch, kvm_arch_init can allocate memory and it will not
be leaked.
Signed-off-by: Paolo Bonzini <address@hidden>
---
kvm-all.c | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/kvm-all.c b/kvm-all.c
index 5f75ac4..42e7615 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1342,27 +1342,31 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s,
EventNotifier *n, int virq)
false);
}
-static int kvm_irqchip_create(MachineState *machine, KVMState *s)
+static void kvm_irqchip_create(MachineState *machine, KVMState *s)
{
int ret;
- if (!machine_kernel_irqchip_allowed(machine) ||
- (!kvm_check_extension(s, KVM_CAP_IRQCHIP) &&
- (kvm_vm_enable_cap(s, KVM_CAP_S390_IRQCHIP, 0) < 0))) {
- return 0;
+ if (kvm_check_extension(s, KVM_CAP_IRQCHIP)) {
+ ;
+ } else if (kvm_check_extension(s, KVM_CAP_S390_IRQCHIP)) {
+ ret = kvm_vm_enable_cap(s, KVM_CAP_S390_IRQCHIP, 0);
+ if (ret < 0) {
+ fprintf(stderr, "Enable kernel irqchip failed: %s\n",
strerror(-ret));
+ exit(1);
+ }
+ } else {
+ return;
}
/* First probe and see if there's a arch-specific hook to create the
* in-kernel irqchip for us */
ret = kvm_arch_irqchip_create(s);
- if (ret < 0) {
- return ret;
- } else if (ret == 0) {
+ if (ret == 0) {
ret = kvm_vm_ioctl(s, KVM_CREATE_IRQCHIP);
- if (ret < 0) {
- fprintf(stderr, "Create kernel irqchip failed\n");
- return ret;
- }
+ }
+ if (ret < 0) {
+ fprintf(stderr, "Create kernel irqchip failed: %s\n", strerror(-ret));
+ exit(1);
}
kvm_kernel_irqchip = true;
@@ -1373,8 +1377,6 @@ static int kvm_irqchip_create(MachineState *machine,
KVMState *s)
kvm_halt_in_kernel_allowed = true;
kvm_init_irq_routing(s);
-
- return 0;
}
/* Find number of supported CPUs using the recommended
@@ -1591,9 +1593,8 @@ static int kvm_init(MachineState *ms)
goto err;
}
- ret = kvm_irqchip_create(ms, s);
- if (ret < 0) {
- goto err;
+ if (machine_kernel_irqchip_allowed(ms)) {
+ kvm_irqchip_create(ms, s);
}
kvm_state = s;
--
1.8.3.1
- [Qemu-devel] [PATCH for-2.4 00/12] pc: KVM support for SMRAM, Paolo Bonzini, 2015/06/18
- [Qemu-devel] [PATCH 03/12] kvm-all: put kvm_mem_flags to more work, Paolo Bonzini, 2015/06/18
- [Qemu-devel] [PATCH 04/12] kvm-all: remove useless typedef, Paolo Bonzini, 2015/06/18
- [Qemu-devel] [PATCH 02/12] target-i386: add support for SMBASE MSR and SMIs, Paolo Bonzini, 2015/06/18
- [Qemu-devel] [PATCH 01/12] piix4/ich9: do not raise SMI on ACPI enable/disable commands, Paolo Bonzini, 2015/06/18
- [Qemu-devel] [PATCH 05/12] kvm-all: move internal types to kvm_int.h, Paolo Bonzini, 2015/06/18
- [Qemu-devel] [PATCH 07/12] kvm-all: add support for multiple address spaces, Paolo Bonzini, 2015/06/18
- [Qemu-devel] [PATCH 08/12] kvm-all: kvm_irqchip_create is not expected to fail,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 06/12] kvm-all: make KVM's memory listener more generic, Paolo Bonzini, 2015/06/18
- [Qemu-devel] [PATCH 09/12] target-i386: register a separate KVM address space including SMRAM regions, Paolo Bonzini, 2015/06/18
- [Qemu-devel] [PATCH 10/12] pc_piix: rename kvm_enabled to smm_enabled, Paolo Bonzini, 2015/06/18
- [Qemu-devel] [PATCH 12/12] pc: add SMM property, Paolo Bonzini, 2015/06/18
- [Qemu-devel] [PATCH 11/12] ich9: add smm_enabled field and arguments, Paolo Bonzini, 2015/06/18