mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
Fix multiple bugs in LXC domainMemoryStats driver
The virCgroupXXX APIs' return value must be checked for being less than 0, not equal to 0. An VIR_ERR_OPERATION_INVALID error must also be raised when the VM is not running to prevent a crash on NULL priv->cgroup field. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
5eb61e6846
commit
cb9b3bc257
@ -5410,13 +5410,16 @@ lxcDomainMemoryStats(virDomainPtr dom,
|
||||
if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!virCgroupGetMemSwapUsage(priv->cgroup, &swap_usage))
|
||||
if (!virDomainObjIsActive(vm)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("domain is not active"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virCgroupGetMemSwapUsage(priv->cgroup, &swap_usage) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!virCgroupGetMemoryUsage(priv->cgroup, &mem_usage))
|
||||
goto cleanup;
|
||||
|
||||
if (!virDomainObjIsActive(vm))
|
||||
if (virCgroupGetMemoryUsage(priv->cgroup, &mem_usage) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user