|
|
9119d9 |
From 86d3bdb4d60def4336ac23f62d4ef3fcf49956bf Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <86d3bdb4d60def4336ac23f62d4ef3fcf49956bf@dist-git>
|
|
|
9119d9 |
From: Martin Kletzander <mkletzan@redhat.com>
|
|
|
9119d9 |
Date: Thu, 15 Jan 2015 15:03:47 +0100
|
|
|
9119d9 |
Subject: [PATCH] qemu: Save numad advice into qemuDomainObjPrivate
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1161540
|
|
|
9119d9 |
|
|
|
9119d9 |
Thanks to that we don't need to drag the pointer everywhere and future
|
|
|
9119d9 |
code will get cleaner.
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit c74d58ad4770cb2e2060f81ce32bc78c8ed31e5a)
|
|
|
9119d9 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
9119d9 |
|
|
|
9119d9 |
Conflicts:
|
|
|
9119d9 |
src/qemu/qemu_cgroup.h -- 4882618e
|
|
|
9119d9 |
src/qemu/qemu_process.c -- c63ef045
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu_cgroup.c | 18 +++++++-----------
|
|
|
9119d9 |
src/qemu/qemu_cgroup.h | 9 +++------
|
|
|
9119d9 |
src/qemu/qemu_domain.c | 1 +
|
|
|
9119d9 |
src/qemu/qemu_domain.h | 1 +
|
|
|
9119d9 |
src/qemu/qemu_process.c | 21 ++++++++++-----------
|
|
|
9119d9 |
5 files changed, 22 insertions(+), 28 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
|
|
|
9119d9 |
index ac12f43..fa94037 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_cgroup.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_cgroup.c
|
|
|
9119d9 |
@@ -608,8 +608,7 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
|
|
|
9119d9 |
|
|
|
9119d9 |
|
|
|
9119d9 |
int
|
|
|
9119d9 |
-qemuSetupCpusetMems(virDomainObjPtr vm,
|
|
|
9119d9 |
- virBitmapPtr nodemask)
|
|
|
9119d9 |
+qemuSetupCpusetMems(virDomainObjPtr vm)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
virCgroupPtr cgroup_temp = NULL;
|
|
|
9119d9 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
9119d9 |
@@ -620,7 +619,7 @@ qemuSetupCpusetMems(virDomainObjPtr vm,
|
|
|
9119d9 |
return 0;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (virDomainNumatuneMaybeFormatNodeset(vm->def->numatune,
|
|
|
9119d9 |
- nodemask,
|
|
|
9119d9 |
+ priv->autoNodeset,
|
|
|
9119d9 |
&mem_mask, -1) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -640,7 +639,6 @@ qemuSetupCpusetMems(virDomainObjPtr vm,
|
|
|
9119d9 |
|
|
|
9119d9 |
static int
|
|
|
9119d9 |
qemuSetupCpusetCgroup(virDomainObjPtr vm,
|
|
|
9119d9 |
- virBitmapPtr nodemask,
|
|
|
9119d9 |
virCapsPtr caps)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
9119d9 |
@@ -655,7 +653,7 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm,
|
|
|
9119d9 |
|
|
|
9119d9 |
if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
|
|
|
9119d9 |
virBitmapPtr cpumap;
|
|
|
9119d9 |
- if (!(cpumap = virCapabilitiesGetCpusForNodemask(caps, nodemask)))
|
|
|
9119d9 |
+ if (!(cpumap = virCapabilitiesGetCpusForNodemask(caps, priv->autoNodeset)))
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
cpu_mask = virBitmapFormat(cpumap);
|
|
|
9119d9 |
virBitmapFree(cpumap);
|
|
|
9119d9 |
@@ -819,8 +817,7 @@ qemuConnectCgroup(virQEMUDriverPtr driver,
|
|
|
9119d9 |
|
|
|
9119d9 |
int
|
|
|
9119d9 |
qemuSetupCgroup(virQEMUDriverPtr driver,
|
|
|
9119d9 |
- virDomainObjPtr vm,
|
|
|
9119d9 |
- virBitmapPtr nodemask)
|
|
|
9119d9 |
+ virDomainObjPtr vm)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
9119d9 |
virCapsPtr caps = NULL;
|
|
|
9119d9 |
@@ -853,7 +850,7 @@ qemuSetupCgroup(virQEMUDriverPtr driver,
|
|
|
9119d9 |
if (qemuSetupCpuCgroup(driver, vm) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (qemuSetupCpusetCgroup(vm, nodemask, caps) < 0)
|
|
|
9119d9 |
+ if (qemuSetupCpusetCgroup(vm, caps) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
ret = 0;
|
|
|
9119d9 |
@@ -1040,8 +1037,7 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm)
|
|
|
9119d9 |
|
|
|
9119d9 |
int
|
|
|
9119d9 |
qemuSetupCgroupForEmulator(virQEMUDriverPtr driver,
|
|
|
9119d9 |
- virDomainObjPtr vm,
|
|
|
9119d9 |
- virBitmapPtr nodemask)
|
|
|
9119d9 |
+ virDomainObjPtr vm)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
virBitmapPtr cpumask = NULL;
|
|
|
9119d9 |
virBitmapPtr cpumap = NULL;
|
|
|
9119d9 |
@@ -1077,7 +1073,7 @@ qemuSetupCgroupForEmulator(virQEMUDriverPtr driver,
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
|
|
|
9119d9 |
- if (!(cpumap = qemuPrepareCpumap(driver, nodemask)))
|
|
|
9119d9 |
+ if (!(cpumap = qemuPrepareCpumap(driver, priv->autoNodeset)))
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
cpumask = cpumap;
|
|
|
9119d9 |
} else if (def->cputune.emulatorpin) {
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
|
|
|
9119d9 |
index 2ae16df..8d9de3c 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_cgroup.h
|
|
|
9119d9 |
+++ b/src/qemu/qemu_cgroup.h
|
|
|
9119d9 |
@@ -45,10 +45,8 @@ int qemuTeardownHostdevCgroup(virDomainObjPtr vm,
|
|
|
9119d9 |
int qemuConnectCgroup(virQEMUDriverPtr driver,
|
|
|
9119d9 |
virDomainObjPtr vm);
|
|
|
9119d9 |
int qemuSetupCgroup(virQEMUDriverPtr driver,
|
|
|
9119d9 |
- virDomainObjPtr vm,
|
|
|
9119d9 |
- virBitmapPtr nodemask);
|
|
|
9119d9 |
-int qemuSetupCpusetMems(virDomainObjPtr vm,
|
|
|
9119d9 |
- virBitmapPtr nodemask);
|
|
|
9119d9 |
+ virDomainObjPtr vm);
|
|
|
9119d9 |
+int qemuSetupCpusetMems(virDomainObjPtr vm);
|
|
|
9119d9 |
int qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
|
|
|
9119d9 |
unsigned long long period,
|
|
|
9119d9 |
long long quota);
|
|
|
9119d9 |
@@ -64,8 +62,7 @@ int qemuSetupCgroupIOThreadsPin(virCgroupPtr cgroup,
|
|
|
9119d9 |
int qemuSetupCgroupForVcpu(virDomainObjPtr vm);
|
|
|
9119d9 |
int qemuSetupCgroupForIOThreads(virDomainObjPtr vm);
|
|
|
9119d9 |
int qemuSetupCgroupForEmulator(virQEMUDriverPtr driver,
|
|
|
9119d9 |
- virDomainObjPtr vm,
|
|
|
9119d9 |
- virBitmapPtr nodemask);
|
|
|
9119d9 |
+ virDomainObjPtr vm);
|
|
|
9119d9 |
int qemuRemoveCgroup(virDomainObjPtr vm);
|
|
|
9119d9 |
int qemuAddToCgroup(virDomainObjPtr vm);
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
9119d9 |
index 0cfc603..03ca663 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_domain.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_domain.c
|
|
|
9119d9 |
@@ -461,6 +461,7 @@ qemuDomainObjPrivateFree(void *data)
|
|
|
9119d9 |
qemuAgentClose(priv->agent);
|
|
|
9119d9 |
}
|
|
|
9119d9 |
VIR_FREE(priv->cleanupCallbacks);
|
|
|
9119d9 |
+ virBitmapFree(priv->autoNodeset);
|
|
|
9119d9 |
VIR_FREE(priv);
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
|
|
9119d9 |
index 9c94a65..53501f9 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_domain.h
|
|
|
9119d9 |
+++ b/src/qemu/qemu_domain.h
|
|
|
9119d9 |
@@ -187,6 +187,7 @@ struct _qemuDomainObjPrivate {
|
|
|
9119d9 |
char **qemuDevices; /* NULL-terminated list of devices aliases known to QEMU */
|
|
|
9119d9 |
|
|
|
9119d9 |
bool hookRun; /* true if there was a hook run over this domain */
|
|
|
9119d9 |
+ virBitmapPtr autoNodeset;
|
|
|
9119d9 |
};
|
|
|
9119d9 |
|
|
|
9119d9 |
typedef enum {
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
9119d9 |
index c055eb7..90e45a8 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_process.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_process.c
|
|
|
9119d9 |
@@ -2373,12 +2373,12 @@ qemuPrepareCpumap(virQEMUDriverPtr driver,
|
|
|
9119d9 |
*/
|
|
|
9119d9 |
static int
|
|
|
9119d9 |
qemuProcessInitCpuAffinity(virQEMUDriverPtr driver,
|
|
|
9119d9 |
- virDomainObjPtr vm,
|
|
|
9119d9 |
- virBitmapPtr nodemask)
|
|
|
9119d9 |
+ virDomainObjPtr vm)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
int ret = -1;
|
|
|
9119d9 |
virBitmapPtr cpumap = NULL;
|
|
|
9119d9 |
virBitmapPtr cpumapToSet = NULL;
|
|
|
9119d9 |
+ qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (!vm->pid) {
|
|
|
9119d9 |
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
9119d9 |
@@ -2386,7 +2386,7 @@ qemuProcessInitCpuAffinity(virQEMUDriverPtr driver,
|
|
|
9119d9 |
return -1;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (!(cpumap = qemuPrepareCpumap(driver, nodemask)))
|
|
|
9119d9 |
+ if (!(cpumap = qemuPrepareCpumap(driver, priv->autoNodeset)))
|
|
|
9119d9 |
return -1;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
|
|
|
9119d9 |
@@ -3115,13 +3115,13 @@ struct qemuProcessHookData {
|
|
|
9119d9 |
virConnectPtr conn;
|
|
|
9119d9 |
virDomainObjPtr vm;
|
|
|
9119d9 |
virQEMUDriverPtr driver;
|
|
|
9119d9 |
- virBitmapPtr nodemask;
|
|
|
9119d9 |
virQEMUDriverConfigPtr cfg;
|
|
|
9119d9 |
};
|
|
|
9119d9 |
|
|
|
9119d9 |
static int qemuProcessHook(void *data)
|
|
|
9119d9 |
{
|
|
|
9119d9 |
struct qemuProcessHookData *h = data;
|
|
|
9119d9 |
+ qemuDomainObjPrivatePtr priv = h->vm->privateData;
|
|
|
9119d9 |
int ret = -1;
|
|
|
9119d9 |
int fd;
|
|
|
9119d9 |
/* This method cannot use any mutexes, which are not
|
|
|
9119d9 |
@@ -3153,7 +3153,7 @@ static int qemuProcessHook(void *data)
|
|
|
9119d9 |
if (virSecurityManagerClearSocketLabel(h->driver->securityManager, h->vm->def) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (virNumaSetupMemoryPolicy(h->vm->def->numatune, h->nodemask) < 0)
|
|
|
9119d9 |
+ if (virNumaSetupMemoryPolicy(h->vm->def->numatune, priv->autoNodeset) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
ret = 0;
|
|
|
9119d9 |
@@ -4511,7 +4511,7 @@ int qemuProcessStart(virConnectPtr conn,
|
|
|
9119d9 |
if (virBitmapParse(nodeset, 0, &nodemask, VIR_DOMAIN_CPUMASK_LEN) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
- hookData.nodemask = nodemask;
|
|
|
9119d9 |
+ priv->autoNodeset = nodemask;
|
|
|
9119d9 |
|
|
|
9119d9 |
/* "volume" type disk's source must be translated before
|
|
|
9119d9 |
* cgroup and security setting.
|
|
|
9119d9 |
@@ -4715,13 +4715,13 @@ int qemuProcessStart(virConnectPtr conn,
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
VIR_DEBUG("Setting up domain cgroup (if required)");
|
|
|
9119d9 |
- if (qemuSetupCgroup(driver, vm, nodemask) < 0)
|
|
|
9119d9 |
+ if (qemuSetupCgroup(driver, vm) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
/* This must be done after cgroup placement to avoid resetting CPU
|
|
|
9119d9 |
* affinity */
|
|
|
9119d9 |
if (!vm->def->cputune.emulatorpin &&
|
|
|
9119d9 |
- qemuProcessInitCpuAffinity(driver, vm, nodemask) < 0)
|
|
|
9119d9 |
+ qemuProcessInitCpuAffinity(driver, vm) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
VIR_DEBUG("Setting domain security labels");
|
|
|
9119d9 |
@@ -4769,7 +4769,7 @@ int qemuProcessStart(virConnectPtr conn,
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
VIR_DEBUG("Setting cgroup for emulator (if required)");
|
|
|
9119d9 |
- if (qemuSetupCgroupForEmulator(driver, vm, nodemask) < 0)
|
|
|
9119d9 |
+ if (qemuSetupCgroupForEmulator(driver, vm) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
VIR_DEBUG("Setting affinity of emulator threads");
|
|
|
9119d9 |
@@ -4796,7 +4796,7 @@ int qemuProcessStart(virConnectPtr conn,
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
VIR_DEBUG("Setting up post-init cgroup restrictions");
|
|
|
9119d9 |
- if (qemuSetupCpusetMems(vm, nodemask) < 0)
|
|
|
9119d9 |
+ if (qemuSetupCpusetMems(vm) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
VIR_DEBUG("Detecting VCPU PIDs");
|
|
|
9119d9 |
@@ -4938,7 +4938,6 @@ int qemuProcessStart(virConnectPtr conn,
|
|
|
9119d9 |
* if we failed to initialize the now running VM. kill it off and
|
|
|
9119d9 |
* pretend we never started it */
|
|
|
9119d9 |
VIR_FREE(nodeset);
|
|
|
9119d9 |
- virBitmapFree(nodemask);
|
|
|
9119d9 |
virCommandFree(cmd);
|
|
|
9119d9 |
VIR_FORCE_CLOSE(logfile);
|
|
|
9119d9 |
if (priv->mon)
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.2.1
|
|
|
9119d9 |
|