The query-cpus-fast command was introduced in 2.12, therefore query-cpus is never used on supported versions of QEMU. Remove the logic to parse its output, as well as the parameters to choose between the two commands. Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 22 ++++-------------- src/qemu/qemu_monitor.c | 29 ++++++++++-------------- src/qemu/qemu_monitor.h | 6 ++--- src/qemu/qemu_monitor_json.c | 44 +++++++----------------------------- src/qemu/qemu_monitor_json.h | 3 +-- tests/qemumonitorjsontest.c | 4 ++-- 6 files changed, 30 insertions(+), 78 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 69e0c9e217..bb25266959 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9618,22 +9618,18 @@ qemuDomainRefreshVcpuInfo(virQEMUDriver *driver, size_t maxvcpus = virDomainDefGetVcpusMax(vm->def); size_t i, j; bool hotplug; - bool fast; bool validTIDs = true; int rc; int ret = -1; hotplug = qemuDomainSupportsNewVcpuHotplug(vm); - fast = virQEMUCapsGet(QEMU_DOMAIN_PRIVATE(vm)->qemuCaps, - QEMU_CAPS_QUERY_CPUS_FAST); - - VIR_DEBUG("Maxvcpus %zu hotplug %d fast query %d", maxvcpus, hotplug, fast); + VIR_DEBUG("Maxvcpus %zu hotplug %d", maxvcpus, hotplug); if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; rc = qemuMonitorGetCPUInfo(qemuDomainGetMonitor(vm), &info, maxvcpus, - hotplug, fast); + hotplug); qemuDomainObjExitMonitor(vm); @@ -9641,7 +9637,7 @@ qemuDomainRefreshVcpuInfo(virQEMUDriver *driver, goto cleanup; /* - * The query-cpus[-fast] commands return information + * The query-cpus-fast commands return information * about the vCPUs, including the OS level PID that * is executing the vCPU. * @@ -9766,7 +9762,6 @@ qemuDomainRefreshVcpuHalted(virQEMUDriver *driver, size_t maxvcpus = virDomainDefGetVcpusMax(vm->def); g_autoptr(virBitmap) haltedmap = NULL; size_t i; - bool fast; /* Not supported currently for TCG, see qemuDomainRefreshVcpuInfo */ if (vm->def->virtType == VIR_DOMAIN_VIRT_QEMU) @@ -9774,21 +9769,14 @@ qemuDomainRefreshVcpuHalted(virQEMUDriver *driver, /* The halted state is interesting only on s390(x). On other platforms * the data would be stale at the time when it would be used. - * Calling qemuMonitorGetCpuHalted() can adversely affect the running - * VM's performance unless QEMU supports query-cpus-fast. */ - if (!ARCH_IS_S390(vm->def->os.arch) || - !virQEMUCapsGet(QEMU_DOMAIN_PRIVATE(vm)->qemuCaps, - QEMU_CAPS_QUERY_CPUS_FAST)) + if (!ARCH_IS_S390(vm->def->os.arch)) return 0; if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; - fast = virQEMUCapsGet(QEMU_DOMAIN_PRIVATE(vm)->qemuCaps, - QEMU_CAPS_QUERY_CPUS_FAST); - haltedmap = qemuMonitorGetCpuHalted(qemuDomainGetMonitor(vm), maxvcpus, - fast); + haltedmap = qemuMonitorGetCpuHalted(qemuDomainGetMonitor(vm), maxvcpus); qemuDomainObjExitMonitor(vm); if (!haltedmap) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 0c0b07d4a5..9d20acdc11 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1565,16 +1565,16 @@ qemuMonitorGetCPUInfoLegacy(struct qemuMonitorQueryCpusEntry *cpuentries, * * This function stitches together data retrieved via query-hotpluggable-cpus * which returns entities on the hotpluggable level (which may describe more - * than one guest logical vcpu) with the output of query-cpus (or - * query-cpus-fast), having an entry per enabled guest logical vcpu. + * than one guest logical vcpu) with the output of query-cpus-fast, + * having an entry per enabled guest logical vcpu. * * query-hotpluggable-cpus conveys following information: * - topology information and number of logical vcpus this entry creates * - device type name of the entry that needs to be used when hotplugging * - qom path in qemu which can be used to map the entry against - * query-cpus[-fast] + * query-cpus-fast * - * query-cpus[-fast] conveys following information: + * query-cpus-fast conveys following information: * - thread id of a given guest logical vcpu * - order in which the vcpus were inserted * - qom path to allow mapping the two together @@ -1609,7 +1609,7 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl for (i = 0; i < nhotplugvcpus; i++) totalvcpus += hotplugvcpus[i].vcpus; - /* trim '/thread...' suffix from the data returned by query-cpus[-fast] */ + /* trim '/thread...' suffix from the data returned by query-cpus-fast */ for (i = 0; i < ncpuentries; i++) { if (cpuentries[i].qom_path && (tmp = strstr(cpuentries[i].qom_path, "/thread"))) @@ -1622,7 +1622,7 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl } /* Note the order in which the hotpluggable entities are inserted by - * matching them to the query-cpus[-fast] entries */ + * matching them to the query-cpus-fast entries */ for (i = 0; i < ncpuentries; i++) { for (j = 0; j < nhotplugvcpus; j++) { if (!cpuentries[i].qom_path || @@ -1679,7 +1679,7 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl } if (anyvcpu == maxvcpus) { - VIR_DEBUG("too many query-cpus[-fast] entries for a given " + VIR_DEBUG("too many query-cpus-fast entries for a given " "query-hotpluggable-cpus entry"); return -1; } @@ -1707,7 +1707,6 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl * @vcpus: pointer filled by array of qemuMonitorCPUInfo structures * @maxvcpus: total possible number of vcpus * @hotplug: query data relevant for hotplug support - * @fast: use QMP query-cpus-fast if supported * * Detects VCPU information. If qemu doesn't support or fails reporting * information this function will return success as other parts of libvirt @@ -1720,8 +1719,7 @@ int qemuMonitorGetCPUInfo(qemuMonitor *mon, qemuMonitorCPUInfo **vcpus, size_t maxvcpus, - bool hotplug, - bool fast) + bool hotplug) { struct qemuMonitorQueryHotpluggableCpusEntry *hotplugcpus = NULL; size_t nhotplugcpus = 0; @@ -1742,8 +1740,7 @@ qemuMonitorGetCPUInfo(qemuMonitor *mon, (qemuMonitorJSONGetHotpluggableCPUs(mon, &hotplugcpus, &nhotplugcpus)) < 0) goto cleanup; - rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries, hotplug, - fast); + rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries, hotplug); if (rc < 0) { if (!hotplug && rc == -2) { @@ -1779,12 +1776,11 @@ qemuMonitorGetCPUInfo(qemuMonitor *mon, * qemuMonitorGetCpuHalted: * * Returns a bitmap of vcpu id's that are halted. The id's correspond to the - * 'CPU' field as reported by query-cpus[-fast]'. + * 'CPU' field as reported by query-cpus-fast'. */ virBitmap * qemuMonitorGetCpuHalted(qemuMonitor *mon, - size_t maxvcpus, - bool fast) + size_t maxvcpus) { struct qemuMonitorQueryCpusEntry *cpuentries = NULL; size_t ncpuentries = 0; @@ -1794,8 +1790,7 @@ qemuMonitorGetCpuHalted(qemuMonitor *mon, QEMU_CHECK_MONITOR_NULL(mon); - rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries, false, - fast); + rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries, false); if (rc < 0) goto cleanup; diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 742bfd4cdc..49adad85dd 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -644,11 +644,9 @@ void qemuMonitorCPUInfoFree(qemuMonitorCPUInfo *list, int qemuMonitorGetCPUInfo(qemuMonitor *mon, qemuMonitorCPUInfo **vcpus, size_t maxvcpus, - bool hotplug, - bool fast); + bool hotplug); virBitmap *qemuMonitorGetCpuHalted(qemuMonitor *mon, - size_t maxvcpus, - bool fast); + size_t maxvcpus); int qemuMonitorGetBalloonInfo(qemuMonitor *mon, unsigned long long *currmem); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 2469165728..dd352d6296 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1678,21 +1678,8 @@ qemuMonitorJSONExtractCPUS390Info(virJSONValue *jsoncpu, * @data: JSON response data * @entries: filled with detected cpu entries on success * @nentries: number of entries returned - * @fast: true if this is a response from query-cpus-fast * * The JSON response @data will have the following format - * in case @fast == false - * [{ "arch": "x86", - * "current": true, - * "CPU": 0, - * "qom_path": "/machine/unattached/device[0]", - * "pc": -2130415978, - * "halted": true, - * "thread_id": 2631237, - * ...}, - * {...} - * ] - * and for @fast == true * [{ "arch": "x86", * "cpu-index": 0, * "props": { @@ -1724,8 +1711,7 @@ qemuMonitorJSONExtractCPUS390Info(virJSONValue *jsoncpu, static int qemuMonitorJSONExtractCPUInfo(virJSONValue *data, struct qemuMonitorQueryCpusEntry **entries, - size_t *nentries, - bool fast) + size_t *nentries) { const char *arch = NULL; struct qemuMonitorQueryCpusEntry *cpus = NULL; @@ -1753,19 +1739,11 @@ qemuMonitorJSONExtractCPUInfo(virJSONValue *data, * non-fatal, simply returning no data. * The return data of query-cpus-fast has different field names */ - if (fast) { - if (!(arch = virJSONValueObjectGetString(entry, "target"))) - arch = virJSONValueObjectGetString(entry, "arch"); - ignore_value(virJSONValueObjectGetNumberInt(entry, "cpu-index", &cpuid)); - ignore_value(virJSONValueObjectGetNumberInt(entry, "thread-id", &thread)); - qom_path = virJSONValueObjectGetString(entry, "qom-path"); - } else { + if (!(arch = virJSONValueObjectGetString(entry, "target"))) arch = virJSONValueObjectGetString(entry, "arch"); - ignore_value(virJSONValueObjectGetNumberInt(entry, "CPU", &cpuid)); - ignore_value(virJSONValueObjectGetNumberInt(entry, "thread_id", &thread)); - ignore_value(virJSONValueObjectGetBoolean(entry, "halted", &halted)); - qom_path = virJSONValueObjectGetString(entry, "qom_path"); - } + ignore_value(virJSONValueObjectGetNumberInt(entry, "cpu-index", &cpuid)); + ignore_value(virJSONValueObjectGetNumberInt(entry, "thread-id", &thread)); + qom_path = virJSONValueObjectGetString(entry, "qom-path"); cpus[i].qemu_id = cpuid; cpus[i].tid = thread; @@ -1794,7 +1772,6 @@ qemuMonitorJSONExtractCPUInfo(virJSONValue *data, * @entries: filled with detected entries on success * @nentries: number of entries returned * @force: force exit on error - * @fast: use query-cpus-fast * * Queries qemu for cpu-related information. Failure to execute the command or * extract results does not produce an error as libvirt can continue without @@ -1807,18 +1784,13 @@ int qemuMonitorJSONQueryCPUs(qemuMonitor *mon, struct qemuMonitorQueryCpusEntry **entries, size_t *nentries, - bool force, - bool fast) + bool force) { g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) reply = NULL; virJSONValue *data; - if (fast) - cmd = qemuMonitorJSONMakeCommand("query-cpus-fast", NULL); - else - cmd = qemuMonitorJSONMakeCommand("query-cpus", NULL); - + cmd = qemuMonitorJSONMakeCommand("query-cpus-fast", NULL); if (!cmd) return -1; @@ -1831,7 +1803,7 @@ qemuMonitorJSONQueryCPUs(qemuMonitor *mon, if (!(data = virJSONValueObjectGetArray(reply, "return"))) return -2; - return qemuMonitorJSONExtractCPUInfo(data, entries, nentries, fast); + return qemuMonitorJSONExtractCPUInfo(data, entries, nentries); } diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index e4c65e250e..924238eeec 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -66,8 +66,7 @@ int qemuMonitorJSONQueryCPUs(qemuMonitor *mon, struct qemuMonitorQueryCpusEntry **entries, size_t *nentries, - bool force, - bool fast); + bool force); int qemuMonitorJSONUpdateVideoMemorySize(qemuMonitor *mon, virDomainVideoDef *video, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 9d8a315103..e0dd00dc7a 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1299,7 +1299,7 @@ testQEMUMonitorJSONqemuMonitorJSONQueryCPUsHelper(qemuMonitorTest *test, int ret = -1; if (qemuMonitorJSONQueryCPUs(qemuMonitorTestGetMonitor(test), - &cpudata, &ncpudata, true, true) < 0) + &cpudata, &ncpudata, true) < 0) goto cleanup; if (ncpudata != num) { @@ -2380,7 +2380,7 @@ testQemuMonitorCPUInfo(const void *opaque) goto cleanup; rc = qemuMonitorGetCPUInfo(qemuMonitorTestGetMonitor(test), - &vcpus, data->maxvcpus, true, true); + &vcpus, data->maxvcpus, true); if (rc < 0) goto cleanup; -- 2.37.1