Convert QEMU driver to use virCgroupNewMachine

Convert the QEMU driver code to use the new atomic API
for setup of cgroups

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2013-07-22 16:44:52 +01:00
parent b333330aa5
commit 02098ac260

View File

@ -633,7 +633,6 @@ qemuInitCgroup(virQEMUDriverPtr driver,
{ {
int ret = -1; int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
virCgroupPtr parent = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
if (!cfg->privileged) if (!cfg->privileged)
@ -664,32 +663,26 @@ qemuInitCgroup(virQEMUDriverPtr driver,
vm->def->resource->partition); vm->def->resource->partition);
goto cleanup; goto cleanup;
} }
/* We only auto-create the default partition. In other
* cases we expect the sysadmin/app to have done so */ if (virCgroupNewMachine(vm->def->name,
if (virCgroupNewPartition(vm->def->resource->partition, "qemu",
STREQ(vm->def->resource->partition, "/machine"), cfg->privileged,
cfg->cgroupControllers, vm->def->uuid,
&parent) < 0) { NULL,
vm->pid,
false,
vm->def->resource->partition,
cfg->cgroupControllers,
&priv->cgroup) < 0) {
if (virCgroupNewIgnoreError()) if (virCgroupNewIgnoreError())
goto done; goto done;
goto cleanup; goto cleanup;
} }
if (virCgroupNewDomainPartition(parent,
"qemu",
vm->def->name,
true,
&priv->cgroup) < 0)
goto cleanup;
if (virCgroupAddTask(priv->cgroup, vm->pid) < 0)
goto cleanup;
done: done:
ret = 0; ret = 0;
cleanup: cleanup:
virCgroupFree(&parent);
virObjectUnref(cfg); virObjectUnref(cfg);
return ret; return ret;
} }