mirror of https://github.com/xqemu/xqemu.git
kvm-all: kvm_irqchip_create is not expected to fail
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 <pbonzini@redhat.com>
This commit is contained in:
parent
38bfe69180
commit
8db4936bb6
33
kvm-all.c
33
kvm-all.c
|
@ -1345,27 +1345,31 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq)
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int kvm_irqchip_create(MachineState *machine, KVMState *s)
|
static void kvm_irqchip_create(MachineState *machine, KVMState *s)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!machine_kernel_irqchip_allowed(machine) ||
|
if (kvm_check_extension(s, KVM_CAP_IRQCHIP)) {
|
||||||
(!kvm_check_extension(s, KVM_CAP_IRQCHIP) &&
|
;
|
||||||
(kvm_vm_enable_cap(s, KVM_CAP_S390_IRQCHIP, 0) < 0))) {
|
} else if (kvm_check_extension(s, KVM_CAP_S390_IRQCHIP)) {
|
||||||
return 0;
|
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
|
/* First probe and see if there's a arch-specific hook to create the
|
||||||
* in-kernel irqchip for us */
|
* in-kernel irqchip for us */
|
||||||
ret = kvm_arch_irqchip_create(s);
|
ret = kvm_arch_irqchip_create(s);
|
||||||
if (ret < 0) {
|
if (ret == 0) {
|
||||||
return ret;
|
|
||||||
} else if (ret == 0) {
|
|
||||||
ret = kvm_vm_ioctl(s, KVM_CREATE_IRQCHIP);
|
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;
|
kvm_kernel_irqchip = true;
|
||||||
|
@ -1376,8 +1380,6 @@ static int kvm_irqchip_create(MachineState *machine, KVMState *s)
|
||||||
kvm_halt_in_kernel_allowed = true;
|
kvm_halt_in_kernel_allowed = true;
|
||||||
|
|
||||||
kvm_init_irq_routing(s);
|
kvm_init_irq_routing(s);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find number of supported CPUs using the recommended
|
/* Find number of supported CPUs using the recommended
|
||||||
|
@ -1594,9 +1596,8 @@ static int kvm_init(MachineState *ms)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = kvm_irqchip_create(ms, s);
|
if (machine_kernel_irqchip_allowed(ms)) {
|
||||||
if (ret < 0) {
|
kvm_irqchip_create(ms, s);
|
||||||
goto err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kvm_state = s;
|
kvm_state = s;
|
||||||
|
|
Loading…
Reference in New Issue