From b3ef7efaa57ab9122e8ea0b5bf16d19b5c2b2558 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Tue, 29 Oct 2019 14:36:11 +0100 Subject: [PATCH] qemu: Use virDomainCapsCPUUsable in qemuMonitorCPUDefInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- src/qemu/qemu_capabilities.c | 11 +++-------- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 4 ++-- tests/qemumonitorjsontest.c | 4 ++-- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index cb1faec802..4c9f982e0c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -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; } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index cd8e850ed2..cd6b529b58 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -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 */ }; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3f523257d0..7d0de45704 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -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; diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 4646d3a55e..21f17f42af 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -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);