[PATCH 01/13] Introduce the function virCgroupForHypervisor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce the function virCgroupForHypervisor() to create sub directory
for hypervisor thread(include I/O thread, vhost-net thread)
---
 src/libvirt_private.syms |    1 +
 src/util/cgroup.c        |   42 ++++++++++++++++++++++++++++++++++++++++++
 src/util/cgroup.h        |    4 ++++
 3 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index fdf2186..c581063 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -67,6 +67,7 @@ virCgroupDenyAllDevices;
 virCgroupDenyDevicePath;
 virCgroupForDomain;
 virCgroupForDriver;
+virCgroupForHypervisor;
 virCgroupForVcpu;
 virCgroupFree;
 virCgroupGetBlkioWeight;
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 5b32881..66d98e3 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -946,6 +946,48 @@ int virCgroupForVcpu(virCgroupPtr driver ATTRIBUTE_UNUSED,
 #endif
 
 /**
+ * virCgroupForHypervisor:
+ *
+ * @driver: group for the domain
+ * @group: Pointer to returned virCgroupPtr
+ *
+ * Returns 0 on success
+ */
+#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
+int virCgroupForHypervisor(virCgroupPtr driver,
+                           virCgroupPtr *group,
+                           int create)
+{
+    int rc;
+    char *path;
+
+    if (driver == NULL)
+        return -EINVAL;
+
+    if (virAsprintf(&path, "%s/hypervisor", driver->path) < 0)
+        return -ENOMEM;
+
+    rc = virCgroupNew(path, group);
+    VIR_FREE(path);
+
+    if (rc == 0) {
+        rc = virCgroupMakeGroup(driver, *group, create, VIR_CGROUP_VCPU);
+        if (rc != 0)
+            virCgroupFree(group);
+    }
+
+    return rc;
+}
+#else
+int virCgroupForHypervisor(virCgroupPtr driver ATTRIBUTE_UNUSED,
+                           virCgroupPtr *group ATTRIBUTE_UNUSED,
+                           int create ATTRIBUTE_UNUSED)
+{
+    return -ENXIO;
+}
+
+#endif
+/**
  * virCgroupSetBlkioWeight:
  *
  * @group: The cgroup to change io weight for
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index 05325ae..315ebd6 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -47,6 +47,10 @@ int virCgroupForVcpu(virCgroupPtr driver,
                      virCgroupPtr *group,
                      int create);
 
+int virCgroupForHypervisor(virCgroupPtr driver,
+                           virCgroupPtr *group,
+                           int create);
+
 int virCgroupPathOfController(virCgroupPtr group,
                               int controller,
                               const char *key,
-- 
1.7.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]