This makes code clean, and prepares for the next patch.
---
src/qemu/qemu_driver.c | 39 +++++++++++++++++++++++----------------
1 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 98595d1..f432c38 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4360,10 +4360,9 @@ static int qemudDomainAttachDeviceFlags(virDomainPtr dom,
return -1;
}
-
-static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
- const char *xml,
- unsigned int flags)
+static int qemuDomainUpdateDevice(virDomainPtr dom,
+ const char *xml,
+ bool force)
{
struct qemud_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
@@ -4371,18 +4370,6 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
virBitmapPtr qemuCaps = NULL;
virCgroupPtr cgroup = NULL;
int ret = -1;
- bool force = (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) != 0;
-
- virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_CURRENT |
- VIR_DOMAIN_DEVICE_MODIFY_LIVE |
- VIR_DOMAIN_DEVICE_MODIFY_CONFIG |
- VIR_DOMAIN_DEVICE_MODIFY_FORCE, -1);
-
- if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
- qemuReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot modify the persistent
configuration of a domain"));
- return -1;
- }
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -4482,6 +4469,26 @@ cleanup:
return ret;
}
+static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
+ const char *xml,
+ unsigned int flags)
+{
+ bool force = (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) != 0;
+
+ virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_CURRENT |
+ VIR_DOMAIN_DEVICE_MODIFY_LIVE |
+ VIR_DOMAIN_DEVICE_MODIFY_CONFIG |
+ VIR_DOMAIN_DEVICE_MODIFY_FORCE, -1);
+
+ if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("cannot modify the persistent
configuration of a domain"));
+ return -1;
+ }
+
+ return qemuDomainUpdateDevice(dom, xml, force);
+}
+
static int qemudDomainDetachDevice(virDomainPtr dom,
const char *xml) {
--
1.7.3.1
--
Thanks,
Hu Tao