|
|
404507 |
From d75ea91fe4c95b17f928931637f65fcf317e986c Mon Sep 17 00:00:00 2001
|
|
|
404507 |
Message-Id: <d75ea91fe4c95b17f928931637f65fcf317e986c@dist-git>
|
|
|
404507 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
404507 |
Date: Wed, 7 Feb 2018 14:16:01 +0100
|
|
|
404507 |
Subject: [PATCH] qemu: domain: Store vcpu halted state as a tristate
|
|
|
404507 |
|
|
|
404507 |
Since it may be possible that the state is unknown in some cases we
|
|
|
404507 |
should store it as a tristate so that other code using it can determine
|
|
|
404507 |
whether the state was updated.
|
|
|
404507 |
|
|
|
404507 |
(cherry picked from commit ca588a34b23a1f30dc7eeb7d5134706e31b403ef)
|
|
|
404507 |
|
|
|
404507 |
https://bugzilla.redhat.com/show_bug.cgi?id=1534585
|
|
|
404507 |
---
|
|
|
404507 |
src/qemu/qemu_domain.c | 3 ++-
|
|
|
404507 |
src/qemu/qemu_domain.h | 2 +-
|
|
|
404507 |
src/qemu/qemu_driver.c | 13 ++++---------
|
|
|
404507 |
3 files changed, 7 insertions(+), 11 deletions(-)
|
|
|
404507 |
|
|
|
404507 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
404507 |
index b0c78cc7c4..e87c7d030c 100644
|
|
|
404507 |
--- a/src/qemu/qemu_domain.c
|
|
|
404507 |
+++ b/src/qemu/qemu_domain.c
|
|
|
404507 |
@@ -8000,7 +8000,8 @@ qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver,
|
|
|
404507 |
for (i = 0; i < maxvcpus; i++) {
|
|
|
404507 |
vcpu = virDomainDefGetVcpu(vm->def, i);
|
|
|
404507 |
vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
|
|
|
404507 |
- vcpupriv->halted = virBitmapIsBitSet(haltedmap, vcpupriv->qemu_id);
|
|
|
404507 |
+ vcpupriv->halted = virTristateBoolFromBool(virBitmapIsBitSet(haltedmap,
|
|
|
404507 |
+ vcpupriv->qemu_id));
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
ret = 0;
|
|
|
404507 |
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
|
|
404507 |
index 1a82922415..19e58ef3be 100644
|
|
|
404507 |
--- a/src/qemu/qemu_domain.h
|
|
|
404507 |
+++ b/src/qemu/qemu_domain.h
|
|
|
404507 |
@@ -389,7 +389,7 @@ struct _qemuDomainVcpuPrivate {
|
|
|
404507 |
int enable_id; /* order in which the vcpus were enabled in qemu */
|
|
|
404507 |
int qemu_id; /* ID reported by qemu as 'CPU' in query-cpus */
|
|
|
404507 |
char *alias;
|
|
|
404507 |
- bool halted;
|
|
|
404507 |
+ virTristateBool halted;
|
|
|
404507 |
|
|
|
404507 |
/* information for hotpluggable cpus */
|
|
|
404507 |
char *type;
|
|
|
404507 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
404507 |
index b5bef7442e..b8022a06ba 100644
|
|
|
404507 |
--- a/src/qemu/qemu_driver.c
|
|
|
404507 |
+++ b/src/qemu/qemu_driver.c
|
|
|
404507 |
@@ -19526,7 +19526,6 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
|
|
|
404507 |
char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
|
|
|
404507 |
virVcpuInfoPtr cpuinfo = NULL;
|
|
|
404507 |
unsigned long long *cpuwait = NULL;
|
|
|
404507 |
- bool vcpuhalted = false;
|
|
|
404507 |
|
|
|
404507 |
if (virTypedParamsAddUInt(&record->params,
|
|
|
404507 |
&record->nparams,
|
|
|
404507 |
@@ -19546,15 +19545,11 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
|
|
|
404507 |
VIR_ALLOC_N(cpuwait, virDomainDefGetVcpus(dom->def)) < 0)
|
|
|
404507 |
goto cleanup;
|
|
|
404507 |
|
|
|
404507 |
- if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) {
|
|
|
404507 |
- if (qemuDomainRefreshVcpuHalted(driver, dom,
|
|
|
404507 |
- QEMU_ASYNC_JOB_NONE) < 0) {
|
|
|
404507 |
+ if (HAVE_JOB(privflags) && virDomainObjIsActive(dom) &&
|
|
|
404507 |
+ qemuDomainRefreshVcpuHalted(driver, dom, QEMU_ASYNC_JOB_NONE) < 0) {
|
|
|
404507 |
/* it's ok to be silent and go ahead, because halted vcpu info
|
|
|
404507 |
* wasn't here from the beginning */
|
|
|
404507 |
virResetLastError();
|
|
|
404507 |
- } else {
|
|
|
404507 |
- vcpuhalted = true;
|
|
|
404507 |
- }
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait,
|
|
|
404507 |
@@ -19602,14 +19597,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
|
|
|
404507 |
|
|
|
404507 |
vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
|
|
|
404507 |
|
|
|
404507 |
- if (vcpuhalted) {
|
|
|
404507 |
+ if (vcpupriv->halted != VIR_TRISTATE_BOOL_ABSENT) {
|
|
|
404507 |
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
|
|
404507 |
"vcpu.%u.halted", cpuinfo[i].number);
|
|
|
404507 |
if (virTypedParamsAddBoolean(&record->params,
|
|
|
404507 |
&record->nparams,
|
|
|
404507 |
maxparams,
|
|
|
404507 |
param_name,
|
|
|
404507 |
- vcpupriv->halted) < 0)
|
|
|
404507 |
+ vcpupriv->halted == VIR_TRISTATE_BOOL_YES) < 0)
|
|
|
404507 |
goto cleanup;
|
|
|
404507 |
}
|
|
|
404507 |
}
|
|
|
404507 |
--
|
|
|
404507 |
2.16.1
|
|
|
404507 |
|