]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Introduce the function virCgroupForEmulator
authorWen Congyang <wency@cn.fujitsu.com>
Tue, 21 Aug 2012 09:18:24 +0000 (17:18 +0800)
committerDaniel Veillard <veillard@redhat.com>
Wed, 22 Aug 2012 06:25:06 +0000 (14:25 +0800)
Introduce the function virCgroupForEmulator() to create sub directory
for simulator thread(include I/O thread, vhost-net thread)

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
src/libvirt_private.syms
src/util/cgroup.c
src/util/cgroup.h

index b20a7546994158fe7e9083864f1662eb9a889e26..a51aa91e9d5ab5993526efc93a0a0b05412352f3 100644 (file)
@@ -71,6 +71,7 @@ virCgroupDenyDeviceMajor;
 virCgroupDenyDevicePath;
 virCgroupForDomain;
 virCgroupForDriver;
+virCgroupForEmulator;
 virCgroupForVcpu;
 virCgroupFree;
 virCgroupGetBlkioWeight;
index 2256c23af4a28c2410d1e28017d43c1eb350e038..169b56a37b69d154f99b431127dc90e79abe16e9 100644 (file)
@@ -956,6 +956,48 @@ int virCgroupForVcpu(virCgroupPtr driver ATTRIBUTE_UNUSED,
 }
 #endif
 
+/**
+ * virCgroupForEmulator:
+ *
+ * @driver: group for the domain
+ * @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,
+                          int create)
+{
+    int rc;
+    char *path;
+
+    if (driver == NULL)
+        return -EINVAL;
+
+    if (virAsprintf(&path, "%s/emulator", 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 virCgroupForEmulator(virCgroupPtr driver ATTRIBUTE_UNUSED,
+                          virCgroupPtr *group ATTRIBUTE_UNUSED,
+                          int create ATTRIBUTE_UNUSED)
+{
+    return -ENXIO;
+}
+
+#endif
 /**
  * virCgroupSetBlkioWeight:
  *
index 265f7c96c795581a626bf7661241f9c8c4c82162..9f803a511154e764fc64614f5617b2bd21c32c49 100644 (file)
@@ -59,6 +59,10 @@ int virCgroupForVcpu(virCgroupPtr driver,
                      virCgroupPtr *group,
                      int create);
 
+int virCgroupForEmulator(virCgroupPtr driver,
+                         virCgroupPtr *group,
+                         int create);
+
 int virCgroupPathOfController(virCgroupPtr group,
                               int controller,
                               const char *key,