From: Ján Tomko Date: Mon, 30 May 2016 11:08:30 +0000 (+0200) Subject: Use virDomainObjGetDefs in lxcDomainSetBlkioParameters X-Git-Tag: v2.0.0-rc1~378 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f62e4f209152fd5b970d5c5d1e879a7647af8c1c;p=thirdparty%2Flibvirt.git Use virDomainObjGetDefs in lxcDomainSetBlkioParameters Remove yet another usage of virDomainLiveConfigHelperMethod along with an sa_assert that helped clang understand the code flow. --- diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 452c8055a7..03e1f60a43 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2571,10 +2571,10 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, virLXCDriverPtr driver = dom->conn->privateData; size_t i; virDomainObjPtr vm = NULL; + virDomainDefPtr def = NULL; virDomainDefPtr persistentDef = NULL; int ret = -1; virLXCDriverConfigPtr cfg = NULL; - virCapsPtr caps = NULL; virLXCDomainObjPrivatePtr priv; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -2604,17 +2604,13 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, if (virDomainSetBlkioParametersEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (!(caps = virLXCDriverGetCapabilities(driver, false))) - goto cleanup; - if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, - &persistentDef) < 0) + if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) goto endjob; - if (flags & VIR_DOMAIN_AFFECT_LIVE) { + if (def) { if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("blkio cgroup isn't mounted")); @@ -2623,7 +2619,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, } ret = 0; - if (flags & VIR_DOMAIN_AFFECT_LIVE) { + if (def) { for (i = 0; i < nparams; i++) { virTypedParameterPtr param = ¶ms[i]; @@ -2718,8 +2714,8 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, } if (j != ndevices || - lxcDomainMergeBlkioDevice(&vm->def->blkio.devices, - &vm->def->blkio.ndevices, + lxcDomainMergeBlkioDevice(&def->blkio.devices, + &def->blkio.ndevices, devices, ndevices, param->field) < 0) ret = -1; virBlkioDeviceArrayClear(devices, ndevices); @@ -2729,10 +2725,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, } if (ret < 0) goto endjob; - if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - /* Clang can't see that if we get here, persistentDef was set. */ - sa_assert(persistentDef); - + if (persistentDef) { for (i = 0; i < nparams; i++) { virTypedParameterPtr param = ¶ms[i]; @@ -2771,7 +2764,6 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); - virObjectUnref(caps); virObjectUnref(cfg); return ret; }