qemu: domain: Store vcpu halted state as a tristate

Since it may be possible that the state is unknown in some cases we
should store it as a tristate so that other code using it can determine
whether the state was updated.
This commit is contained in:
Peter Krempa 2018-02-06 16:00:45 +01:00
parent 2222548b1e
commit ca588a34b2
3 changed files with 7 additions and 11 deletions

View File

@ -8737,7 +8737,8 @@ qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver,
for (i = 0; i < maxvcpus; i++) {
vcpu = virDomainDefGetVcpu(vm->def, i);
vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
vcpupriv->halted = virBitmapIsBitSet(haltedmap, vcpupriv->qemu_id);
vcpupriv->halted = virTristateBoolFromBool(virBitmapIsBitSet(haltedmap,
vcpupriv->qemu_id));
}
ret = 0;

View File

@ -399,7 +399,7 @@ struct _qemuDomainVcpuPrivate {
int enable_id; /* order in which the vcpus were enabled in qemu */
int qemu_id; /* ID reported by qemu as 'CPU' in query-cpus */
char *alias;
bool halted;
virTristateBool halted;
/* information for hotpluggable cpus */
char *type;

View File

@ -19659,7 +19659,6 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
virVcpuInfoPtr cpuinfo = NULL;
unsigned long long *cpuwait = NULL;
bool vcpuhalted = false;
if (virTypedParamsAddUInt(&record->params,
&record->nparams,
@ -19679,15 +19678,11 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
VIR_ALLOC_N(cpuwait, virDomainDefGetVcpus(dom->def)) < 0)
goto cleanup;
if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) {
if (qemuDomainRefreshVcpuHalted(driver, dom,
QEMU_ASYNC_JOB_NONE) < 0) {
if (HAVE_JOB(privflags) && virDomainObjIsActive(dom) &&
qemuDomainRefreshVcpuHalted(driver, dom, QEMU_ASYNC_JOB_NONE) < 0) {
/* it's ok to be silent and go ahead, because halted vcpu info
* wasn't here from the beginning */
virResetLastError();
} else {
vcpuhalted = true;
}
}
if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait,
@ -19735,14 +19730,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
if (vcpuhalted) {
if (vcpupriv->halted != VIR_TRISTATE_BOOL_ABSENT) {
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
"vcpu.%u.halted", cpuinfo[i].number);
if (virTypedParamsAddBoolean(&record->params,
&record->nparams,
maxparams,
param_name,
vcpupriv->halted) < 0)
vcpupriv->halted == VIR_TRISTATE_BOOL_YES) < 0)
goto cleanup;
}
}