These operations aren't necessarily time consuming, but need to
wait in the queue of modify jobs.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_driver.c | 40 ++++++++++++++++++++++++++--------------
1 file changed, 26 insertions(+), 14 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 7ce127a..528c2cb 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3414,6 +3414,9 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
+ if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
+ goto cleanup;
+
if (virDomainObjIsActive(vm)) {
if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
@@ -3424,14 +3427,14 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("Domain is not running"));
- goto cleanup;
+ goto endjob;
}
}
if ((flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) && !vm->persistent) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot modify device on transient
domain"));
- goto cleanup;
+ goto endjob;
}
priv = vm->privateData;
@@ -3440,15 +3443,15 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
if (!(dev = virDomainDeviceDefParse(xml, vm->def,
cfg->caps, driver->xmlopt,
VIR_DOMAIN_XML_INACTIVE)))
- goto cleanup;
+ goto endjob;
/* Make a copy for updated domain. */
if (!(vmdef = virDomainObjCopyPersistentDef(vm, cfg->caps,
driver->xmlopt)))
- goto cleanup;
+ goto endjob;
if ((ret = libxlDomainAttachDeviceConfig(vmdef, dev)) < 0)
- goto cleanup;
+ goto endjob;
} else {
ret = 0;
}
@@ -3459,10 +3462,10 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
if (!(dev = virDomainDeviceDefParse(xml, vm->def,
cfg->caps, driver->xmlopt,
VIR_DOMAIN_XML_INACTIVE)))
- goto cleanup;
+ goto endjob;
if ((ret = libxlDomainAttachDeviceLive(priv, vm, dev)) < 0)
- goto cleanup;
+ goto endjob;
/*
* update domain status forcibly because the domain status may be
@@ -3481,6 +3484,9 @@ libxlDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
}
}
+endjob:
+ libxlDomainObjEndJob(driver, vm);
+
cleanup:
virDomainDefFree(vmdef);
virDomainDeviceDefFree(dev);
@@ -3518,6 +3524,9 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
+ if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
+ goto cleanup;
+
if (virDomainObjIsActive(vm)) {
if (flags == VIR_DOMAIN_DEVICE_MODIFY_CURRENT)
flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
@@ -3528,14 +3537,14 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("Domain is not running"));
- goto cleanup;
+ goto endjob;
}
}
if ((flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) && !vm->persistent) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot modify device on transient
domain"));
- goto cleanup;
+ goto endjob;
}
priv = vm->privateData;
@@ -3544,15 +3553,15 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
if (!(dev = virDomainDeviceDefParse(xml, vm->def,
cfg->caps, driver->xmlopt,
VIR_DOMAIN_XML_INACTIVE)))
- goto cleanup;
+ goto endjob;
/* Make a copy for updated domain. */
if (!(vmdef = virDomainObjCopyPersistentDef(vm, cfg->caps,
driver->xmlopt)))
- goto cleanup;
+ goto endjob;
if ((ret = libxlDomainDetachDeviceConfig(vmdef, dev)) < 0)
- goto cleanup;
+ goto endjob;
} else {
ret = 0;
}
@@ -3563,10 +3572,10 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
if (!(dev = virDomainDeviceDefParse(xml, vm->def,
cfg->caps, driver->xmlopt,
VIR_DOMAIN_XML_INACTIVE)))
- goto cleanup;
+ goto endjob;
if ((ret = libxlDomainDetachDeviceLive(priv, vm, dev)) < 0)
- goto cleanup;
+ goto endjob;
/*
* update domain status forcibly because the domain status may be
@@ -3585,6 +3594,9 @@ libxlDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
}
}
+endjob:
+ libxlDomainObjEndJob(driver, vm);
+
cleanup:
virDomainDefFree(vmdef);
virDomainDeviceDefFree(dev);
--
1.8.1.4