]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vircgroup: Introduce virCgroupNewIOThread
authorJohn Ferlan <jferlan@redhat.com>
Wed, 3 Sep 2014 13:04:07 +0000 (09:04 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 15 Sep 2014 17:18:56 +0000 (13:18 -0400)
Add virCgroupNewIOThread() to mimic virCgroupNewVcpu() except the naming
scheme with use "iothread" rather than "vcpu".

src/libvirt_private.syms
src/util/vircgroup.c
src/util/vircgroup.h

index f128b0ccfc282258ebb2ca66b38ba46b1320d87a..51a692b39ba30ff037a35af949aafea8f00a9d6e 100644 (file)
@@ -1089,6 +1089,7 @@ virCgroupNewDetectMachine;
 virCgroupNewDomainPartition;
 virCgroupNewEmulator;
 virCgroupNewIgnoreError;
+virCgroupNewIOThread;
 virCgroupNewMachine;
 virCgroupNewPartition;
 virCgroupNewSelf;
index a64f08108e04ad04b39cb2bd5f5ecd0862dc0946..13c7b7da192383fb2550013fa359c836b7594a80 100644 (file)
@@ -1492,6 +1492,49 @@ virCgroupNewEmulator(virCgroupPtr domain,
 }
 
 
+/**
+ * virCgroupNewIOThread:
+ *
+ * @domain: group for the domain
+ * @iothreadid: id of the iothread
+ * @create: true to create if not already existing
+ * @group: Pointer to returned virCgroupPtr
+ *
+ * Returns 0 on success, or -1 on error
+ */
+int
+virCgroupNewIOThread(virCgroupPtr domain,
+                     int iothreadid,
+                     bool create,
+                     virCgroupPtr *group)
+{
+    int ret = -1;
+    char *name = NULL;
+    int controllers;
+
+    if (virAsprintf(&name, "iothread%d", iothreadid) < 0)
+        goto cleanup;
+
+    controllers = ((1 << VIR_CGROUP_CONTROLLER_CPU) |
+                   (1 << VIR_CGROUP_CONTROLLER_CPUACCT) |
+                   (1 << VIR_CGROUP_CONTROLLER_CPUSET));
+
+    if (virCgroupNew(-1, name, domain, controllers, group) < 0)
+        goto cleanup;
+
+    if (virCgroupMakeGroup(domain, *group, create, VIR_CGROUP_NONE) < 0) {
+        virCgroupRemove(*group);
+        virCgroupFree(group);
+        goto cleanup;
+    }
+
+    ret = 0;
+ cleanup:
+    VIR_FREE(name);
+    return ret;
+}
+
+
 int
 virCgroupNewDetect(pid_t pid,
                    int controllers,
index 90b41f78ef0927488555c83881147d44b93bfa8b..19e82d16eb27da9273bca4bf7ce245dd721d98de 100644 (file)
@@ -76,6 +76,12 @@ int virCgroupNewEmulator(virCgroupPtr domain,
                          virCgroupPtr *group)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
 
+int virCgroupNewIOThread(virCgroupPtr domain,
+                         int iothreadid,
+                         bool create,
+                         virCgroupPtr *group)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
+
 int virCgroupNewDetect(pid_t pid,
                        int controllers,
                        virCgroupPtr *group);