diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 066d3444bb..79da472378 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4026,6 +4026,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. * @@ -4035,15 +4036,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 3c37a6ffe3..c3d3f2fb38 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1021,7 +1021,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 733daf096c..553544aead 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 59d9f098c9..2bc2d6ea8f 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 86bf25b6f0..db98a2f2ca 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3854,7 +3854,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 402c87d455..d0f9381b3e 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);