Nova (openstack) calls libvirt to create a container, then periodically checks using GetInfo to see whether the container is up. If it does this too quickly, then libvirt returns an error, which in libvirt.py causes an exception to be raised, the same type as if the container was bad. This may not be the best way to handle it, but with this patch, we assume that a -ENOENT return from virCgroupForDomain means the cgroups are not yet set up, and so we return the same values for cpu and memory usage as if the domain was not active. Signed-off-by: Serge Hallyn <serge.hallyn@xxxxxxxxxxxxx> --- src/lxc/lxc_driver.c | 37 +++++++++++++++++++++---------------- 1 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4b62600..a68b8e7 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -542,26 +542,31 @@ static int lxcDomainGetInfo(virDomainPtr dom, info->cpuTime = 0; info->memory = vm->def->mem.cur_balloon; } else { - if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { + int ret = virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0); + if (ret == -ENOENT) { + /* cgroups are not set up yet */ + info->cpuTime = 0; + info->memory = vm->def->mem.cur_balloon; + } else if (ret != 0) { lxcError(VIR_ERR_INTERNAL_ERROR, _("Unable to get cgroup for %s"), vm->def->name); goto cleanup; - } - - if (virCgroupGetCpuacctUsage(cgroup, &(info->cpuTime)) < 0) { - lxcError(VIR_ERR_OPERATION_FAILED, - "%s", _("Cannot read cputime for domain")); - goto cleanup; - } - if ((rc = virCgroupGetMemoryUsage(cgroup, &(info->memory))) < 0) { - lxcError(VIR_ERR_OPERATION_FAILED, - "%s", _("Cannot read memory usage for domain")); - if (rc == -ENOENT) { - /* Don't fail if we can't read memory usage due to a lack of - * kernel support */ - info->memory = 0; - } else + } else { + if (virCgroupGetCpuacctUsage(cgroup, &(info->cpuTime)) < 0) { + lxcError(VIR_ERR_OPERATION_FAILED, + "%s", _("Cannot read cputime for domain")); goto cleanup; + } + if ((rc = virCgroupGetMemoryUsage(cgroup, &(info->memory))) < 0) { + lxcError(VIR_ERR_OPERATION_FAILED, + "%s", _("Cannot read memory usage for domain")); + if (rc == -ENOENT) { + /* Don't fail if we can't read memory usage due to a lack of + * kernel support */ + info->memory = 0; + } else + goto cleanup; + } } } -- 1.7.5.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list