From: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
This helps calling the routines with a list of devices.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
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 dd9ae30bb5..43a3ffea99 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8117,11 +8117,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;
@@ -8316,19 +8313,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;
@@ -8518,6 +8531,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.26.2