|
|
c401cc |
From fc74342fd4e1f5c4de1d39d31f902c3f6d717e20 Mon Sep 17 00:00:00 2001
|
|
|
c401cc |
Message-Id: <fc74342fd4e1f5c4de1d39d31f902c3f6d717e20.1389183249.git.jdenemar@redhat.com>
|
|
|
c401cc |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
c401cc |
Date: Mon, 6 Jan 2014 17:02:27 +0100
|
|
|
c401cc |
Subject: [PATCH] qemu: Clean up qemuDomainSetNumaParameters
|
|
|
c401cc |
|
|
|
c401cc |
https://bugzilla.redhat.com/show_bug.cgi?id=1047234
|
|
|
c401cc |
|
|
|
c401cc |
Add whitespace to separate logical code blocks, reformat error messages
|
|
|
c401cc |
and clean up code flow.
|
|
|
c401cc |
|
|
|
c401cc |
This patch changes error handling in some cases where the the loop would
|
|
|
c401cc |
be continued to jump to cleanup instead and error out rather than modify
|
|
|
c401cc |
the domain any further.
|
|
|
c401cc |
|
|
|
c401cc |
(cherry picked from commit 8b573a6b0d1ee9d99862104f28fee8bc7f949a9d)
|
|
|
c401cc |
|
|
|
c401cc |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c401cc |
---
|
|
|
c401cc |
src/qemu/qemu_driver.c | 30 +++++++++++++++---------------
|
|
|
c401cc |
1 file changed, 15 insertions(+), 15 deletions(-)
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
c401cc |
index a3d4725..215ac1b 100644
|
|
|
c401cc |
--- a/src/qemu/qemu_driver.c
|
|
|
c401cc |
+++ b/src/qemu/qemu_driver.c
|
|
|
c401cc |
@@ -8507,6 +8507,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
|
|
|
c401cc |
|
|
|
c401cc |
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
|
|
c401cc |
VIR_DOMAIN_AFFECT_CONFIG, -1);
|
|
|
c401cc |
+
|
|
|
c401cc |
if (virTypedParamsValidate(params, nparams,
|
|
|
c401cc |
VIR_DOMAIN_NUMA_MODE,
|
|
|
c401cc |
VIR_TYPED_PARAM_INT,
|
|
|
c401cc |
@@ -8533,43 +8534,40 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
|
|
|
c401cc |
|
|
|
c401cc |
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
|
|
c401cc |
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
|
|
c401cc |
- virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
c401cc |
- "%s", _("cgroup cpuset controller is not mounted"));
|
|
|
c401cc |
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
c401cc |
+ _("cgroup cpuset controller is not mounted"));
|
|
|
c401cc |
goto cleanup;
|
|
|
c401cc |
}
|
|
|
c401cc |
}
|
|
|
c401cc |
|
|
|
c401cc |
- ret = 0;
|
|
|
c401cc |
for (i = 0; i < nparams; i++) {
|
|
|
c401cc |
virTypedParameterPtr param = ¶ms[i];
|
|
|
c401cc |
|
|
|
c401cc |
if (STREQ(param->field, VIR_DOMAIN_NUMA_MODE)) {
|
|
|
c401cc |
+ int mode = param->value.i;
|
|
|
c401cc |
+
|
|
|
c401cc |
if ((flags & VIR_DOMAIN_AFFECT_LIVE) &&
|
|
|
c401cc |
- vm->def->numatune.memory.mode != params[i].value.i) {
|
|
|
c401cc |
+ vm->def->numatune.memory.mode != mode) {
|
|
|
c401cc |
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
c401cc |
_("can't change numa mode for running domain"));
|
|
|
c401cc |
- ret = -1;
|
|
|
c401cc |
goto cleanup;
|
|
|
c401cc |
}
|
|
|
c401cc |
|
|
|
c401cc |
- if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
|
|
c401cc |
- persistentDef->numatune.memory.mode = params[i].value.i;
|
|
|
c401cc |
- }
|
|
|
c401cc |
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
|
|
c401cc |
+ persistentDef->numatune.memory.mode = mode;
|
|
|
c401cc |
+
|
|
|
c401cc |
} else if (STREQ(param->field, VIR_DOMAIN_NUMA_NODESET)) {
|
|
|
c401cc |
virBitmapPtr nodeset = NULL;
|
|
|
c401cc |
|
|
|
c401cc |
- if (virBitmapParse(params[i].value.s,
|
|
|
c401cc |
- 0, &nodeset,
|
|
|
c401cc |
+ if (virBitmapParse(param->value.s, 0, &nodeset,
|
|
|
c401cc |
VIR_DOMAIN_CPUMASK_LEN) < 0) {
|
|
|
c401cc |
- ret = -1;
|
|
|
c401cc |
- continue;
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
}
|
|
|
c401cc |
|
|
|
c401cc |
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
|
|
c401cc |
if (qemuDomainSetNumaParamsLive(vm, caps, nodeset) < 0) {
|
|
|
c401cc |
virBitmapFree(nodeset);
|
|
|
c401cc |
- ret = -1;
|
|
|
c401cc |
- continue;
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
}
|
|
|
c401cc |
|
|
|
c401cc |
/* update vm->def here so that dumpxml can read the new
|
|
|
c401cc |
@@ -8598,9 +8596,11 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
|
|
|
c401cc |
persistentDef->numatune.memory.placement_mode =
|
|
|
c401cc |
VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO;
|
|
|
c401cc |
if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
|
|
|
c401cc |
- ret = -1;
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
}
|
|
|
c401cc |
|
|
|
c401cc |
+ ret = 0;
|
|
|
c401cc |
+
|
|
|
c401cc |
cleanup:
|
|
|
c401cc |
if (vm)
|
|
|
c401cc |
virObjectUnlock(vm);
|
|
|
c401cc |
--
|
|
|
c401cc |
1.8.5.2
|
|
|
c401cc |
|