[PATCH v2 12/21] qemu: refactor qemuDomain[Attach|Detach]DeviceConfig

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

 



From: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>

This helps calling the routines with a list of devices.

Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 src/qemu/qemu_driver.c | 45 +++++++++++++++++++++++++++++++++---------
 1 file changed, 36 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8bb845298b..2e91a2b694 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8109,11 +8109,8 @@ qemuCheckDiskConfigAgainstDomain(const virDomainDef *def,
 
 
 static int
-qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
-                             virDomainDeviceDefPtr dev,
-                             virQEMUCapsPtr qemuCaps,
-                             unsigned int parse_flags,
-                             virDomainXMLOptionPtr xmlopt)
+qemuDomainAttachDeviceConfigInternal(virDomainDefPtr vmdef,
+                                     virDomainDeviceDefPtr dev)
 {
     virDomainDiskDefPtr disk;
     virDomainNetDefPtr net;
@@ -8310,19 +8307,35 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
          return -1;
     }
 
-    if (virDomainDefPostParse(vmdef, parse_flags, xmlopt, qemuCaps) < 0)
-        return -1;
-
     return 0;
 }
 
 
 static int
-qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
+qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
                              virDomainDeviceDefPtr dev,
                              virQEMUCapsPtr qemuCaps,
                              unsigned int parse_flags,
                              virDomainXMLOptionPtr xmlopt)
+{
+    if (virDomainDefCompatibleDevice(vmdef, dev, NULL,
+                                     VIR_DOMAIN_DEVICE_ACTION_ATTACH,
+                                     false) < 0)
+        return -1;
+
+    if (qemuDomainAttachDeviceConfigInternal(vmdef, dev))
+        return -1;
+
+    if (virDomainDefPostParse(vmdef, parse_flags, xmlopt, qemuCaps) < 0)
+        return -1;
+
+    return 0;
+}
+
+
+static int
+qemuDomainDetachDeviceConfigInternal(virDomainDefPtr vmdef,
+                                     virDomainDeviceDefPtr dev)
 {
     virDomainDiskDefPtr disk, det_disk;
     virDomainNetDefPtr net;
@@ -8512,6 +8525,20 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
         return -1;
     }
 
+    return 0;
+}
+
+
+static int
+qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
+                             virDomainDeviceDefPtr dev,
+                             virQEMUCapsPtr qemuCaps,
+                             unsigned int parse_flags,
+                             virDomainXMLOptionPtr xmlopt)
+{
+    if (qemuDomainDetachDeviceConfigInternal(vmdef, dev))
+        return -1;
+
     if (virDomainDefPostParse(vmdef, parse_flags, xmlopt, qemuCaps) < 0)
         return -1;
 
-- 
2.24.1






[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