This patch adds support for the new api to change domain descriptions to
the qemu driver.
---
Diff to v1:
- use consistent goto labels
- simplified error path
- add flush of config to disk after it's changed
- fixed flag checking logic operators
src/qemu/qemu_driver.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 70 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c920bfd..10dd98d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11857,6 +11857,75 @@ cleanup:
return ret;
}
+static int
+qemuDomainSetDescription(virDomainPtr dom, const char *description,
+ unsigned int flags)
+{
+ struct qemud_driver *driver = dom->conn->privateData;
+ virDomainObjPtr vm;
+ virDomainDefPtr persistentDef;
+ int ret = -1;
+
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG |
+ VIR_DOMAIN_DESCRIPTION_TITLE, -1);
+
+ bool title = (flags & VIR_DOMAIN_DESCRIPTION_TITLE) > 0;
+
+ qemuDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+ qemuDriverUnlock(driver);
+
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(dom->uuid, uuidstr);
+ qemuReportError(VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s'"),
uuidstr);
+ goto cleanup;
+ }
+
+ if (virDomainLiveConfigHelperMethod(driver->caps, vm, &flags,
+ &persistentDef) < 0)
+ goto cleanup;
+
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ if (title) {
+ VIR_FREE(vm->def->title);
+ if (!(vm->def->title = strdup(description)))
+ goto no_memory;
+ } else {
+ VIR_FREE(vm->def->description);
+ if (!(vm->def->description = strdup(description)))
+ goto no_memory;
+ }
+ }
+
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ if (title) {
+ VIR_FREE(persistentDef->title);
+ if (!(persistentDef->title = strdup(description)))
+ goto no_memory;
+ } else {
+ VIR_FREE(persistentDef->description);
+ if (!(persistentDef->description = strdup(description)))
+ goto no_memory;
+ }
+
+ if (virDomainSaveConfig(driver->configDir, persistentDef) < 0)
+ goto cleanup;
+ }
+
+ ret = 0;
+
+cleanup:
+ if (vm)
+ virDomainObjUnlock(vm);
+ return ret;
+no_memory:
+ virReportOOMError();
+ goto cleanup;
+}
+
static virDriver qemuDriver = {
.no = VIR_DRV_QEMU,
.name = "QEMU",
@@ -12009,6 +12078,7 @@ static virDriver qemuDriver = {
.domainGetNumaParameters = qemuDomainGetNumaParameters, /* 0.9.9 */
.domainGetInterfaceParameters = qemuDomainGetInterfaceParameters, /* 0.9.9 */
.domainSetInterfaceParameters = qemuDomainSetInterfaceParameters, /* 0.9.9 */
+ .domainSetDescription = qemuDomainSetDescription, /* 0.9.10 */
};
--
1.7.3.4