|
|
404507 |
From 72285626fa7b899ceb9c8d4358b4b1b3fa7081a4 Mon Sep 17 00:00:00 2001
|
|
|
404507 |
Message-Id: <72285626fa7b899ceb9c8d4358b4b1b3fa7081a4@dist-git>
|
|
|
404507 |
From: Martin Kletzander <mkletzan@redhat.com>
|
|
|
404507 |
Date: Wed, 31 Jan 2018 16:32:32 +0100
|
|
|
404507 |
Subject: [PATCH] qemu: Add support for resctrl
|
|
|
404507 |
|
|
|
404507 |
We've been building up to this. This adds support for cputune/cachetune
|
|
|
404507 |
settings for domains in the QEMU driver. The addition into
|
|
|
404507 |
qemuProcessSetupVcpu() automatically adds support for hotplug. For hot-unplug
|
|
|
404507 |
we need to remove the allocation only if all the vCPUs were unplugged. But
|
|
|
404507 |
since the threads are left running, we can't really do much about it now.
|
|
|
404507 |
|
|
|
404507 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1289368
|
|
|
404507 |
|
|
|
404507 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
404507 |
(cherry picked from commit 9a2fc2db8fe18da41c274d52b6e52316a4bbe52d)
|
|
|
404507 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
404507 |
|
|
|
404507 |
https://bugzilla.redhat.com/show_bug.cgi?id=1289368
|
|
|
404507 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
404507 |
---
|
|
|
404507 |
src/qemu/qemu_process.c | 60 ++++++++++++++++++++++++++++++++++++++++++++-----
|
|
|
404507 |
1 file changed, 55 insertions(+), 5 deletions(-)
|
|
|
404507 |
|
|
|
404507 |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
404507 |
index c64088e4ca..57faf9cd79 100644
|
|
|
404507 |
--- a/src/qemu/qemu_process.c
|
|
|
404507 |
+++ b/src/qemu/qemu_process.c
|
|
|
404507 |
@@ -2504,6 +2504,32 @@ qemuProcessSetupEmulator(virDomainObjPtr vm)
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
|
|
|
404507 |
+static int
|
|
|
404507 |
+qemuProcessResctrlCreate(virQEMUDriverPtr driver,
|
|
|
404507 |
+ virDomainObjPtr vm)
|
|
|
404507 |
+{
|
|
|
404507 |
+ int ret = -1;
|
|
|
404507 |
+ size_t i = 0;
|
|
|
404507 |
+ virCapsPtr caps = virQEMUDriverGetCapabilities(driver, false);
|
|
|
404507 |
+ qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
404507 |
+
|
|
|
404507 |
+ if (!caps)
|
|
|
404507 |
+ return -1;
|
|
|
404507 |
+
|
|
|
404507 |
+ for (i = 0; i < vm->def->ncachetunes; i++) {
|
|
|
404507 |
+ if (virResctrlAllocCreate(caps->host.resctrl,
|
|
|
404507 |
+ vm->def->cachetunes[i]->alloc,
|
|
|
404507 |
+ priv->machineName) < 0)
|
|
|
404507 |
+ goto cleanup;
|
|
|
404507 |
+ }
|
|
|
404507 |
+
|
|
|
404507 |
+ ret = 0;
|
|
|
404507 |
+ cleanup:
|
|
|
404507 |
+ virObjectUnref(caps);
|
|
|
404507 |
+ return ret;
|
|
|
404507 |
+}
|
|
|
404507 |
+
|
|
|
404507 |
+
|
|
|
404507 |
static int
|
|
|
404507 |
qemuProcessInitPasswords(virConnectPtr conn,
|
|
|
404507 |
virQEMUDriverPtr driver,
|
|
|
404507 |
@@ -5015,12 +5041,26 @@ qemuProcessSetupVcpu(virDomainObjPtr vm,
|
|
|
404507 |
{
|
|
|
404507 |
pid_t vcpupid = qemuDomainGetVcpuPid(vm, vcpuid);
|
|
|
404507 |
virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, vcpuid);
|
|
|
404507 |
+ size_t i = 0;
|
|
|
404507 |
|
|
|
404507 |
- return qemuProcessSetupPid(vm, vcpupid, VIR_CGROUP_THREAD_VCPU,
|
|
|
404507 |
- vcpuid, vcpu->cpumask,
|
|
|
404507 |
- vm->def->cputune.period,
|
|
|
404507 |
- vm->def->cputune.quota,
|
|
|
404507 |
- &vcpu->sched);
|
|
|
404507 |
+ if (qemuProcessSetupPid(vm, vcpupid, VIR_CGROUP_THREAD_VCPU,
|
|
|
404507 |
+ vcpuid, vcpu->cpumask,
|
|
|
404507 |
+ vm->def->cputune.period,
|
|
|
404507 |
+ vm->def->cputune.quota,
|
|
|
404507 |
+ &vcpu->sched) < 0)
|
|
|
404507 |
+ return -1;
|
|
|
404507 |
+
|
|
|
404507 |
+ for (i = 0; i < vm->def->ncachetunes; i++) {
|
|
|
404507 |
+ virDomainCachetuneDefPtr ct = vm->def->cachetunes[i];
|
|
|
404507 |
+
|
|
|
404507 |
+ if (virBitmapIsBitSet(ct->vcpus, vcpuid)) {
|
|
|
404507 |
+ if (virResctrlAllocAddPID(ct->alloc, vcpupid) < 0)
|
|
|
404507 |
+ return -1;
|
|
|
404507 |
+ break;
|
|
|
404507 |
+ }
|
|
|
404507 |
+ }
|
|
|
404507 |
+
|
|
|
404507 |
+ return 0;
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
|
|
|
404507 |
@@ -5892,6 +5932,10 @@ qemuProcessLaunch(virConnectPtr conn,
|
|
|
404507 |
if (qemuProcessSetupEmulator(vm) < 0)
|
|
|
404507 |
goto cleanup;
|
|
|
404507 |
|
|
|
404507 |
+ VIR_DEBUG("Setting up resctrlfs");
|
|
|
404507 |
+ if (qemuProcessResctrlCreate(driver, vm) < 0)
|
|
|
404507 |
+ goto cleanup;
|
|
|
404507 |
+
|
|
|
404507 |
VIR_DEBUG("Setting domain security labels");
|
|
|
404507 |
if (qemuSecuritySetAllLabel(driver,
|
|
|
404507 |
vm,
|
|
|
404507 |
@@ -6540,6 +6584,12 @@ void qemuProcessStop(virQEMUDriverPtr driver,
|
|
|
404507 |
vm->def->name);
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
+ /* Remove resctrl allocation after cgroups are cleaned up which makes it
|
|
|
404507 |
+ * kind of safer (although removing the allocation should work even with
|
|
|
404507 |
+ * pids in tasks file */
|
|
|
404507 |
+ for (i = 0; i < vm->def->ncachetunes; i++)
|
|
|
404507 |
+ virResctrlAllocRemove(vm->def->cachetunes[i]->alloc);
|
|
|
404507 |
+
|
|
|
404507 |
qemuProcessRemoveDomainStatus(driver, vm);
|
|
|
404507 |
|
|
|
404507 |
/* Remove VNC and Spice ports from port reservation bitmap, but only if
|
|
|
404507 |
--
|
|
|
404507 |
2.16.1
|
|
|
404507 |
|