--- src/qemu/qemu_hotplug.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6db789d..0093245 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2139,6 +2139,28 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } +static void +qemuDomainRemoveControllerDevice(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, + virDomainObjPtr vm, + virDomainControllerDefPtr controller) +{ + size_t i; + + VIR_DEBUG("Removing controller %s from domain %p %s", + controller->info.alias, vm, vm->def->name); + + for (i = 0; i < vm->def->ncontrollers; i++) { + if (vm->def->controllers[i] == controller) { + virDomainControllerRemove(vm->def, i); + break; + } + } + + qemuDomainReleaseDeviceAddress(vm, &controller->info, NULL); + virDomainControllerDefFree(controller); +} + + int qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDiskDefPtr detach) @@ -2364,9 +2386,7 @@ int qemuDomainDetachPciControllerDevice(virQEMUDriverPtr driver, } qemuDomainObjExitMonitor(driver, vm); - virDomainControllerRemove(vm->def, idx); - qemuDomainReleaseDeviceAddress(vm, &detach->info, NULL); - virDomainControllerDefFree(detach); + qemuDomainRemoveControllerDevice(driver, vm, detach); ret = 0; -- 1.8.3.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list