From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> The virCgroupNewDomainDriver and virCgroupNewDriver methods are obsolete now that we can auto-detect existing cgroup placement. Delete them to reduce code bloat. Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> --- src/libvirt_private.syms | 2 - src/util/vircgroup.c | 121 ----------------------------------------------- src/util/vircgroup.h | 11 ----- tests/vircgrouptest.c | 112 ------------------------------------------- 4 files changed, 246 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3be604b..5a5d112 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1188,9 +1188,7 @@ virCgroupKillPainfully; virCgroupKillRecursive; virCgroupMoveTask; virCgroupNewDetect; -virCgroupNewDomainDriver; virCgroupNewDomainPartition; -virCgroupNewDriver; virCgroupNewEmulator; virCgroupNewIgnoreError; virCgroupNewPartition; diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 1043318..593caad 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -918,28 +918,6 @@ error: return -1; } - -static int virCgroupAppRoot(virCgroupPtr *group, - bool create, - int controllers) -{ - virCgroupPtr selfgrp = NULL; - int ret = -1; - - if (virCgroupNewSelf(&selfgrp) < 0) - return -1; - - if (virCgroupNew(-1, "libvirt", selfgrp, controllers, group) < 0) - goto cleanup; - - if (virCgroupMakeGroup(selfgrp, *group, create, VIR_CGROUP_NONE) < 0) - goto cleanup; - - ret = 0; -cleanup: - virCgroupFree(&selfgrp); - return ret; -} #endif #if defined _DIRENT_HAVE_D_TYPE @@ -1387,53 +1365,6 @@ int virCgroupNewPartition(const char *path ATTRIBUTE_UNUSED, } #endif -/** - * virCgroupNewDriver: - * - * @name: name of this driver (e.g., xen, qemu, lxc) - * @group: Pointer to returned virCgroupPtr - * - * Returns 0 on success, or -1 on error - */ -#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R -int virCgroupNewDriver(const char *name, - bool create, - int controllers, - virCgroupPtr *group) -{ - int ret = -1; - virCgroupPtr rootgrp = NULL; - - if (virCgroupAppRoot(&rootgrp, - create, controllers) < 0) - goto cleanup; - - if (virCgroupNew(-1, name, rootgrp, -1, group) < 0) - goto cleanup; - - if (virCgroupMakeGroup(rootgrp, *group, create, VIR_CGROUP_NONE) < 0) { - virCgroupRemove(*group); - virCgroupFree(group); - goto cleanup; - } - - ret = 0; - -cleanup: - virCgroupFree(&rootgrp); - return ret; -} -#else -int virCgroupNewDriver(const char *name ATTRIBUTE_UNUSED, - bool create ATTRIBUTE_UNUSED, - int controllers ATTRIBUTE_UNUSED, - virCgroupPtr *group ATTRIBUTE_UNUSED) -{ - virReportSystemError(ENXIO, "%s", - _("Control groups not supported on this platform")); - return -1; -} -#endif /** * virCgroupNewSelf: @@ -1452,58 +1383,6 @@ int virCgroupNewSelf(virCgroupPtr *group) /** - * virCgroupNewDomainDriver: - * - * @driver: group for driver owning the domain - * @name: name of the domain - * @group: Pointer to returned virCgroupPtr - * - * Returns 0 on success, or -1 on error - */ -#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R -int virCgroupNewDomainDriver(virCgroupPtr driver, - const char *name, - bool create, - virCgroupPtr *group) -{ - int ret = -1; - - if (virCgroupNew(-1, name, driver, -1, group) < 0) - goto cleanup; - - /* - * Create a cgroup with memory.use_hierarchy enabled to - * surely account memory usage of lxc with ns subsystem - * enabled. (To be exact, memory and ns subsystems are - * enabled at the same time.) - * - * The reason why doing it here, not a upper group, say - * a group for driver, is to avoid overhead to track - * cumulative usage that we don't need. - */ - if (virCgroupMakeGroup(driver, *group, create, VIR_CGROUP_MEM_HIERACHY) < 0) { - virCgroupRemove(*group); - virCgroupFree(group); - goto cleanup; - } - - ret = 0; -cleanup: - return ret; -} -#else -int virCgroupNewDomainDriver(virCgroupPtr driver ATTRIBUTE_UNUSED, - const char *name ATTRIBUTE_UNUSED, - bool create ATTRIBUTE_UNUSED, - virCgroupPtr *group ATTRIBUTE_UNUSED) -{ - virReportSystemError(ENXIO, "%s", - _("Control groups not supported on this platform")); - return -1; -} -#endif - -/** * virCgroupNewDomainPartition: * * @partition: partition holding the domain diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 9bf0d7e..3c05604 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -59,20 +59,9 @@ int virCgroupNewPartition(const char *path, virCgroupPtr *group) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); -int virCgroupNewDriver(const char *name, - bool create, - int controllers, - virCgroupPtr *group) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); - int virCgroupNewSelf(virCgroupPtr *group) ATTRIBUTE_NONNULL(1); -int virCgroupNewDomainDriver(virCgroupPtr driver, - const char *name, - bool create, - virCgroupPtr *group) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4); int virCgroupNewDomainPartition(virCgroupPtr partition, const char *driver, const char *name, diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index 18d10d9..20ac494 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -148,112 +148,6 @@ cleanup: /* Asking for impossible combination since CPU is co-mounted */ -static int testCgroupNewForDriver(const void *args ATTRIBUTE_UNUSED) -{ - virCgroupPtr cgroup = NULL; - int ret = -1; - int rv; - const char *placementSmall[VIR_CGROUP_CONTROLLER_LAST] = { - [VIR_CGROUP_CONTROLLER_CPU] = "/system/libvirt/lxc", - [VIR_CGROUP_CONTROLLER_CPUACCT] = "/system/libvirt/lxc", - [VIR_CGROUP_CONTROLLER_CPUSET] = NULL, - [VIR_CGROUP_CONTROLLER_MEMORY] = "/libvirt/lxc", - [VIR_CGROUP_CONTROLLER_DEVICES] = NULL, - [VIR_CGROUP_CONTROLLER_FREEZER] = NULL, - [VIR_CGROUP_CONTROLLER_BLKIO] = NULL, - }; - const char *placementFull[VIR_CGROUP_CONTROLLER_LAST] = { - [VIR_CGROUP_CONTROLLER_CPU] = "/system/libvirt/lxc", - [VIR_CGROUP_CONTROLLER_CPUACCT] = "/system/libvirt/lxc", - [VIR_CGROUP_CONTROLLER_CPUSET] = "/libvirt/lxc", - [VIR_CGROUP_CONTROLLER_MEMORY] = "/libvirt/lxc", - [VIR_CGROUP_CONTROLLER_DEVICES] = NULL, - [VIR_CGROUP_CONTROLLER_FREEZER] = "/libvirt/lxc", - [VIR_CGROUP_CONTROLLER_BLKIO] = "/libvirt/lxc", - }; - - if ((rv = virCgroupNewDriver("lxc", false, -1, &cgroup)) != -1) { - fprintf(stderr, "Unexpected found LXC cgroup: %d\n", -rv); - goto cleanup; - } - ENSURE_ERRNO(ENOENT); - - if ((rv = virCgroupNewDriver("lxc", true, - (1 << VIR_CGROUP_CONTROLLER_CPU), - &cgroup)) != -1) { - fprintf(stderr, "Should not have created LXC cgroup: %d\n", -rv); - goto cleanup; - } - ENSURE_ERRNO(EINVAL); - - /* Asking for impossible combination since devices is not mounted */ - if ((rv = virCgroupNewDriver("lxc", true, - (1 << VIR_CGROUP_CONTROLLER_DEVICES), - &cgroup)) != -1) { - fprintf(stderr, "Should not have created LXC cgroup: %d\n", -rv); - goto cleanup; - } - ENSURE_ERRNO(ENXIO); - - /* Asking for small combination since devices is not mounted */ - if ((rv = virCgroupNewDriver("lxc", true, - (1 << VIR_CGROUP_CONTROLLER_CPU) | - (1 << VIR_CGROUP_CONTROLLER_CPUACCT) | - (1 << VIR_CGROUP_CONTROLLER_MEMORY), - &cgroup)) != 0) { - fprintf(stderr, "Cannot create LXC cgroup: %d\n", -rv); - goto cleanup; - } - ret = validateCgroup(cgroup, "libvirt/lxc", mountsSmall, links, placementSmall); - virCgroupFree(&cgroup); - - if ((rv = virCgroupNewDriver("lxc", true, -1, &cgroup)) != 0) { - fprintf(stderr, "Cannot create LXC cgroup: %d\n", -rv); - goto cleanup; - } - ret = validateCgroup(cgroup, "libvirt/lxc", mountsFull, links, placementFull); - -cleanup: - virCgroupFree(&cgroup); - return ret; -} - - -static int testCgroupNewForDriverDomain(const void *args ATTRIBUTE_UNUSED) -{ - virCgroupPtr drivercgroup = NULL; - virCgroupPtr domaincgroup = NULL; - int ret = -1; - int rv; - const char *placement[VIR_CGROUP_CONTROLLER_LAST] = { - [VIR_CGROUP_CONTROLLER_CPU] = "/system/libvirt/lxc/wibble", - [VIR_CGROUP_CONTROLLER_CPUACCT] = "/system/libvirt/lxc/wibble", - [VIR_CGROUP_CONTROLLER_CPUSET] = "/libvirt/lxc/wibble", - [VIR_CGROUP_CONTROLLER_MEMORY] = "/libvirt/lxc/wibble", - [VIR_CGROUP_CONTROLLER_DEVICES] = NULL, - [VIR_CGROUP_CONTROLLER_FREEZER] = "/libvirt/lxc/wibble", - [VIR_CGROUP_CONTROLLER_BLKIO] = "/libvirt/lxc/wibble", - }; - - if ((rv = virCgroupNewDriver("lxc", false, -1, &drivercgroup)) != 0) { - fprintf(stderr, "Cannot find LXC cgroup: %d\n", -rv); - goto cleanup; - } - - if ((rv = virCgroupNewDomainDriver(drivercgroup, "wibble", true, &domaincgroup)) != 0) { - fprintf(stderr, "Cannot create LXC cgroup: %d\n", -rv); - goto cleanup; - } - - ret = validateCgroup(domaincgroup, "libvirt/lxc/wibble", mountsFull, links, placement); - -cleanup: - virCgroupFree(&drivercgroup); - virCgroupFree(&domaincgroup); - return ret; -} - - static int testCgroupNewForPartition(const void *args ATTRIBUTE_UNUSED) { virCgroupPtr cgroup = NULL; @@ -537,12 +431,6 @@ mymain(void) if (virtTestRun("New cgroup for self", 1, testCgroupNewForSelf, NULL) < 0) ret = -1; - if (virtTestRun("New cgroup for driver", 1, testCgroupNewForDriver, NULL) < 0) - ret = -1; - - if (virtTestRun("New cgroup for domain driver", 1, testCgroupNewForDriverDomain, NULL) < 0) - ret = -1; - if (virtTestRun("New cgroup for partition", 1, testCgroupNewForPartition, NULL) < 0) ret = -1; -- 1.8.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list