render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
6ae9ed
From c8ef2c52d8ce4adf880dd577c04fc6ab7463753a Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <c8ef2c52d8ce4adf880dd577c04fc6ab7463753a@dist-git>
6ae9ed
From: Martin Kletzander <mkletzan@redhat.com>
6ae9ed
Date: Wed, 24 Aug 2016 16:10:56 -0400
6ae9ed
Subject: [PATCH] qemu: Use qemuProcessSetupPid() in qemuProcessSetupVcpu()
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
6ae9ed
6ae9ed
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
6ae9ed
(cherry picked from commit 949c43370e4b639a15ef81f6ae4fd439c68f1d07)
6ae9ed
---
6ae9ed
 src/qemu/qemu_process.c | 78 ++++---------------------------------------------
6ae9ed
 1 file changed, 5 insertions(+), 73 deletions(-)
6ae9ed
6ae9ed
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
6ae9ed
index de34851..4cfa81a 100644
6ae9ed
--- a/src/qemu/qemu_process.c
6ae9ed
+++ b/src/qemu/qemu_process.c
6ae9ed
@@ -4627,80 +4627,12 @@ qemuProcessSetupVcpu(virDomainObjPtr vm,
6ae9ed
 {
6ae9ed
     pid_t vcpupid = qemuDomainGetVcpuPid(vm, vcpuid);
6ae9ed
     virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, vcpuid);
6ae9ed
-    qemuDomainObjPrivatePtr priv = vm->privateData;
6ae9ed
-    char *mem_mask = NULL;
6ae9ed
-    virDomainNumatuneMemMode mem_mode;
6ae9ed
-    unsigned long long period = vm->def->cputune.period;
6ae9ed
-    long long quota = vm->def->cputune.quota;
6ae9ed
-    virCgroupPtr cgroup_vcpu = NULL;
6ae9ed
-    virBitmapPtr cpumask;
6ae9ed
-    int ret = -1;
6ae9ed
 
6ae9ed
-    if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU) ||
6ae9ed
-        virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
6ae9ed
-
6ae9ed
-        if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 &&
6ae9ed
-            mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
6ae9ed
-            virDomainNumatuneMaybeFormatNodeset(vm->def->numa,
6ae9ed
-                                                priv->autoNodeset,
6ae9ed
-                                                &mem_mask, -1) < 0)
6ae9ed
-            goto cleanup;
6ae9ed
-
6ae9ed
-        if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, vcpuid,
6ae9ed
-                               true, &cgroup_vcpu) < 0)
6ae9ed
-            goto cleanup;
6ae9ed
-
6ae9ed
-        if (period || quota) {
6ae9ed
-            if (qemuSetupCgroupVcpuBW(cgroup_vcpu, period, quota) < 0)
6ae9ed
-                goto cleanup;
6ae9ed
-        }
6ae9ed
-    }
6ae9ed
-
6ae9ed
-    /* infer which cpumask shall be used */
6ae9ed
-    if (vcpu->cpumask)
6ae9ed
-        cpumask = vcpu->cpumask;
6ae9ed
-    else if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)
6ae9ed
-        cpumask = priv->autoCpuset;
6ae9ed
-    else
6ae9ed
-        cpumask = vm->def->cpumask;
6ae9ed
-
6ae9ed
-    /* setup cgroups */
6ae9ed
-    if (cgroup_vcpu) {
6ae9ed
-        if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
6ae9ed
-            if (mem_mask && virCgroupSetCpusetMems(cgroup_vcpu, mem_mask) < 0)
6ae9ed
-                goto cleanup;
6ae9ed
-
6ae9ed
-            if (cpumask && qemuSetupCgroupCpusetCpus(cgroup_vcpu, cpumask) < 0)
6ae9ed
-                goto cleanup;
6ae9ed
-        }
6ae9ed
-
6ae9ed
-        /* move the thread for vcpu to sub dir */
6ae9ed
-        if (virCgroupAddTask(cgroup_vcpu, vcpupid) < 0)
6ae9ed
-            goto cleanup;
6ae9ed
-    }
6ae9ed
-
6ae9ed
-    /* setup legacy affinty */
6ae9ed
-    if (cpumask && virProcessSetAffinity(vcpupid, cpumask) < 0)
6ae9ed
-        goto cleanup;
6ae9ed
-
6ae9ed
-    /* set scheduler type and priority */
6ae9ed
-    if (vcpu->sched.policy != VIR_PROC_POLICY_NONE) {
6ae9ed
-        if (virProcessSetScheduler(vcpupid, vcpu->sched.policy,
6ae9ed
-                                   vcpu->sched.priority) < 0)
6ae9ed
-            goto cleanup;
6ae9ed
-    }
6ae9ed
-
6ae9ed
-    ret = 0;
6ae9ed
-
6ae9ed
- cleanup:
6ae9ed
-    VIR_FREE(mem_mask);
6ae9ed
-    if (cgroup_vcpu) {
6ae9ed
-        if (ret < 0)
6ae9ed
-            virCgroupRemove(cgroup_vcpu);
6ae9ed
-        virCgroupFree(&cgroup_vcpu);
6ae9ed
-    }
6ae9ed
-
6ae9ed
-    return ret;
6ae9ed
+    return qemuProcessSetupPid(vm, vcpupid, VIR_CGROUP_THREAD_VCPU,
6ae9ed
+                               vcpuid, vcpu->cpumask,
6ae9ed
+                               vm->def->cputune.period,
6ae9ed
+                               vm->def->cputune.quota,
6ae9ed
+                               &vcpu->sched);
6ae9ed
 }
6ae9ed
 
6ae9ed
 
6ae9ed
-- 
6ae9ed
2.10.0
6ae9ed