The checks need to be performed per device and its better to do
them a level down in stack as we prepare for multifunction hotplug.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/qemu/qemu_domain.c | 12 ++++++++++++
src/qemu/qemu_driver.c | 24 ------------------------
src/qemu/qemu_hotplug.c | 12 ++++++++++++
3 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index bf91db3..da5f97d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5531,6 +5531,10 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
virDomainDeviceDefPtr dev,
virConnectPtr conn)
{
+ if (virDomainDefCompatibleDevice(vmdef, dev,
+ VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0)
+ return -1;
+
return qemuDomainAttachDeviceConfigInternal(qemuCaps, vmdef, dev, conn);
}
@@ -5674,6 +5678,10 @@ int
qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
virDomainDeviceDefPtr dev)
{
+ if (virDomainDefCompatibleDevice(vmdef, dev,
+ VIR_DOMAIN_DEVICE_ACTION_DETACH) < 0)
+ return -1;
+
return qemuDomainDetachDeviceConfigInternal(vmdef, dev);
}
@@ -5778,5 +5786,9 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps,
virDomainDefPtr vmdef,
virDomainDeviceDefPtr dev)
{
+ if (virDomainDefCompatibleDevice(vmdef, dev,
+ VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0)
+ return -1;
+
return qemuDomainUpdateDeviceConfigInternal(qemuCaps, vmdef, dev);
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 98e0bfd..9484576 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7521,20 +7521,12 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const
char *xml,
if (!vmdef)
goto endjob;
- if (virDomainDefCompatibleDevice(vmdef, dev,
- VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0)
- goto endjob;
-
if ((ret = qemuDomainAttachDeviceConfig(qemuCaps, vmdef, dev,
dom->conn)) < 0)
goto endjob;
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
- if (virDomainDefCompatibleDevice(vm->def, dev_copy,
- VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0)
- goto endjob;
-
if ((ret = qemuDomainAttachDeviceLive(vm, dev_copy, dom)) < 0)
goto endjob;
/*
@@ -7648,19 +7640,11 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
if (!vmdef)
goto endjob;
- if (virDomainDefCompatibleDevice(vmdef, dev,
- VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0)
- goto endjob;
-
if ((ret = qemuDomainUpdateDeviceConfig(qemuCaps, vmdef, dev)) < 0)
goto endjob;
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
- if (virDomainDefCompatibleDevice(vm->def, dev_copy,
- VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0)
- goto endjob;
-
if ((ret = qemuDomainUpdateDeviceLive(dom->conn, vm, dev_copy, dom, force))
< 0)
goto endjob;
/*
@@ -7768,19 +7752,11 @@ static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const
char *xml,
if (!vmdef)
goto endjob;
- if (virDomainDefCompatibleDevice(vmdef, dev,
- VIR_DOMAIN_DEVICE_ACTION_DETACH) < 0)
- goto endjob;
-
if ((ret = qemuDomainDetachDeviceConfig(vmdef, dev)) < 0)
goto endjob;
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
- if (virDomainDefCompatibleDevice(vm->def, dev_copy,
- VIR_DOMAIN_DEVICE_ACTION_DETACH) < 0)
- goto endjob;
-
if ((ret = qemuDomainDetachDeviceLive(vm, dev_copy, dom)) < 0)
goto endjob;
/*
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 96caef3..9a546e2 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4386,6 +4386,10 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
virDomainDeviceDefPtr dev,
virDomainPtr dom)
{
+ if (virDomainDefCompatibleDevice(vm->def, dev,
+ VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0)
+ return -1;
+
return qemuDomainAttachDeviceLiveInternal(vm, dev, dom);
}
@@ -4477,6 +4481,10 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
virDomainDeviceDefPtr dev,
virDomainPtr dom)
{
+ if (virDomainDefCompatibleDevice(vm->def, dev,
+ VIR_DOMAIN_DEVICE_ACTION_DETACH) < 0)
+ return -1;
+
return qemuDomainDetachDeviceLiveInternal(vm, dev, dom);
}
@@ -4620,6 +4628,10 @@ qemuDomainUpdateDeviceLive(virConnectPtr conn,
virDomainPtr dom,
bool force)
{
+ if (virDomainDefCompatibleDevice(vm->def, dev,
+ VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0)
+ return -1;
+
return qemuDomainUpdateDeviceLiveInternal(conn, vm, dev,
dom, force);
}