From: John Ferlan Date: Tue, 28 May 2013 18:52:39 +0000 (-0400) Subject: qemu: Resolve issue with GetScheduler APIs for non running domain X-Git-Tag: v1.0.5.3~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1729409fbb568444525d01d914efba6f4052bb0;p=thirdparty%2Flibvirt.git qemu: Resolve issue with GetScheduler APIs for non running domain Cherry-picked from b23754534193fb7a1e31306d94ae5f09759a0aa4 As a consequence of the cgroup layout changes from commit '632f78ca', the qemuDomainGetSchedulerParameters[Flags]()' and qemuGetSchedulerType() APIs failed to return data for a non running domain. This can be seen through a 'virsh schedinfo ' command which returns: Scheduler : Unknown error: Requested operation is not valid: cgroup CPU controller is not mounted Prior to that change a non running domain would return: Scheduler : posix cpu_shares : 0 vcpu_period : 0 vcpu_quota : 0 emulator_period: 0 emulator_quota : 0 This patch will restore the capability to return configuration only data for a non running domain regardless of whether cgroups are available. NOTE: Needed to change the VIR_STRDUP(ret, "posix"); to ret = strdup("posix"); and added the virReportOOMError(); on failure. --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 31b2f8569a..631e6f440d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6619,6 +6619,16 @@ static char *qemuDomainGetSchedulerType(virDomainPtr dom, } priv = vm->privateData; + /* Domain not running, thus no cgroups - return defaults */ + if (!virDomainObjIsActive(vm)) { + if (nparams) + *nparams = 5; + ret = strdup("posix"); + if (!ret) + virReportOOMError(); + goto cleanup; + } + if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cgroup CPU controller is not mounted")); @@ -8038,11 +8048,12 @@ qemuDomainGetSchedulerParametersFlags(virDomainPtr dom, if (flags & VIR_DOMAIN_AFFECT_CONFIG) { shares = persistentDef->cputune.shares; - if (*nparams > 1 && cpu_bw_status) { + if (*nparams > 1) { period = persistentDef->cputune.period; quota = persistentDef->cputune.quota; emulator_period = persistentDef->cputune.emulator_period; emulator_quota = persistentDef->cputune.emulator_quota; + cpu_bw_status = true; /* Allow copy of data to params[] */ } goto out; }