[PATCH 3/5] qemu: Split qemuDomainDetachDeviceLiveAndConfig

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The aim is to have qemuDomainDetachDeviceLiveAndConfig() accept
virDomainDeviceDefPtr. Therefore, new
qemuDomainDetachDeviceXMLLiveAndConfig() which is a drop in
replacement for the former.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3a328e5d46..0e0c0ce53e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8661,15 +8661,16 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
     return ret;
 }
 
+
 static int
 qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
                                     virDomainObjPtr vm,
-                                    const char *xml,
+                                    virDomainDeviceDefPtr dev,
                                     unsigned int flags)
 {
     virCapsPtr caps = NULL;
     virQEMUDriverConfigPtr cfg = NULL;
-    virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
+    virDomainDeviceDefPtr dev_copy = dev;
     unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
     virDomainDefPtr vmdef = NULL;
     int ret = -1;
@@ -8686,12 +8687,6 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
         !(flags & VIR_DOMAIN_AFFECT_LIVE))
         parse_flags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
 
-    dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
-                                             caps, driver->xmlopt,
-                                             parse_flags);
-    if (dev == NULL)
-        goto cleanup;
-
     if (flags & VIR_DOMAIN_AFFECT_CONFIG &&
         flags & VIR_DOMAIN_AFFECT_LIVE) {
         /* If we are affecting both CONFIG and LIVE
@@ -8743,11 +8738,42 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
     virObjectUnref(cfg);
     if (dev != dev_copy)
         virDomainDeviceDefFree(dev_copy);
-    virDomainDeviceDefFree(dev);
     virDomainDefFree(vmdef);
     return ret;
 }
 
+
+static int
+qemuDomainDetachDeviceXMLLiveAndConfig(virQEMUDriverPtr driver,
+                                       virDomainObjPtr vm,
+                                       const char *xml,
+                                       unsigned int flags)
+{
+    virCapsPtr caps = NULL;
+    virDomainDeviceDefPtr dev = NULL;
+    unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
+    int ret = -1;
+
+    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
+        goto cleanup;
+
+    if ((flags & VIR_DOMAIN_AFFECT_CONFIG) &&
+        !(flags & VIR_DOMAIN_AFFECT_LIVE))
+        parse_flags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
+
+    if (!(dev = virDomainDeviceDefParse(xml, vm->def,
+                                        caps, driver->xmlopt,
+                                        parse_flags)))
+        goto cleanup;
+
+    ret = qemuDomainDetachDeviceLiveAndConfig(driver, vm, dev, flags);
+ cleanup:
+    virDomainDeviceDefFree(dev);
+    virObjectUnref(caps);
+    return ret;
+}
+
+
 static int
 qemuDomainDetachDeviceFlags(virDomainPtr dom,
                             const char *xml,
@@ -8769,7 +8795,7 @@ qemuDomainDetachDeviceFlags(virDomainPtr dom,
     if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
         goto endjob;
 
-    if (qemuDomainDetachDeviceLiveAndConfig(driver, vm, xml, flags) < 0)
+    if (qemuDomainDetachDeviceXMLLiveAndConfig(driver, vm, xml, flags) < 0)
         goto endjob;
 
     ret = 0;
-- 
2.16.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux