]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Fix detaching from persistent def in qemuDomainDetachDeviceAliasLiveAndConfig
authorPeter Krempa <pkrempa@redhat.com>
Tue, 5 Jun 2018 07:35:12 +0000 (09:35 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 5 Jun 2018 13:05:57 +0000 (15:05 +0200)
The code that detaches the device from persistent definition copies the
persistent definition first so that it can easily be rolled back. The
actual detaching is then made in the copy which is assigned back on
success (if the live operation succeeded as well).

This is not the case in qemuDomainDetachDeviceAliasLiveAndConfig where
the definition was copied and put back, but the detaching happened from
the other object which was overwritten.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_driver.c

index c200c5a63d91156b23f5d1c709a8f3cb805d5e76..b7b318896fe22b5604e7ebfbfdeb4f65d3abb18f 100644 (file)
@@ -8822,14 +8822,13 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver,
     if (persistentDef) {
         virDomainDeviceDef dev;
 
-        vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
-        if (!vmdef)
+        if (!(vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt)))
             goto cleanup;
 
-        if (virDomainDefFindDevice(persistentDef, alias, &dev, true) < 0)
+        if (virDomainDefFindDevice(vmdef, alias, &dev, true) < 0)
             goto cleanup;
 
-        if (qemuDomainDetachDeviceConfig(persistentDef, &dev, caps,
+        if (qemuDomainDetachDeviceConfig(vmdef, &dev, caps,
                                          parse_flags, driver->xmlopt) < 0)
             goto cleanup;
     }