[libvirt] [PATCH for v1.0.4-maint 0/2] Resolve issues seen with schedinfo

This is a backport of: https://www.redhat.com/archives/libvir-list/2013-June/msg00453.html submitted upstread as commit id 'b2375453' and '38ada092' John Ferlan (2): qemu: Resolve issue with GetScheduler APIs for non running domain lxc: Resolve issue with GetScheduler APIs for non running domain src/lxc/lxc_driver.c | 19 ++++++++++++++++++- src/qemu/qemu_driver.c | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) -- 1.8.1.4

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 <domain>' 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. Conflicts: src/qemu/qemu_driver.c * Resolved conflict by using former qemuCgroupHasController() rather than virCgroupHasController() * Needed to add the code to fetch the 'vm' vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); if (vm == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("No such domain %s"), dom->uuid); goto cleanup; } * Used 'ret = strdup("posix");' rather than VIR_STRDUP(ret, "posix"); --- src/qemu/qemu_driver.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b6a5139..bfa10c4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6734,6 +6734,22 @@ static char *qemuGetSchedulerType(virDomainPtr dom, virQEMUDriverPtr driver = dom->conn->privateData; char *ret = NULL; int rc; + virDomainObjPtr vm = NULL; + + vm = virDomainObjListFindByUUID(driver->domains, dom->uuid); + if (vm == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("No such domain %s"), dom->uuid); + goto cleanup; + } + + /* Domain not running, thus no cgroups - return defaults */ + if (!virDomainObjIsActive(vm)) { + if (nparams) + *nparams = 5; + ret = strdup("posix"); + goto cleanup; + } if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -8227,11 +8243,12 @@ qemuGetSchedulerParametersFlags(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; } -- 1.8.1.4

As a consequence of the cgroup layout changes from commit 'cfed9ad4', the lxcDomainGetSchedulerParameters[Flags]()' and lxcGetSchedulerType() APIs failed to return data for a non running domain. This can be seen through a 'virsh schedinfo <domain>' 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. Conflicts: src/lxc/lxc_driver.c * Resolved conflict by using former lxcCgroupHasController() rather than virCgroupHasController() * Needed to add the code to fetch the 'vm' vm = virDomainObjListFindByUUID(driver->domains, domain->uuid); if (vm == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("No such domain %s"), domain->uuid); goto cleanup; } * Used 'ret = strdup("posix");' rather than VIR_STRDUP(ret, "posix"); --- src/lxc/lxc_driver.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index ba14db7..0ece8ed 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1662,8 +1662,24 @@ static char *lxcGetSchedulerType(virDomainPtr domain, virLXCDriverPtr driver = domain->conn->privateData; char *ret = NULL; int rc; + virDomainObjPtr vm; lxcDriverLock(driver); + vm = virDomainObjListFindByUUID(driver->domains, domain->uuid); + if (vm == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("No such domain %s"), domain->uuid); + goto cleanup; + } + + /* Domain not running, thus no cgroups - return defaults */ + if (!virDomainObjIsActive(vm)) { + if (nparams) + *nparams = 3; + ret = strdup("posix"); + goto cleanup; + } + if (!lxcCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cgroup CPU controller is not mounted")); @@ -1947,9 +1963,10 @@ lxcGetSchedulerParametersFlags(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; + cpu_bw_status = true; /* Allow copy of data to params[] */ } goto out; } -- 1.8.1.4
participants (1)
-
John Ferlan