[RFC PATCH 21/28] qemu: refactor qemuDomain[Attach|Detach]DeviceConfig

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

 



This helps calling the routines with a list of devices.

Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>
---
 src/qemu/qemu_driver.c |   45 ++++++++++++++++++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0ade86d6a9..18e88f05bb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7969,11 +7969,8 @@ qemuDomainUpdateDeviceLive(virDomainObjPtr vm,
 }
 
 static int
-qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
-                             virDomainDeviceDefPtr dev,
-                             virCapsPtr caps,
-                             unsigned int parse_flags,
-                             virDomainXMLOptionPtr xmlopt)
+qemuDomainAttachDeviceConfigInternal(virDomainDefPtr vmdef,
+                                     virDomainDeviceDefPtr dev)
 {
     virDomainDiskDefPtr disk;
     virDomainNetDefPtr net;
@@ -8151,20 +8148,34 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
          return -1;
     }
 
-    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
-        return -1;
-
     return 0;
 }
 
 
 static int
-qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
+qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
                              virDomainDeviceDefPtr dev,
                              virCapsPtr caps,
                              unsigned int parse_flags,
                              virDomainXMLOptionPtr xmlopt)
 {
+    if (virDomainDefCompatibleDevice(vmdef, dev, NULL) < 0)
+        return -1;
+
+    if (qemuDomainAttachDeviceConfigInternal(vmdef, dev))
+        return -1;
+
+    if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
+        return -1;
+
+    return 0;
+}
+
+
+static int
+qemuDomainDetachDeviceConfigInternal(virDomainDefPtr vmdef,
+                                     virDomainDeviceDefPtr dev)
+{
     virDomainDiskDefPtr disk, det_disk;
     virDomainNetDefPtr net;
     virDomainHostdevDefPtr hostdev, det_hostdev;
@@ -8334,6 +8345,20 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
         return -1;
     }
 
+    return 0;
+}
+
+
+static int
+qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
+                             virDomainDeviceDefPtr dev,
+                             virCapsPtr caps,
+                             unsigned int parse_flags,
+                             virDomainXMLOptionPtr xmlopt)
+{
+    if (qemuDomainDetachDeviceConfigInternal(vmdef, dev))
+        return -1;
+
     if (virDomainDefPostParse(vmdef, caps, parse_flags, xmlopt, NULL) < 0)
         return -1;
 
@@ -8486,8 +8511,6 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
         if (!vmdef)
             goto cleanup;
 
-        if (virDomainDefCompatibleDevice(vmdef, dev, NULL) < 0)
-            goto cleanup;
         if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, caps,
                                                 parse_flags,
                                                 driver->xmlopt)) < 0)

--
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