提交 cb9b3bc2 编写于 作者: D Daniel P. Berrange

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: NDaniel P. Berrange <berrange@redhat.com>
上级 5eb61e68
...@@ -5410,13 +5410,16 @@ lxcDomainMemoryStats(virDomainPtr dom, ...@@ -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; goto cleanup;
}
if (!virCgroupGetMemoryUsage(priv->cgroup, &mem_usage)) if (virCgroupGetMemSwapUsage(priv->cgroup, &swap_usage) < 0)
goto cleanup; goto cleanup;
if (!virDomainObjIsActive(vm)) if (virCgroupGetMemoryUsage(priv->cgroup, &mem_usage) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册