qemu: Use virDomainCapsCPUUsable in qemuMonitorCPUDefInfo

While virDomainCapsCPUModel structure contains 'usable' field with
virDomainCapsCPUUsable type, the lower level structure specific to QEMU
driver used virTriStateBool for the same thing and we had to translate
between them.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Jiri Denemark 2019-10-29 14:36:11 +01:00
parent 7f091cb6ed
commit b3ef7efaa5
4 changed files with 8 additions and 13 deletions

View File

@ -2485,14 +2485,9 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon,
goto cleanup;
for (i = 0; i < defs->ncpus; i++) {
virDomainCapsCPUUsable usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
if (defs->cpus[i].usable == VIR_TRISTATE_BOOL_YES)
usable = VIR_DOMCAPS_CPU_USABLE_YES;
else if (defs->cpus[i].usable == VIR_TRISTATE_BOOL_NO)
usable = VIR_DOMCAPS_CPU_USABLE_NO;
if (virDomainCapsCPUModelsAddSteal(models, &defs->cpus[i].name, usable,
if (virDomainCapsCPUModelsAddSteal(models,
&defs->cpus[i].name,
defs->cpus[i].usable,
&defs->cpus[i].blockers) < 0)
goto cleanup;
}

View File

@ -1088,7 +1088,7 @@ typedef struct _qemuMonitorCPUDefInfo qemuMonitorCPUDefInfo;
typedef qemuMonitorCPUDefInfo *qemuMonitorCPUDefInfoPtr;
struct _qemuMonitorCPUDefInfo {
virTristateBool usable;
virDomainCapsCPUUsable usable;
char *name;
char **blockers; /* NULL-terminated string list */
};

View File

@ -5634,11 +5634,11 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
len = virJSONValueArraySize(blockers);
if (len == 0) {
cpu->usable = VIR_TRISTATE_BOOL_YES;
cpu->usable = VIR_DOMCAPS_CPU_USABLE_YES;
continue;
}
cpu->usable = VIR_TRISTATE_BOOL_NO;
cpu->usable = VIR_DOMCAPS_CPU_USABLE_NO;
if (VIR_ALLOC_N(cpu->blockers, len + 1) < 0)
return -1;

View File

@ -478,11 +478,11 @@ testQemuMonitorJSONGetCPUDefinitions(const void *opaque)
} while (0)
#define CHECK(i, wantname) \
CHECK_FULL(i, wantname, VIR_TRISTATE_BOOL_ABSENT)
CHECK_FULL(i, wantname, VIR_DOMCAPS_CPU_USABLE_UNKNOWN)
#define CHECK_USABLE(i, wantname, usable) \
CHECK_FULL(i, wantname, \
usable ? VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO)
usable ? VIR_DOMCAPS_CPU_USABLE_YES : VIR_DOMCAPS_CPU_USABLE_NO)
CHECK(0, "qemu64");
CHECK_USABLE(1, "Opteron_G4", false);