mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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)
|
if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
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;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virCgroupGetMemoryUsage(priv->cgroup, &mem_usage))
|
if (virCgroupGetMemoryUsage(priv->cgroup, &mem_usage) < 0)
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm))
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user