]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_cgroup: use virCgroupAddTask instead of virCgroupMoveTask
authorHenning Schild <henning.schild@siemens.com>
Fri, 26 Feb 2016 15:34:24 +0000 (16:34 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 1 Mar 2016 14:07:27 +0000 (14:07 +0000)
qemuProcessSetupEmulator runs at a point in time where there is only
the qemu main thread. Use virCgroupAddTask to put just that one task
into the emulator cgroup. That patch makes virCgroupMoveTask and
virCgroupAddTaskStrController obsolete.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
src/libvirt_private.syms
src/qemu/qemu_process.c
src/util/vircgroup.c
src/util/vircgroup.h

index 4c53bf42a0bfca2db6053e5a51460a6bf54154bf..5251dc0bc9e4b6ba57257bd6702a5cb6750c4968 100644 (file)
@@ -1231,7 +1231,6 @@ virCgroupHasEmptyTasks;
 virCgroupKill;
 virCgroupKillPainfully;
 virCgroupKillRecursive;
-virCgroupMoveTask;
 virCgroupNewDetect;
 virCgroupNewDetectMachine;
 virCgroupNewDomainPartition;
index fa2bdb834eb9c6164085ecd1f89241db2638e540..13813131f2d28d3b9fe6a628b461f5ae7ef53f75 100644 (file)
@@ -2220,7 +2220,7 @@ qemuProcessSetupEmulator(virDomainObjPtr vm)
                                true, &cgroup_emulator) < 0)
             goto cleanup;
 
-        if (virCgroupMoveTask(priv->cgroup, cgroup_emulator) < 0)
+        if (virCgroupAddTask(cgroup_emulator, vm->pid) < 0)
             goto cleanup;
 
 
index 706d27cec3bde5ee89be2be0f7af13403f20f084..bffd88f90a44599a228305a8e0c5556a51282009 100644 (file)
@@ -1223,99 +1223,6 @@ virCgroupAddTaskController(virCgroupPtr group, pid_t pid, int controller)
 }
 
 
-static int
-virCgroupAddTaskStrController(virCgroupPtr group,
-                              const char *pidstr,
-                              int controller)
-{
-    char *str = NULL, *cur = NULL, *next = NULL;
-    unsigned long long p = 0;
-    int rc = 0;
-    char *endp;
-
-    if (VIR_STRDUP(str, pidstr) < 0)
-        return -1;
-
-    cur = str;
-    while (*cur != '\0') {
-        if (virStrToLong_ull(cur, &endp, 10, &p) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Cannot parse '%s' as an integer"), cur);
-            goto cleanup;
-        }
-
-        if (virCgroupAddTaskController(group, p, controller) < 0) {
-            /* A thread that exits between when we first read the source
-             * tasks and now is not fatal.  */
-            if (virLastErrorIsSystemErrno(ESRCH))
-                virResetLastError();
-            else
-                goto cleanup;
-        }
-
-        next = strchr(cur, '\n');
-        if (next) {
-            cur = next + 1;
-            *next = '\0';
-        } else {
-            break;
-        }
-    }
-
- cleanup:
-    VIR_FREE(str);
-    return rc;
-}
-
-
-/**
- * virCgroupMoveTask:
- *
- * @src_group: The source cgroup where all tasks are removed from
- * @dest_group: The destination where all tasks are added to
- *
- * Returns: 0 on success or -1 on failure
- */
-int
-virCgroupMoveTask(virCgroupPtr src_group, virCgroupPtr dest_group)
-{
-    int ret = -1;
-    char *content = NULL;
-    size_t i;
-
-    for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
-        if (!src_group->controllers[i].mountPoint ||
-            !dest_group->controllers[i].mountPoint)
-            continue;
-
-        /* We must never move tasks in systemd's hierarchy */
-        if (i == VIR_CGROUP_CONTROLLER_SYSTEMD)
-            continue;
-
-        /* New threads are created in the same group as their parent;
-         * but if a thread is created after we first read we aren't
-         * aware that it needs to move.  Therefore, we must iterate
-         * until content is empty.  */
-        while (1) {
-            VIR_FREE(content);
-            if (virCgroupGetValueStr(src_group, i, "tasks", &content) < 0)
-                return -1;
-
-            if (!*content)
-                break;
-
-            if (virCgroupAddTaskStrController(dest_group, content, i) < 0)
-                goto cleanup;
-        }
-    }
-
-    ret = 0;
- cleanup:
-    VIR_FREE(content);
-    return ret;
-}
-
-
 static int
 virCgroupSetPartitionSuffix(const char *path, char **res)
 {
@@ -4324,16 +4231,6 @@ virCgroupAddTaskController(virCgroupPtr group ATTRIBUTE_UNUSED,
 }
 
 
-int
-virCgroupMoveTask(virCgroupPtr src_group ATTRIBUTE_UNUSED,
-                  virCgroupPtr dest_group ATTRIBUTE_UNUSED)
-{
-    virReportSystemError(ENXIO, "%s",
-                         _("Control groups not supported on this platform"));
-    return -1;
-}
-
-
 int
 virCgroupGetBlkioIoServiced(virCgroupPtr group ATTRIBUTE_UNUSED,
                             long long *bytes_read ATTRIBUTE_UNUSED,
index 7914cbbdaa7a3c9a01f45625601066e9292fbb87..2ddbb350f17c308c5de9c55be166fae56a31a9f1 100644 (file)
@@ -132,9 +132,6 @@ int virCgroupAddTaskController(virCgroupPtr group,
                                pid_t pid,
                                int controller);
 
-int virCgroupMoveTask(virCgroupPtr src_group,
-                      virCgroupPtr dest_group);
-
 int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight);
 int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight);