virCgroupDenyDevice;
virCgroupDenyDeviceMajor;
virCgroupDenyDevicePath;
-virCgroupForDomain;
-virCgroupForDriver;
-virCgroupForEmulator;
-virCgroupForSelf;
-virCgroupForVcpu;
virCgroupFree;
virCgroupGetBlkioWeight;
virCgroupGetCpuacctPercpuUsage;
virCgroupKillPainfully;
virCgroupKillRecursive;
virCgroupMoveTask;
+virCgroupNewDomain;
+virCgroupNewDriver;
+virCgroupNewEmulator;
+virCgroupNewSelf;
+virCgroupNewVcpu;
virCgroupPathOfController;
virCgroupRemove;
virCgroupRemoveRecursively;
int ret;
virCgroupPtr cgroup;
- ret = virCgroupForSelf(&cgroup);
+ ret = virCgroupNewSelf(&cgroup);
if (ret < 0) {
virReportSystemError(-ret, "%s",
_("Unable to get cgroup for container"));
virCgroupPtr cgroup = NULL;
int rc;
- rc = virCgroupForDriver("lxc", &driver, 1, 0, -1);
+ rc = virCgroupNewDriver("lxc", true, false, -1, &driver);
if (rc != 0) {
virReportSystemError(-rc, "%s",
_("Unable to get cgroup for driver"));
goto cleanup;
}
- rc = virCgroupForDomain(driver, def->name, &cgroup, 1);
+ rc = virCgroupNewDomain(driver, def->name, true, &cgroup);
if (rc != 0) {
virReportSystemError(-rc,
_("Unable to create cgroup for domain %s"),
virCgroupFree(&priv->cgroup);
- rc = virCgroupForDriver("qemu", &driverGroup,
- cfg->privileged, true,
- cfg->cgroupControllers);
+ rc = virCgroupNewDriver("qemu",
+ cfg->privileged,
+ true,
+ cfg->cgroupControllers,
+ &driverGroup);
if (rc != 0) {
if (rc == -ENXIO ||
rc == -EPERM ||
goto cleanup;
}
- rc = virCgroupForDomain(driverGroup, vm->def->name, &priv->cgroup, 1);
+ rc = virCgroupNewDomain(driverGroup, vm->def->name, true, &priv->cgroup);
if (rc != 0) {
virReportSystemError(-rc,
_("Unable to create cgroup for %s"),
}
for (i = 0; i < priv->nvcpupids; i++) {
- rc = virCgroupForVcpu(priv->cgroup, i, &cgroup_vcpu, 1);
+ rc = virCgroupNewVcpu(priv->cgroup, i, true, &cgroup_vcpu);
if (rc < 0) {
virReportSystemError(-rc,
_("Unable to create vcpu cgroup for %s(vcpu:"
if (priv->cgroup == NULL)
return 0; /* Not supported, so claim success */
- rc = virCgroupForEmulator(priv->cgroup, &cgroup_emulator, 1);
+ rc = virCgroupNewEmulator(priv->cgroup, true, &cgroup_emulator);
if (rc < 0) {
virReportSystemError(-rc,
_("Unable to create emulator cgroup for %s"),
if (priv->cgroup) {
int rv = -1;
/* Create cgroup for the onlined vcpu */
- rv = virCgroupForVcpu(priv->cgroup, i, &cgroup_vcpu, 1);
+ rv = virCgroupNewVcpu(priv->cgroup, i, true, &cgroup_vcpu);
if (rv < 0) {
virReportSystemError(-rv,
_("Unable to create vcpu cgroup for %s(vcpu:"
if (priv->cgroup) {
int rv = -1;
- rv = virCgroupForVcpu(priv->cgroup, i, &cgroup_vcpu, 0);
+ rv = virCgroupNewVcpu(priv->cgroup, i, false, &cgroup_vcpu);
if (rv < 0) {
virReportSystemError(-rv,
_("Unable to access vcpu cgroup for %s(vcpu:"
/* Configure the corresponding cpuset cgroup before set affinity. */
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
- if (virCgroupForVcpu(priv->cgroup, vcpu, &cgroup_vcpu, 0) == 0 &&
+ if (virCgroupNewVcpu(priv->cgroup, vcpu, false, &cgroup_vcpu) == 0 &&
qemuSetupCgroupVcpuPin(cgroup_vcpu, newVcpuPin, newVcpuPinNum, vcpu) < 0) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("failed to set cpuset.cpus in cgroup"
* Configure the corresponding cpuset cgroup.
* If no cgroup for domain or hypervisor exists, do nothing.
*/
- if (virCgroupForEmulator(priv->cgroup, &cgroup_emulator, 0) == 0) {
+ if (virCgroupNewEmulator(priv->cgroup, false, &cgroup_emulator) == 0) {
if (qemuSetupCgroupEmulatorPin(cgroup_emulator,
newVcpuPin[0]->cpumask) < 0) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
*/
if (priv->nvcpupids != 0 && priv->vcpupids[0] != vm->pid) {
for (i = 0; i < priv->nvcpupids; i++) {
- rc = virCgroupForVcpu(cgroup, i, &cgroup_vcpu, 0);
+ rc = virCgroupNewVcpu(cgroup, i, false, &cgroup_vcpu);
if (rc < 0) {
virReportSystemError(-rc,
_("Unable to find vcpu cgroup for %s(vcpu:"
return 0;
}
- rc = virCgroupForEmulator(cgroup, &cgroup_emulator, 0);
+ rc = virCgroupNewEmulator(cgroup, false, &cgroup_emulator);
if (rc < 0) {
virReportSystemError(-rc,
_("Unable to find emulator cgroup for %s"),
}
/* get period and quota for vcpu0 */
- rc = virCgroupForVcpu(priv->cgroup, 0, &cgroup_vcpu, 0);
+ rc = virCgroupNewVcpu(priv->cgroup, 0, false, &cgroup_vcpu);
if (!cgroup_vcpu) {
virReportSystemError(-rc,
_("Unable to find vcpu cgroup for %s(vcpu: 0)"),
}
/* get period and quota for emulator */
- rc = virCgroupForEmulator(cgroup, &cgroup_emulator, 0);
+ rc = virCgroupNewEmulator(cgroup, false, &cgroup_emulator);
if (!cgroup_emulator) {
virReportSystemError(-rc,
_("Unable to find emulator cgroup for %s"),
unsigned long long tmp;
int j;
- if (virCgroupForVcpu(priv->cgroup, i, &group_vcpu, 0) < 0) {
+ if (virCgroupNewVcpu(priv->cgroup, i, false, &group_vcpu) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("error accessing cgroup cpuacct for vcpu"));
goto cleanup;
}
/**
- * virCgroupForDriver:
+ * virCgroupNewDriver:
*
* @name: name of this driver (e.g., xen, qemu, lxc)
* @group: Pointer to returned virCgroupPtr
* Returns 0 on success
*/
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
-int virCgroupForDriver(const char *name,
- virCgroupPtr *group,
+int virCgroupNewDriver(const char *name,
bool privileged,
bool create,
- int controllers)
+ int controllers,
+ virCgroupPtr *group)
{
int rc;
char *path = NULL;
return rc;
}
#else
-int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED,
- virCgroupPtr *group ATTRIBUTE_UNUSED,
+int virCgroupNewDriver(const char *name ATTRIBUTE_UNUSED,
bool privileged ATTRIBUTE_UNUSED,
bool create ATTRIBUTE_UNUSED,
- int controllers ATTRIBUTE_UNUSED)
+ int controllers ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED)
{
/* Claim no support */
return -ENXIO;
#endif
/**
-* virCgroupForSelf:
+* virCgroupNewSelf:
*
* @group: Pointer to returned virCgroupPtr
*
* Returns 0 on success
*/
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
-int virCgroupForSelf(virCgroupPtr *group)
+int virCgroupNewSelf(virCgroupPtr *group)
{
return virCgroupNew("/", -1, group);
}
#else
-int virCgroupForSelf(virCgroupPtr *group ATTRIBUTE_UNUSED)
+int virCgroupNewSelf(virCgroupPtr *group ATTRIBUTE_UNUSED)
{
return -ENXIO;
}
#endif
/**
- * virCgroupForDomain:
+ * virCgroupNewDomain:
*
* @driver: group for driver owning the domain
* @name: name of the domain
* Returns 0 on success
*/
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
-int virCgroupForDomain(virCgroupPtr driver,
+int virCgroupNewDomain(virCgroupPtr driver,
const char *name,
- virCgroupPtr *group,
- bool create)
+ bool create,
+ virCgroupPtr *group)
{
int rc;
char *path;
- if (driver == NULL)
- return -EINVAL;
-
if (virAsprintf(&path, "%s/%s", driver->path, name) < 0)
return -ENOMEM;
return rc;
}
#else
-int virCgroupForDomain(virCgroupPtr driver ATTRIBUTE_UNUSED,
+int virCgroupNewDomain(virCgroupPtr driver ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
- virCgroupPtr *group ATTRIBUTE_UNUSED,
- bool create ATTRIBUTE_UNUSED)
+ bool create ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED)
{
return -ENXIO;
}
#endif
/**
- * virCgroupForVcpu:
+ * virCgroupNewVcpu:
*
- * @driver: group for the domain
+ * @domain: group for the domain
* @vcpuid: id of the vcpu
+ * @create: true to create if not already existing
* @group: Pointer to returned virCgroupPtr
*
* Returns 0 on success
*/
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
-int virCgroupForVcpu(virCgroupPtr driver,
+int virCgroupNewVcpu(virCgroupPtr domain,
int vcpuid,
- virCgroupPtr *group,
- bool create)
+ bool create,
+ virCgroupPtr *group)
{
int rc;
char *path;
int controllers;
- if (driver == NULL)
- return -EINVAL;
-
- if (virAsprintf(&path, "%s/vcpu%d", driver->path, vcpuid) < 0)
+ if (virAsprintf(&path, "%s/vcpu%d", domain->path, vcpuid) < 0)
return -ENOMEM;
controllers = ((1 << VIR_CGROUP_CONTROLLER_CPU) |
VIR_FREE(path);
if (rc == 0) {
- rc = virCgroupMakeGroup(driver, *group, create, VIR_CGROUP_NONE);
+ rc = virCgroupMakeGroup(domain, *group, create, VIR_CGROUP_NONE);
if (rc != 0)
virCgroupFree(group);
}
return rc;
}
#else
-int virCgroupForVcpu(virCgroupPtr driver ATTRIBUTE_UNUSED,
+int virCgroupNewVcpu(virCgroupPtr domain ATTRIBUTE_UNUSED,
int vcpuid ATTRIBUTE_UNUSED,
- virCgroupPtr *group ATTRIBUTE_UNUSED,
- bool create ATTRIBUTE_UNUSED)
+ bool create ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED)
{
return -ENXIO;
}
#endif
/**
- * virCgroupForEmulator:
+ * virCgroupNewEmulator:
*
- * @driver: group for the domain
+ * @domain: group for the domain
+ * @create: true to create if not already existing
* @group: Pointer to returned virCgroupPtr
*
* Returns: 0 on success or -errno on failure
*/
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
-int virCgroupForEmulator(virCgroupPtr driver,
- virCgroupPtr *group,
- bool create)
+int virCgroupNewEmulator(virCgroupPtr domain,
+ bool create,
+ virCgroupPtr *group)
{
int rc;
char *path;
int controllers;
- if (driver == NULL)
- return -EINVAL;
-
- if (virAsprintf(&path, "%s/emulator", driver->path) < 0)
+ if (virAsprintf(&path, "%s/emulator", domain->path) < 0)
return -ENOMEM;
controllers = ((1 << VIR_CGROUP_CONTROLLER_CPU) |
VIR_FREE(path);
if (rc == 0) {
- rc = virCgroupMakeGroup(driver, *group, create, VIR_CGROUP_NONE);
+ rc = virCgroupMakeGroup(domain, *group, create, VIR_CGROUP_NONE);
if (rc != 0)
virCgroupFree(group);
}
return rc;
}
#else
-int virCgroupForEmulator(virCgroupPtr driver ATTRIBUTE_UNUSED,
- virCgroupPtr *group ATTRIBUTE_UNUSED,
- bool create ATTRIBUTE_UNUSED)
+int virCgroupNewEmulator(virCgroupPtr domain ATTRIBUTE_UNUSED,
+ bool create ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED)
{
return -ENXIO;
}
VIR_ENUM_DECL(virCgroupController);
-int virCgroupForDriver(const char *name,
- virCgroupPtr *group,
+int virCgroupNewDriver(const char *name,
bool privileged,
bool create,
- int controllers);
+ int controllers,
+ virCgroupPtr *group)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(5);
-int virCgroupForSelf(virCgroupPtr *group);
+int virCgroupNewSelf(virCgroupPtr *group)
+ ATTRIBUTE_NONNULL(1);
-int virCgroupForDomain(virCgroupPtr driver,
+int virCgroupNewDomain(virCgroupPtr driver,
const char *name,
- virCgroupPtr *group,
- bool create);
+ bool create,
+ virCgroupPtr *group)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
-int virCgroupForVcpu(virCgroupPtr driver,
+int virCgroupNewVcpu(virCgroupPtr domain,
int vcpuid,
- virCgroupPtr *group,
- bool create);
-
-int virCgroupForEmulator(virCgroupPtr driver,
- virCgroupPtr *group,
- bool create);
+ bool create,
+ virCgroupPtr *group)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
+
+int virCgroupNewEmulator(virCgroupPtr domain,
+ bool create,
+ virCgroupPtr *group)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
int virCgroupPathOfController(virCgroupPtr group,
int controller,