|
|
6ae9ed |
From 0267f63a1fcfe60c69183274650cace0a4aba1f5 Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <0267f63a1fcfe60c69183274650cace0a4aba1f5@dist-git>
|
|
|
6ae9ed |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
6ae9ed |
Date: Wed, 24 Aug 2016 16:11:09 -0400
|
|
|
6ae9ed |
Subject: [PATCH] qemu: domain: Simplify return values of
|
|
|
6ae9ed |
qemuDomainRefreshVcpuInfo
|
|
|
6ae9ed |
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Call the vcpu thread info validation separately to decrease complexity
|
|
|
6ae9ed |
of returned values by qemuDomainRefreshVcpuInfo.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
This function now returns 0 on success and -1 on error. Certain
|
|
|
6ae9ed |
failures of qemu to report data are still considered as success. Any
|
|
|
6ae9ed |
error reported now is fatal.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
(cherry picked from commit 041f35340b949e4b4dbb8fbbbc12d69dfac734a6)
|
|
|
6ae9ed |
---
|
|
|
6ae9ed |
src/qemu/qemu_domain.c | 15 +++++----------
|
|
|
6ae9ed |
src/qemu/qemu_driver.c | 22 +++++++++++-----------
|
|
|
6ae9ed |
src/qemu/qemu_process.c | 6 ++++++
|
|
|
6ae9ed |
3 files changed, 22 insertions(+), 21 deletions(-)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
6ae9ed |
index e087fe6..9cbf938 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_domain.c
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_domain.c
|
|
|
6ae9ed |
@@ -5676,10 +5676,10 @@ qemuDomainValidateVcpuInfo(virDomainObjPtr vm)
|
|
|
6ae9ed |
* @vm: domain object
|
|
|
6ae9ed |
* @asyncJob: current asynchronous job type
|
|
|
6ae9ed |
*
|
|
|
6ae9ed |
- * Updates vCPU information private data of @vm.
|
|
|
6ae9ed |
+ * Updates vCPU information private data of @vm. Due to historical reasons this
|
|
|
6ae9ed |
+ * function returns success even if some data were not reported by qemu.
|
|
|
6ae9ed |
*
|
|
|
6ae9ed |
- * Returns number of detected vCPU threads on success, -1 on error and reports
|
|
|
6ae9ed |
- * an appropriate error, -2 if the domain doesn't exist any more.
|
|
|
6ae9ed |
+ * Returns 0 on success and -1 on fatal error.
|
|
|
6ae9ed |
*/
|
|
|
6ae9ed |
int
|
|
|
6ae9ed |
qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
@@ -5727,10 +5727,8 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
|
|
6ae9ed |
return -1;
|
|
|
6ae9ed |
ncpupids = qemuMonitorGetCPUInfo(qemuDomainGetMonitor(vm), &cpupids);
|
|
|
6ae9ed |
- if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
|
|
6ae9ed |
- ret = -2;
|
|
|
6ae9ed |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
|
|
|
6ae9ed |
/* failure to get the VCPU <-> PID mapping or to execute the query
|
|
|
6ae9ed |
* command will not be treated fatal as some versions of qemu don't
|
|
|
6ae9ed |
@@ -5750,10 +5748,7 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
QEMU_DOMAIN_VCPU_PRIVATE(vcpu)->tid = 0;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
- if (qemuDomainValidateVcpuInfo(vm) < 0)
|
|
|
6ae9ed |
- goto cleanup;
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
- ret = ncpupids;
|
|
|
6ae9ed |
+ ret = 0;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
cleanup:
|
|
|
6ae9ed |
VIR_FREE(cpupids);
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
6ae9ed |
index 040c638..1011bb8 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_driver.c
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_driver.c
|
|
|
6ae9ed |
@@ -4621,6 +4621,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
{
|
|
|
6ae9ed |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
6ae9ed |
virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu);
|
|
|
6ae9ed |
+ qemuDomainVcpuPrivatePtr vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpuinfo);
|
|
|
6ae9ed |
int ret = -1;
|
|
|
6ae9ed |
int rc;
|
|
|
6ae9ed |
int oldvcpus = virDomainDefGetVcpus(vm->def);
|
|
|
6ae9ed |
@@ -4645,15 +4646,14 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
|
|
|
6ae9ed |
vcpuinfo->online = true;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
- if ((rc = qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE)) <= 0) {
|
|
|
6ae9ed |
- /* vcpu pids were not detected, skip setting of affinity */
|
|
|
6ae9ed |
- if (rc == 0)
|
|
|
6ae9ed |
- ret = 0;
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
+ if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
|
|
|
6ae9ed |
- if (qemuProcessSetupVcpu(vm, vcpu) < 0)
|
|
|
6ae9ed |
+ if (qemuDomainValidateVcpuInfo(vm) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (vcpupriv->tid > 0 &&
|
|
|
6ae9ed |
+ qemuProcessSetupVcpu(vm, vcpu) < 0)
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
ret = 0;
|
|
|
6ae9ed |
@@ -4695,11 +4695,11 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
- if ((rc = qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE)) < 0) {
|
|
|
6ae9ed |
- /* rollback only if domain didn't exit */
|
|
|
6ae9ed |
- if (rc == -2)
|
|
|
6ae9ed |
- goto cleanup;
|
|
|
6ae9ed |
+ if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+ if (qemuDomainValidateVcpuInfo(vm) < 0) {
|
|
|
6ae9ed |
+ /* rollback vcpu count if the setting has failed */
|
|
|
6ae9ed |
virDomainAuditVcpu(vm, oldvcpus, oldvcpus - 1, "update", false);
|
|
|
6ae9ed |
vcpuinfo->online = true;
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
6ae9ed |
index 6ff5da5..cdfd1e3 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_process.c
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_process.c
|
|
|
6ae9ed |
@@ -5196,6 +5196,9 @@ qemuProcessLaunch(virConnectPtr conn,
|
|
|
6ae9ed |
if (qemuDomainRefreshVcpuInfo(driver, vm, asyncJob) < 0)
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+ if (qemuDomainValidateVcpuInfo(vm) < 0)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
VIR_DEBUG("Detecting IOThread PIDs");
|
|
|
6ae9ed |
if (qemuProcessDetectIOThreadPIDs(driver, vm, asyncJob) < 0)
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
@@ -5990,6 +5993,9 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
6ae9ed |
if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
|
|
6ae9ed |
goto error;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+ if (qemuDomainValidateVcpuInfo(vm) < 0)
|
|
|
6ae9ed |
+ goto error;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
VIR_DEBUG("Detecting IOThread PIDs");
|
|
|
6ae9ed |
if (qemuProcessDetectIOThreadPIDs(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
|
|
6ae9ed |
goto error;
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.10.0
|
|
|
6ae9ed |
|