|
|
6ae9ed |
From 1df0ec24ac710cd5ebeb4c3eb1fd589246e17e78 Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <1df0ec24ac710cd5ebeb4c3eb1fd589246e17e78@dist-git>
|
|
|
6ae9ed |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
6ae9ed |
Date: Wed, 24 Aug 2016 16:11:13 -0400
|
|
|
6ae9ed |
Subject: [PATCH] qemu: setvcpus: Extract setting of maximum vcpu count
|
|
|
6ae9ed |
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Setting of the maximum vcpu count is slightly semantically different
|
|
|
6ae9ed |
thus split it into a self-contained func.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
(cherry picked from commit f10da2f55331afee5b302283518b6593e2dc706e)
|
|
|
6ae9ed |
---
|
|
|
6ae9ed |
src/qemu/qemu_driver.c | 67 +++++++++++++++++++++++++++++++++-----------------
|
|
|
6ae9ed |
1 file changed, 44 insertions(+), 23 deletions(-)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
6ae9ed |
index 4e703ae..520a628 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_driver.c
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_driver.c
|
|
|
6ae9ed |
@@ -4762,6 +4762,42 @@ qemuDomainSetVcpusAgent(virDomainObjPtr vm,
|
|
|
6ae9ed |
|
|
|
6ae9ed |
|
|
|
6ae9ed |
static int
|
|
|
6ae9ed |
+qemuDomainSetVcpusMax(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
+ virDomainDefPtr def,
|
|
|
6ae9ed |
+ virDomainDefPtr persistentDef,
|
|
|
6ae9ed |
+ unsigned int nvcpus)
|
|
|
6ae9ed |
+{
|
|
|
6ae9ed |
+ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
6ae9ed |
+ int ret = -1;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (def) {
|
|
|
6ae9ed |
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
|
6ae9ed |
+ _("maximum vcpu count of a live domain can't be modified"));
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (virDomainNumaGetCPUCountTotal(persistentDef->numa) > nvcpus) {
|
|
|
6ae9ed |
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
|
|
|
6ae9ed |
+ _("Number of CPUs in <numa> exceeds the desired "
|
|
|
6ae9ed |
+ "maximum vcpu count"));
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (virDomainDefSetVcpusMax(persistentDef, nvcpus, driver->xmlopt) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ ret = 0;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ cleanup:
|
|
|
6ae9ed |
+ virObjectUnref(cfg);
|
|
|
6ae9ed |
+ return ret;
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+static int
|
|
|
6ae9ed |
qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|
|
6ae9ed |
unsigned int flags)
|
|
|
6ae9ed |
{
|
|
|
6ae9ed |
@@ -4805,14 +4841,12 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|
|
6ae9ed |
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
|
|
6ae9ed |
goto endjob;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
- if (def) {
|
|
|
6ae9ed |
- if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
|
|
|
6ae9ed |
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
|
6ae9ed |
- _("maximum vcpu count of a live domain can't be "
|
|
|
6ae9ed |
- "modified"));
|
|
|
6ae9ed |
- goto endjob;
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
+ if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
|
|
|
6ae9ed |
+ ret = qemuDomainSetVcpusMax(driver, def, persistentDef, nvcpus);
|
|
|
6ae9ed |
+ goto endjob;
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+ if (def) {
|
|
|
6ae9ed |
if (nvcpus > virDomainDefGetVcpusMax(def)) {
|
|
|
6ae9ed |
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
6ae9ed |
_("requested vcpus is greater than max allowable"
|
|
|
6ae9ed |
@@ -4823,8 +4857,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
if (persistentDef) {
|
|
|
6ae9ed |
- if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) &&
|
|
|
6ae9ed |
- nvcpus > virDomainDefGetVcpusMax(persistentDef)) {
|
|
|
6ae9ed |
+ if (nvcpus > virDomainDefGetVcpusMax(persistentDef)) {
|
|
|
6ae9ed |
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
6ae9ed |
_("requested vcpus is greater than max allowable"
|
|
|
6ae9ed |
" vcpus for the persistent domain: %u > %u"),
|
|
|
6ae9ed |
@@ -4868,20 +4901,8 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
if (persistentDef) {
|
|
|
6ae9ed |
- if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
|
|
|
6ae9ed |
- if (virDomainNumaGetCPUCountTotal(persistentDef->numa) > nvcpus) {
|
|
|
6ae9ed |
- virReportError(VIR_ERR_INVALID_ARG, "%s",
|
|
|
6ae9ed |
- _("Number of CPUs in <numa> exceeds the desired "
|
|
|
6ae9ed |
- "maximum vcpu count"));
|
|
|
6ae9ed |
- goto endjob;
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
- if (virDomainDefSetVcpusMax(persistentDef, nvcpus, driver->xmlopt) < 0)
|
|
|
6ae9ed |
- goto endjob;
|
|
|
6ae9ed |
- } else {
|
|
|
6ae9ed |
- if (virDomainDefSetVcpus(persistentDef, nvcpus) < 0)
|
|
|
6ae9ed |
- goto endjob;
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
+ if (virDomainDefSetVcpus(persistentDef, nvcpus) < 0)
|
|
|
6ae9ed |
+ goto endjob;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
if (virDomainSaveConfig(cfg->configDir, driver->caps,
|
|
|
6ae9ed |
persistentDef) < 0)
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.10.0
|
|
|
6ae9ed |
|