From 53744fa2afeb19f0ce31cb109e0b3c1f1c8b815b Mon Sep 17 00:00:00 2001 Message-Id: <53744fa2afeb19f0ce31cb109e0b3c1f1c8b815b@dist-git> From: Jiri Denemark Date: Fri, 21 Jun 2019 09:25:58 +0200 Subject: [PATCH] qemu: Make qemuMonitorGetGuestCPU usable on x86 only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was never implemented or used for anything else anyway. Mainly because it uses CPUID features bits. The function is renamed as qemuMonitorGetGuestCPUx86 to make this explicit. Signed-off-by: Jiri Denemark Reviewed-by: Ján Tomko (cherry picked from commit 055f8f6bb953a8a489729d6cd62e55dee058b7e6) https://bugzilla.redhat.com/show_bug.cgi?id=1697627 Signed-off-by: Jiri Denemark Message-Id: <8e07e0a4f5f751bacf5e23fcdc6b93265b819359.1561068591.git.jdenemar@redhat.com> Reviewed-by: Ján Tomko --- src/qemu/qemu_monitor.c | 15 +++++------- src/qemu/qemu_monitor.h | 7 +++--- src/qemu/qemu_monitor_json.c | 47 +++++++++++++++--------------------- src/qemu/qemu_monitor_json.h | 7 +++--- src/qemu/qemu_process.c | 3 +-- tests/qemumonitorjsontest.c | 10 +++----- 6 files changed, 36 insertions(+), 53 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index bc116e4e2d..b35187b66d 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4047,9 +4047,8 @@ qemuMonitorSetDomainLog(qemuMonitorPtr mon, /** - * qemuMonitorJSONGetGuestCPU: + * qemuMonitorJSONGetGuestCPUx86: * @mon: Pointer to the monitor - * @arch: arch of the guest * @data: returns the cpu data * @disabled: returns the CPU data for features which were disabled by QEMU * @@ -4059,13 +4058,11 @@ qemuMonitorSetDomainLog(qemuMonitorPtr mon, * -1 on other errors. */ int -qemuMonitorGetGuestCPU(qemuMonitorPtr mon, - virArch arch, - virCPUDataPtr *data, - virCPUDataPtr *disabled) +qemuMonitorGetGuestCPUx86(qemuMonitorPtr mon, + virCPUDataPtr *data, + virCPUDataPtr *disabled) { - VIR_DEBUG("arch=%s data=%p disabled=%p", - virArchToString(arch), data, disabled); + VIR_DEBUG("data=%p disabled=%p", data, disabled); QEMU_CHECK_MONITOR(mon); @@ -4073,7 +4070,7 @@ qemuMonitorGetGuestCPU(qemuMonitorPtr mon, if (disabled) *disabled = NULL; - return qemuMonitorJSONGetGuestCPU(mon, arch, data, disabled); + return qemuMonitorJSONGetGuestCPUx86(mon, data, disabled); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 81474a04f6..b4d484c703 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1095,10 +1095,9 @@ void qemuMonitorSetDomainLog(qemuMonitorPtr mon, void *opaque, virFreeCallback destroy); -int qemuMonitorGetGuestCPU(qemuMonitorPtr mon, - virArch arch, - virCPUDataPtr *data, - virCPUDataPtr *disabled); +int qemuMonitorGetGuestCPUx86(qemuMonitorPtr mon, + virCPUDataPtr *data, + virCPUDataPtr *disabled); int qemuMonitorRTCResetReinjection(qemuMonitorPtr mon); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e6ac82e96b..8fead72ecf 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7157,9 +7157,8 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon) /** - * qemuMonitorJSONGetGuestCPU: + * qemuMonitorJSONGetGuestCPUx86: * @mon: Pointer to the monitor - * @arch: arch of the guest * @data: returns the cpu data of the guest * @disabled: returns the CPU data for features which were disabled by QEMU * @@ -7169,40 +7168,32 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon) * -1 on other errors. */ int -qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon, - virArch arch, - virCPUDataPtr *data, - virCPUDataPtr *disabled) +qemuMonitorJSONGetGuestCPUx86(qemuMonitorPtr mon, + virCPUDataPtr *data, + virCPUDataPtr *disabled) { virCPUDataPtr cpuEnabled = NULL; virCPUDataPtr cpuDisabled = NULL; int rc; - if (ARCH_IS_X86(arch)) { - if ((rc = qemuMonitorJSONCheckCPUx86(mon)) < 0) - return -1; - else if (!rc) - return -2; + if ((rc = qemuMonitorJSONCheckCPUx86(mon)) < 0) + return -1; + else if (!rc) + return -2; - if (qemuMonitorJSONGetCPUx86Data(mon, "feature-words", - &cpuEnabled) < 0) - goto error; + if (qemuMonitorJSONGetCPUx86Data(mon, "feature-words", + &cpuEnabled) < 0) + goto error; - if (disabled && - qemuMonitorJSONGetCPUx86Data(mon, "filtered-features", - &cpuDisabled) < 0) - goto error; + if (disabled && + qemuMonitorJSONGetCPUx86Data(mon, "filtered-features", + &cpuDisabled) < 0) + goto error; - *data = cpuEnabled; - if (disabled) - *disabled = cpuDisabled; - return 0; - } - - virReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU definition retrieval isn't supported for '%s'"), - virArchToString(arch)); - return -1; + *data = cpuEnabled; + if (disabled) + *disabled = cpuDisabled; + return 0; error: virCPUDataFree(cpuEnabled); diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 66536ceb97..57bed027e2 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -486,10 +486,9 @@ int qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon, const char *property, virCPUDataPtr *cpudata); -int qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon, - virArch arch, - virCPUDataPtr *data, - virCPUDataPtr *disabled); +int qemuMonitorJSONGetGuestCPUx86(qemuMonitorPtr mon, + virCPUDataPtr *data, + virCPUDataPtr *disabled); int qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index bc573f96a4..59a739f262 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4034,8 +4034,7 @@ qemuProcessFetchGuestCPU(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto error; - rc = qemuMonitorGetGuestCPU(priv->mon, vm->def->os.arch, - &dataEnabled, &dataDisabled); + rc = qemuMonitorGetGuestCPUx86(priv->mon, &dataEnabled, &dataDisabled); if (qemuDomainObjExitMonitor(driver, vm) < 0) goto error; diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 2eefd06b6e..ef9a549c04 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2437,9 +2437,8 @@ testQemuMonitorJSONGetCPUData(const void *opaque) if (qemuMonitorTestAddItem(test, "qom-get", jsonStr) < 0) goto cleanup; - if (qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test), - VIR_ARCH_X86_64, - &cpuData, NULL) < 0) + if (qemuMonitorJSONGetGuestCPUx86(qemuMonitorTestGetMonitor(test), + &cpuData, NULL) < 0) goto cleanup; if (!(actual = virCPUDataFormat(cpuData))) @@ -2480,9 +2479,8 @@ testQemuMonitorJSONGetNonExistingCPUData(const void *opaque) "}") < 0) goto cleanup; - rv = qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test), - VIR_ARCH_X86_64, - &cpuData, NULL); + rv = qemuMonitorJSONGetGuestCPUx86(qemuMonitorTestGetMonitor(test), + &cpuData, NULL); if (rv != -2) { virReportError(VIR_ERR_INTERNAL_ERROR, "Unexpected return value %d, expecting -2", rv); -- 2.22.0