From: Peter Krempa Date: Fri, 20 Jan 2017 13:24:35 +0000 (+0100) Subject: qemu: hotplug: Properly emit "DEVICE_DELETED" event when unplugging memory X-Git-Tag: CVE-2017-2635~260 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d4fd2dd0fe0ebde9a9c61ebc4326b4181092d58;p=thirdparty%2Flibvirt.git qemu: hotplug: Properly emit "DEVICE_DELETED" event when unplugging memory The event needs to be emitted after the last monitor call, so that it's not possible to find the device in the XML accidentally while the vm object is unlocked. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1414393 --- diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 5b0a3f5155..a6de254071 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3691,9 +3691,6 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver, VIR_DEBUG("Removing memory device %s from domain %p %s", mem->info.alias, vm, vm->def->name); - event = virDomainEventDeviceRemovedNewFromObj(vm, mem->info.alias); - qemuDomainEventQueue(driver, event); - if (virAsprintf(&backendAlias, "mem%s", mem->info.alias) < 0) return -1; @@ -3708,6 +3705,9 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver, if (rc < 0) return -1; + event = virDomainEventDeviceRemovedNewFromObj(vm, mem->info.alias); + qemuDomainEventQueue(driver, event); + if ((idx = virDomainMemoryFindByDef(vm->def, mem)) >= 0) virDomainMemoryRemove(vm->def, idx);