qemuMonitorGetGuestCPU can now optionally create CPU data from filtered-features in addition to feature-words. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_monitor.c | 11 ++++++++--- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 25 +++++++++++++++++++++++-- src/qemu/qemu_monitor_json.h | 3 ++- src/qemu/qemu_process.c | 2 +- tests/qemumonitorjsontest.c | 4 ++-- 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index d71f84c80..70e9724c5 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4000,6 +4000,7 @@ qemuMonitorSetDomainLog(qemuMonitorPtr mon, * @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 * * Retrieve the definition of the guest CPU from a running qemu instance. * @@ -4009,15 +4010,19 @@ qemuMonitorSetDomainLog(qemuMonitorPtr mon, int qemuMonitorGetGuestCPU(qemuMonitorPtr mon, virArch arch, - virCPUDataPtr *data) + virCPUDataPtr *data, + virCPUDataPtr *disabled) { - VIR_DEBUG("arch='%s' data='%p'", virArchToString(arch), data); + VIR_DEBUG("arch=%s data=%p disabled=%p", + virArchToString(arch), data, disabled); QEMU_CHECK_MONITOR_JSON(mon); *data = NULL; + if (disabled) + *disabled = NULL; - return qemuMonitorJSONGetGuestCPU(mon, arch, data); + return qemuMonitorJSONGetGuestCPU(mon, arch, data, disabled); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 847e9458a..575d72edd 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1020,7 +1020,8 @@ void qemuMonitorSetDomainLog(qemuMonitorPtr mon, int qemuMonitorGetGuestCPU(qemuMonitorPtr mon, virArch arch, - virCPUDataPtr *data); + 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 733daf096..553544aea 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6728,6 +6728,7 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon) * @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 * * Retrieve the definition of the guest CPU from a running qemu instance. * @@ -6737,8 +6738,11 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon) int qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon, virArch arch, - virCPUDataPtr *data) + virCPUDataPtr *data, + virCPUDataPtr *disabled) { + virCPUDataPtr cpuEnabled = NULL; + virCPUDataPtr cpuDisabled = NULL; int rc; if (ARCH_IS_X86(arch)) { @@ -6747,13 +6751,30 @@ qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon, else if (!rc) return -2; - return qemuMonitorJSONGetCPUx86Data(mon, "feature-words", data); + if (qemuMonitorJSONGetCPUx86Data(mon, "feature-words", + &cpuEnabled) < 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; + + error: + virCPUDataFree(cpuEnabled); + virCPUDataFree(cpuDisabled); + return -1; } int diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 59d9f098c..2bc2d6ea8 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -475,7 +475,8 @@ int qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon, int qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon, virArch arch, - virCPUDataPtr *data); + virCPUDataPtr *data, + virCPUDataPtr *disabled); int qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 894679373..f2aa134d4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3846,7 +3846,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; - rc = qemuMonitorGetGuestCPU(priv->mon, def->os.arch, &cpu); + rc = qemuMonitorGetGuestCPU(priv->mon, def->os.arch, &cpu, NULL); if (qemuDomainObjExitMonitor(driver, vm) < 0) goto cleanup; diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 402c87d45..d0f9381b3 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2395,7 +2395,7 @@ testQemuMonitorJSONGetCPUData(const void *opaque) if (qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test), VIR_ARCH_X86_64, - &cpuData) < 0) + &cpuData, NULL) < 0) goto cleanup; if (!(actual = virCPUDataFormat(cpuData))) @@ -2438,7 +2438,7 @@ testQemuMonitorJSONGetNonExistingCPUData(const void *opaque) rv = qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test), VIR_ARCH_X86_64, - &cpuData); + &cpuData, NULL); if (rv != -2) { virReportError(VIR_ERR_INTERNAL_ERROR, "Unexpected return value %d, expecting -2", rv); -- 2.12.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list