[PATCH 0/3] cleanups inspired by QMP-deprecation-introspection

I take a look at Markus' QMP deprecation-introspection series. While that requires a lot more work I've fixed a few things along. Peter Krempa (3): util: json: Convert virJSONValueNewObject() to g_new0 qemuMonitorJSONSetMigrationParams: Refactor command construction and cleanup qemuhotplugtestcpus: Always use 'query-cpus-fast' src/admin/admin_server_dispatch.c | 3 - src/locking/lock_daemon.c | 8 +- src/logging/log_daemon.c | 8 +- src/logging/log_handler.c | 5 - src/qemu/qemu_agent.c | 8 +- src/qemu/qemu_command.c | 3 +- src/qemu/qemu_firmware.c | 20 +- src/qemu/qemu_migration_params.c | 8 +- src/qemu/qemu_monitor_json.c | 53 +-- src/qemu/qemu_vhost_user.c | 3 +- src/rpc/virnetdaemon.c | 10 +- src/rpc/virnetserver.c | 5 +- src/rpc/virnetserverclient.c | 3 - src/rpc/virnetserverservice.c | 3 - src/rpc/virnetsocket.c | 3 +- src/util/virjson.c | 21 +- src/util/virlease.c | 6 +- src/util/virlockspace.c | 6 - src/util/virmacmap.c | 5 +- src/util/virnetdev.c | 3 +- tests/qemuhotplugtest.c | 2 + .../ppc64-modern-bulk-monitor.json | 390 +++++++++--------- .../ppc64-modern-individual-monitor.json | 196 ++++----- .../x86-modern-bulk-monitor.json | 150 +++---- .../x86-modern-individual-add-monitor.json | 92 ++--- .../x86-old-bulk-monitor.json | 150 +++---- tests/qemumonitortestutils.c | 8 +- 27 files changed, 529 insertions(+), 643 deletions(-) -- 2.24.1

Make it obvious that the function always returns a valid pointer and fix all callers. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/admin/admin_server_dispatch.c | 3 --- src/locking/lock_daemon.c | 8 +------- src/logging/log_daemon.c | 8 +------- src/logging/log_handler.c | 5 ----- src/qemu/qemu_agent.c | 8 ++------ src/qemu/qemu_command.c | 3 +-- src/qemu/qemu_firmware.c | 20 ++++---------------- src/qemu/qemu_migration_params.c | 8 ++------ src/qemu/qemu_monitor_json.c | 30 +++++++----------------------- src/qemu/qemu_vhost_user.c | 3 +-- src/rpc/virnetdaemon.c | 10 ++-------- src/rpc/virnetserver.c | 5 +---- src/rpc/virnetserverclient.c | 3 --- src/rpc/virnetserverservice.c | 3 --- src/rpc/virnetsocket.c | 3 +-- src/util/virjson.c | 21 ++++----------------- src/util/virlease.c | 6 +----- src/util/virlockspace.c | 6 ------ src/util/virmacmap.c | 5 +---- src/util/virnetdev.c | 3 +-- tests/qemumonitortestutils.c | 8 ++------ 21 files changed, 32 insertions(+), 137 deletions(-) diff --git a/src/admin/admin_server_dispatch.c b/src/admin/admin_server_dispatch.c index 7b3bd697f3..b3da577995 100644 --- a/src/admin/admin_server_dispatch.c +++ b/src/admin/admin_server_dispatch.c @@ -119,9 +119,6 @@ virJSONValuePtr remoteAdmClientPreExecRestart(virNetServerClientPtr client G_GNU { virJSONValuePtr object = virJSONValueNewObject(); - if (!object) - return NULL; - /* No content to add at this time - just need empty object */ return object; diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 5e5a0c1089..245155206a 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -774,9 +774,6 @@ virLockDaemonClientPreExecRestart(virNetServerClientPtr client G_GNUC_UNUSED, virJSONValuePtr object = virJSONValueNewObject(); char uuidstr[VIR_UUID_STRING_BUFLEN]; - if (!object) - return NULL; - if (virJSONValueObjectAppendBoolean(object, "restricted", priv->restricted) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot set restricted data in JSON document")); @@ -923,16 +920,13 @@ virLockDaemonPreExecRestart(const char *state_file, virJSONValuePtr child; char *state = NULL; int ret = -1; - virJSONValuePtr object; + virJSONValuePtr object = virJSONValueNewObject(); char *magic; virHashKeyValuePairPtr pairs = NULL, tmp; virJSONValuePtr lockspaces; VIR_DEBUG("Running pre-restart exec"); - if (!(object = virJSONValueNewObject())) - goto cleanup; - if (!(child = virNetDaemonPreExecRestart(dmn))) goto cleanup; diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 772bbb805b..47377deb4f 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -597,9 +597,6 @@ virLogDaemonClientPreExecRestart(virNetServerClientPtr client G_GNUC_UNUSED, { virJSONValuePtr object = virJSONValueNewObject(); - if (!object) - return NULL; - return object; } @@ -718,15 +715,12 @@ virLogDaemonPreExecRestart(const char *state_file, virJSONValuePtr child; char *state = NULL; int ret = -1; - virJSONValuePtr object; + virJSONValuePtr object = virJSONValueNewObject(); char *magic; virHashKeyValuePairPtr pairs = NULL; VIR_DEBUG("Running pre-restart exec"); - if (!(object = virJSONValueNewObject())) - goto cleanup; - if (!(child = virNetDaemonPreExecRestart(dmn))) goto cleanup; diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c index 576d0d6921..87748d96d1 100644 --- a/src/logging/log_handler.c +++ b/src/logging/log_handler.c @@ -615,9 +615,6 @@ virLogHandlerPreExecRestart(virLogHandlerPtr handler) size_t i; char domuuid[VIR_UUID_STRING_BUFLEN]; - if (!ret) - return NULL; - files = virJSONValueNewArray(); if (virJSONValueObjectAppend(ret, "files", files) < 0) { @@ -627,8 +624,6 @@ virLogHandlerPreExecRestart(virLogHandlerPtr handler) for (i = 0; i < handler->nfiles; i++) { virJSONValuePtr file = virJSONValueNewObject(); - if (!file) - goto error; if (virJSONValueArrayAppend(files, file) < 0) { virJSONValueFree(file); diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 23a775034f..cd25ef6cd3 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1166,15 +1166,12 @@ static virJSONValuePtr G_GNUC_NULL_TERMINATED qemuAgentMakeCommand(const char *cmdname, ...) { - virJSONValuePtr obj; + virJSONValuePtr obj = virJSONValueNewObject(); virJSONValuePtr jargs = NULL; va_list args; va_start(args, cmdname); - if (!(obj = virJSONValueNewObject())) - goto error; - if (virJSONValueObjectAppendString(obj, "execute", cmdname) < 0) goto error; @@ -1544,8 +1541,7 @@ qemuAgentSetVCPUsCommand(qemuAgentPtr mon, (*nmodified)++; /* create single cpu object */ - if (!(cpu = virJSONValueNewObject())) - goto cleanup; + cpu = virJSONValueNewObject(); if (virJSONValueObjectAppendNumberInt(cpu, "logical-id", in->id) < 0) goto cleanup; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9d215e5e06..9e0334a3e7 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3442,8 +3442,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps, return -1; } - if (!(props = virJSONValueNewObject())) - return -1; + props = virJSONValueNewObject(); if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_MEMFD) { backendType = "memory-backend-memfd"; diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 68e2c6b40f..bd251c05fc 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -672,12 +672,9 @@ qemuFirmwareInterfaceFormat(virJSONValuePtr doc, static virJSONValuePtr qemuFirmwareFlashFileFormat(qemuFirmwareFlashFile flash) { - g_autoptr(virJSONValue) json = NULL; + g_autoptr(virJSONValue) json = virJSONValueNewObject(); virJSONValuePtr ret; - if (!(json = virJSONValueNewObject())) - return NULL; - if (virJSONValueObjectAppendString(json, "filename", flash.filename) < 0) @@ -754,10 +751,7 @@ static int qemuFirmwareMappingFormat(virJSONValuePtr doc, qemuFirmwarePtr fw) { - g_autoptr(virJSONValue) mapping = NULL; - - if (!(mapping = virJSONValueNewObject())) - return -1; + g_autoptr(virJSONValue) mapping = virJSONValueNewObject(); if (virJSONValueObjectAppendString(mapping, "device", @@ -802,13 +796,10 @@ qemuFirmwareTargetFormat(virJSONValuePtr doc, for (i = 0; i < fw->ntargets; i++) { qemuFirmwareTargetPtr t = fw->targets[i]; - g_autoptr(virJSONValue) target = NULL; + g_autoptr(virJSONValue) target = virJSONValueNewObject(); g_autoptr(virJSONValue) machines = NULL; size_t j; - if (!(target = virJSONValueNewObject())) - return -1; - if (virJSONValueObjectAppendString(target, "architecture", virQEMUCapsArchToString(t->architecture)) < 0) @@ -869,14 +860,11 @@ qemuFirmwareFeatureFormat(virJSONValuePtr doc, char * qemuFirmwareFormat(qemuFirmwarePtr fw) { - g_autoptr(virJSONValue) doc = NULL; + g_autoptr(virJSONValue) doc = virJSONValueNewObject(); if (!fw) return NULL; - if (!(doc = virJSONValueNewObject())) - return NULL; - if (qemuFirmwareInterfaceFormat(doc, fw) < 0) return NULL; diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index dd1ad9349b..a92bb2fa2b 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -729,15 +729,12 @@ qemuMigrationParamsFromJSON(virJSONValuePtr params) virJSONValuePtr qemuMigrationParamsToJSON(qemuMigrationParamsPtr migParams) { - virJSONValuePtr params = NULL; + virJSONValuePtr params = virJSONValueNewObject(); qemuMigrationParamValuePtr pv; const char *name; size_t i; int rc; - if (!(params = virJSONValueNewObject())) - return NULL; - for (i = 0; i < QEMU_MIGRATION_PARAM_LAST; i++) { name = qemuMigrationParamTypeToString(i); pv = &migParams->params[i]; @@ -797,8 +794,7 @@ qemuMigrationCapsToJSON(virBitmapPtr caps, ignore_value(virBitmapGetBit(states, bit, &state)); - if (!(cap = virJSONValueNewObject())) - goto error; + cap = virJSONValueNewObject(); name = qemuMigrationCapabilityTypeToString(bit); if (virJSONValueObjectAppendString(cap, "capability", name) < 0) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 451e1afef5..5f0185d10b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -690,15 +690,12 @@ qemuMonitorJSONParseKeywords(const char *str, static virJSONValuePtr qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword) { - virJSONValuePtr ret = NULL; + virJSONValuePtr ret = virJSONValueNewObject(); char **keywords = NULL; char **values = NULL; int nkeywords = 0; size_t i; - if (!(ret = virJSONValueNewObject())) - return NULL; - if (qemuMonitorJSONParseKeywords(str, &keywords, &values, &nkeywords, 1) < 0) goto error; @@ -3444,12 +3441,9 @@ qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon, virJSONValuePtr params) { int ret = -1; - virJSONValuePtr cmd = NULL; + virJSONValuePtr cmd = virJSONValueNewObject(); virJSONValuePtr reply = NULL; - if (!(cmd = virJSONValueNewObject())) - goto cleanup; - if (virJSONValueObjectAppendString(cmd, "execute", "migrate-set-parameters") < 0) goto cleanup; @@ -4823,8 +4817,7 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon, } /* create single key object */ - if (!(key = virJSONValueNewObject())) - goto cleanup; + key = virJSONValueNewObject(); /* Union KeyValue has two types, use the generic one */ if (virJSONValueObjectAppendString(key, "type", "number") < 0) @@ -5817,19 +5810,15 @@ static virJSONValuePtr qemuMonitorJSONMakeCPUModel(virCPUDefPtr cpu, bool migratable) { - virJSONValuePtr model = NULL; + virJSONValuePtr model = virJSONValueNewObject(); virJSONValuePtr props = NULL; size_t i; - if (!(model = virJSONValueNewObject())) - goto error; - if (virJSONValueObjectAppendString(model, "name", cpu->model) < 0) goto error; if (cpu->nfeatures || !migratable) { - if (!(props = virJSONValueNewObject())) - goto error; + props = virJSONValueNewObject(); for (i = 0; i < cpu->nfeatures; i++) { char *name = cpu->features[i].name; @@ -7382,8 +7371,8 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, const virDomainChrSourceDef *chr) { virJSONValuePtr ret = NULL; - virJSONValuePtr backend = NULL; - virJSONValuePtr data = NULL; + virJSONValuePtr backend = virJSONValueNewObject(); + virJSONValuePtr data = virJSONValueNewObject(); virJSONValuePtr addr = NULL; const char *backend_type = NULL; const char *host; @@ -7391,11 +7380,6 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, char *tlsalias = NULL; bool telnet; - if (!(backend = virJSONValueNewObject()) || - !(data = virJSONValueNewObject())) { - goto cleanup; - } - switch ((virDomainChrType)chr->type) { case VIR_DOMAIN_CHR_TYPE_NULL: case VIR_DOMAIN_CHR_TYPE_VC: diff --git a/src/qemu/qemu_vhost_user.c b/src/qemu/qemu_vhost_user.c index aee18c9670..be7c3dd5b8 100644 --- a/src/qemu/qemu_vhost_user.c +++ b/src/qemu/qemu_vhost_user.c @@ -217,8 +217,7 @@ qemuVhostUserFormat(qemuVhostUserPtr vu) if (!vu) return NULL; - if (!(doc = virJSONValueNewObject())) - return NULL; + doc = virJSONValueNewObject(); if (virJSONValueObjectAppendString(doc, "type", qemuVhostUserTypeTypeToString(vu->type)) < 0) diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 7f2226b086..bb81a43d43 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -382,18 +382,12 @@ virJSONValuePtr virNetDaemonPreExecRestart(virNetDaemonPtr dmn) { size_t i = 0; - virJSONValuePtr object = NULL; - virJSONValuePtr srvObj = NULL; + virJSONValuePtr object = virJSONValueNewObject(); + virJSONValuePtr srvObj = virJSONValueNewObject(); virHashKeyValuePairPtr srvArray = NULL; virObjectLock(dmn); - if (!(object = virJSONValueNewObject())) - goto error; - - if (!(srvObj = virJSONValueNewObject())) - goto error; - if (virJSONValueObjectAppend(object, "servers", srvObj) < 0) { virJSONValueFree(srvObj); goto error; diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index c87dade1a8..a5998801de 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -546,16 +546,13 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object, virJSONValuePtr virNetServerPreExecRestart(virNetServerPtr srv) { - virJSONValuePtr object; + virJSONValuePtr object = virJSONValueNewObject(); virJSONValuePtr clients; virJSONValuePtr services; size_t i; virObjectLock(srv); - if (!(object = virJSONValueNewObject())) - goto error; - if (virJSONValueObjectAppendNumberUint(object, "min_workers", virThreadPoolGetMinWorkers(srv->workers)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 67b3bf9531..4d85ee25d7 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -593,9 +593,6 @@ virJSONValuePtr virNetServerClientPreExecRestart(virNetServerClientPtr client) virJSONValuePtr object = virJSONValueNewObject(); virJSONValuePtr child; - if (!object) - return NULL; - virObjectLock(client); if (virJSONValueObjectAppendNumberUlong(object, "id", diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c index 0a003e5814..9d5df456a8 100644 --- a/src/rpc/virnetserverservice.c +++ b/src/rpc/virnetserverservice.c @@ -343,9 +343,6 @@ virJSONValuePtr virNetServerServicePreExecRestart(virNetServerServicePtr svc) virJSONValuePtr socks; size_t i; - if (!object) - return NULL; - if (virJSONValueObjectAppendNumberInt(object, "auth", svc->auth) < 0) goto error; if (virJSONValueObjectAppendBoolean(object, "readonly", svc->readonly) < 0) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index a217404fa6..360711acb6 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -1283,8 +1283,7 @@ virJSONValuePtr virNetSocketPreExecRestart(virNetSocketPtr sock) goto error; } - if (!(object = virJSONValueNewObject())) - goto error; + object = virJSONValueNewObject(); if (virJSONValueObjectAppendNumberInt(object, "fd", sock->fd) < 0) goto error; diff --git a/src/util/virjson.c b/src/util/virjson.c index ca57df816f..2d7368b0b6 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -362,8 +362,7 @@ virJSONValueObjectCreateVArgs(virJSONValuePtr *obj, { int ret; - if (!(*obj = virJSONValueNewObject())) - return -1; + *obj = virJSONValueNewObject(); /* free the object on error, or if no value objects were added */ if ((ret = virJSONValueObjectAddVArgs(*obj, args)) <= 0) { @@ -572,10 +571,7 @@ virJSONValueNewArray(void) virJSONValuePtr virJSONValueNewObject(void) { - virJSONValuePtr val; - - if (VIR_ALLOC(val) < 0) - return NULL; + virJSONValuePtr val = g_new0(virJSONValue, 1); val->type = VIR_JSON_TYPE_OBJECT; @@ -1503,8 +1499,6 @@ virJSONValueCopy(const virJSONValue *in) switch ((virJSONType) in->type) { case VIR_JSON_TYPE_OBJECT: out = virJSONValueNewObject(); - if (!out) - return NULL; for (i = 0; i < in->data.object.npairs; i++) { virJSONValuePtr val = NULL; if (!(val = virJSONValueCopy(in->data.object.pairs[i].value))) @@ -1724,9 +1718,6 @@ virJSONParserHandleStartMap(void *ctx) VIR_DEBUG("parser=%p", parser); - if (!value) - return 0; - if (virJSONParserInsertValue(parser, value) < 0) { virJSONValueFree(value); return 0; @@ -2103,8 +2094,7 @@ virJSONValueObjectDeflattenWorker(const char *key, } if (!(existobj = virJSONValueObjectGet(retobj, tokens[0]))) { - if (!(existobj = virJSONValueNewObject())) - goto cleanup; + existobj = virJSONValueNewObject(); if (virJSONValueObjectAppend(retobj, tokens[0], existobj) < 0) goto cleanup; @@ -2143,10 +2133,7 @@ virJSONValueObjectDeflattenWorker(const char *key, virJSONValuePtr virJSONValueObjectDeflatten(virJSONValuePtr json) { - g_autoptr(virJSONValue) deflattened = NULL; - - if (!(deflattened = virJSONValueNewObject())) - return NULL; + g_autoptr(virJSONValue) deflattened = virJSONValueNewObject(); if (virJSONValueObjectForeachKeyValue(json, virJSONValueObjectDeflattenWorker, diff --git a/src/util/virlease.c b/src/util/virlease.c index e0f81539be..1cb9540d80 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -238,11 +238,7 @@ virLeaseNew(virJSONValuePtr *lease_ret, } /* Create new lease */ - if (!(lease_new = virJSONValueNewObject())) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to create json")); - return -1; - } + lease_new = virJSONValueNewObject(); if (iaid && virJSONValueObjectAppendString(lease_new, "iaid", iaid) < 0) return -1; diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index a44377f89e..05517f8b40 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -434,9 +434,6 @@ virJSONValuePtr virLockSpacePreExecRestart(virLockSpacePtr lockspace) virJSONValuePtr resources; virHashKeyValuePairPtr pairs = NULL, tmp; - if (!object) - return NULL; - virMutexLock(&lockspace->lock); if (lockspace->dir && @@ -457,9 +454,6 @@ virJSONValuePtr virLockSpacePreExecRestart(virLockSpacePtr lockspace) virJSONValuePtr owners = NULL; size_t i; - if (!child) - goto error; - if (virJSONValueArrayAppend(resources, child) < 0) { virJSONValueFree(child); goto error; diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c index ec589334ea..0c0ba90def 100644 --- a/src/util/virmacmap.c +++ b/src/util/virmacmap.c @@ -200,15 +200,12 @@ virMACMapHashDumper(void *payload, const void *name, void *data) { - virJSONValuePtr obj = NULL; + virJSONValuePtr obj = virJSONValueNewObject(); virJSONValuePtr arr = NULL; const char **macs = payload; size_t i; int ret = -1; - if (!(obj = virJSONValueNewObject())) - goto cleanup; - arr = virJSONValueNewArray(); for (i = 0; macs[i]; i++) { diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 094d1ac09b..b465bdac2e 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1874,8 +1874,7 @@ virNetDevSaveNetConfig(const char *linkdev, int vf, } } - if (!(configJSON = virJSONValueNewObject())) - goto cleanup; + configJSON = virJSONValueNewObject(); /* if there is a PF, it's now in pfDevName, and linkdev is either * the VF's name, or NULL (if the VF isn't bound to a net driver diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index b29e5d8cd2..00f5b49439 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -529,12 +529,8 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test, return -1; } - if (!args) { - if (!(emptyargs = virJSONValueNewObject())) - return -1; - - args = emptyargs; - } + if (!args) + args = emptyargs = virJSONValueNewObject(); if (testQEMUSchemaValidate(args, schemaroot, test->qapischema, &debug) < 0) { if (qemuMonitorReportError(test, -- 2.24.1

qemuMonitorJSONMakeCommandInternal does the full command construction if you pass in what would become the value of the 'arguments' key. Refactor the open-coded implementation to use the helper and use modern cleanup helpers at the same time. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_json.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 5f0185d10b..3eac80c060 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3440,30 +3440,19 @@ int qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon, virJSONValuePtr params) { - int ret = -1; - virJSONValuePtr cmd = virJSONValueNewObject(); - virJSONValuePtr reply = NULL; - - if (virJSONValueObjectAppendString(cmd, "execute", - "migrate-set-parameters") < 0) - goto cleanup; + g_autoptr(virJSONValue) cmd = NULL; + g_autoptr(virJSONValue) reply = NULL; - if (virJSONValueObjectAppend(cmd, "arguments", params) < 0) - goto cleanup; - params = NULL; + if (!(cmd = qemuMonitorJSONMakeCommandInternal("migrate-set-parameters", params))) + return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; - ret = 0; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(params); - virJSONValueFree(reply); - return ret; + return 0; } -- 2.24.1

Use the new command in the test suite by asserting the capability and adjusting test data to the correct field names as they changed compared to 'query-cpus'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/qemuhotplugtest.c | 2 + .../ppc64-modern-bulk-monitor.json | 390 +++++++++--------- .../ppc64-modern-individual-monitor.json | 196 ++++----- .../x86-modern-bulk-monitor.json | 150 +++---- .../x86-modern-individual-add-monitor.json | 92 ++--- .../x86-old-bulk-monitor.json | 150 +++---- 6 files changed, 491 insertions(+), 489 deletions(-) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 9dd42664cd..e008c1bf0d 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -437,6 +437,8 @@ testQemuHotplugCpuPrepare(const char *test, priv = data->vm->privateData; + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_QUERY_CPUS_FAST); + if (data->modern) virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS); diff --git a/tests/qemuhotplugtestcpus/ppc64-modern-bulk-monitor.json b/tests/qemuhotplugtestcpus/ppc64-modern-bulk-monitor.json index c139426b7b..068b45e3c0 100644 --- a/tests/qemuhotplugtestcpus/ppc64-modern-bulk-monitor.json +++ b/tests/qemuhotplugtestcpus/ppc64-modern-bulk-monitor.json @@ -35,81 +35,81 @@ "id": "libvirt-15" } -{"execute":"query-cpus","id":"libvirt-2"} +{"execute":"query-cpus-fast","id":"libvirt-2"} { "return": [ { - "arch": "ppc", + "target": "ppc", "current": true, - "CPU": 0, + "cpu-index": 0, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[0]", + "qom-path": "/machine/unattached/device[1]/thread[0]", "halted": false, - "thread_id": 21925 + "thread-id": 21925 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 1, + "cpu-index": 1, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[1]", + "qom-path": "/machine/unattached/device[1]/thread[1]", "halted": false, - "thread_id": 21926 + "thread-id": 21926 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 2, + "cpu-index": 2, "nip": -4611686018422360608, - "qom_path": "/machine/unattached/device[1]/thread[2]", + "qom-path": "/machine/unattached/device[1]/thread[2]", "halted": false, - "thread_id": 21927 + "thread-id": 21927 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 3, + "cpu-index": 3, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[3]", + "qom-path": "/machine/unattached/device[1]/thread[3]", "halted": false, - "thread_id": 21928 + "thread-id": 21928 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 4, + "cpu-index": 4, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[4]", + "qom-path": "/machine/unattached/device[1]/thread[4]", "halted": false, - "thread_id": 21930 + "thread-id": 21930 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 5, + "cpu-index": 5, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[5]", + "qom-path": "/machine/unattached/device[1]/thread[5]", "halted": false, - "thread_id": 21931 + "thread-id": 21931 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 6, + "cpu-index": 6, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[6]", + "qom-path": "/machine/unattached/device[1]/thread[6]", "halted": false, - "thread_id": 21932 + "thread-id": 21932 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 7, + "cpu-index": 7, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[7]", + "qom-path": "/machine/unattached/device[1]/thread[7]", "halted": false, - "thread_id": 21933 + "thread-id": 21933 } ], "id": "libvirt-12" @@ -165,153 +165,153 @@ "id": "libvirt-15" } -{"execute":"query-cpus","id":"libvirt-5"} +{"execute":"query-cpus-fast","id":"libvirt-5"} { "return": [ { - "arch": "ppc", + "target": "ppc", "current": true, - "CPU": 0, + "cpu-index": 0, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[0]", + "qom-path": "/machine/unattached/device[1]/thread[0]", "halted": false, - "thread_id": 21925 + "thread-id": 21925 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 1, + "cpu-index": 1, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[1]", + "qom-path": "/machine/unattached/device[1]/thread[1]", "halted": false, - "thread_id": 21926 + "thread-id": 21926 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 2, + "cpu-index": 2, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[2]", + "qom-path": "/machine/unattached/device[1]/thread[2]", "halted": false, - "thread_id": 21927 + "thread-id": 21927 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 3, + "cpu-index": 3, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[3]", + "qom-path": "/machine/unattached/device[1]/thread[3]", "halted": false, - "thread_id": 21928 + "thread-id": 21928 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 4, + "cpu-index": 4, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[4]", + "qom-path": "/machine/unattached/device[1]/thread[4]", "halted": false, - "thread_id": 21930 + "thread-id": 21930 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 5, + "cpu-index": 5, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[5]", + "qom-path": "/machine/unattached/device[1]/thread[5]", "halted": false, - "thread_id": 21931 + "thread-id": 21931 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 6, + "cpu-index": 6, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[6]", + "qom-path": "/machine/unattached/device[1]/thread[6]", "halted": false, - "thread_id": 21932 + "thread-id": 21932 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 7, + "cpu-index": 7, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[7]", + "qom-path": "/machine/unattached/device[1]/thread[7]", "halted": false, - "thread_id": 21933 + "thread-id": 21933 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 8, + "cpu-index": 8, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[0]", + "qom-path": "/machine/peripheral/vcpu1/thread[0]", "halted": false, - "thread_id": 22131 + "thread-id": 22131 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 9, + "cpu-index": 9, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[1]", + "qom-path": "/machine/peripheral/vcpu1/thread[1]", "halted": false, - "thread_id": 22132 + "thread-id": 22132 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 10, + "cpu-index": 10, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[2]", + "qom-path": "/machine/peripheral/vcpu1/thread[2]", "halted": false, - "thread_id": 22133 + "thread-id": 22133 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 11, + "cpu-index": 11, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[3]", + "qom-path": "/machine/peripheral/vcpu1/thread[3]", "halted": false, - "thread_id": 22134 + "thread-id": 22134 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 12, + "cpu-index": 12, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[4]", + "qom-path": "/machine/peripheral/vcpu1/thread[4]", "halted": false, - "thread_id": 22135 + "thread-id": 22135 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 13, + "cpu-index": 13, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[5]", + "qom-path": "/machine/peripheral/vcpu1/thread[5]", "halted": false, - "thread_id": 22136 + "thread-id": 22136 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 14, + "cpu-index": 14, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[6]", + "qom-path": "/machine/peripheral/vcpu1/thread[6]", "halted": false, - "thread_id": 22137 + "thread-id": 22137 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 15, + "cpu-index": 15, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[7]", + "qom-path": "/machine/peripheral/vcpu1/thread[7]", "halted": false, - "thread_id": 22138 + "thread-id": 22138 } ], "id": "libvirt-14" @@ -368,225 +368,225 @@ "id": "libvirt-15" } -{"execute":"query-cpus","id":"libvirt-8"} +{"execute":"query-cpus-fast","id":"libvirt-8"} { "return": [ { - "arch": "ppc", + "target": "ppc", "current": true, - "CPU": 0, + "cpu-index": 0, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[0]", + "qom-path": "/machine/unattached/device[1]/thread[0]", "halted": false, - "thread_id": 21925 + "thread-id": 21925 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 1, + "cpu-index": 1, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[1]", + "qom-path": "/machine/unattached/device[1]/thread[1]", "halted": false, - "thread_id": 21926 + "thread-id": 21926 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 2, + "cpu-index": 2, "nip": -4611686018422360576, - "qom_path": "/machine/unattached/device[1]/thread[2]", + "qom-path": "/machine/unattached/device[1]/thread[2]", "halted": false, - "thread_id": 21927 + "thread-id": 21927 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 3, + "cpu-index": 3, "nip": -4611686018422360596, - "qom_path": "/machine/unattached/device[1]/thread[3]", + "qom-path": "/machine/unattached/device[1]/thread[3]", "halted": false, - "thread_id": 21928 + "thread-id": 21928 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 4, + "cpu-index": 4, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[4]", + "qom-path": "/machine/unattached/device[1]/thread[4]", "halted": false, - "thread_id": 21930 + "thread-id": 21930 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 5, + "cpu-index": 5, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[5]", + "qom-path": "/machine/unattached/device[1]/thread[5]", "halted": false, - "thread_id": 21931 + "thread-id": 21931 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 6, + "cpu-index": 6, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[6]", + "qom-path": "/machine/unattached/device[1]/thread[6]", "halted": false, - "thread_id": 21932 + "thread-id": 21932 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 7, + "cpu-index": 7, "nip": -4611686018422360596, - "qom_path": "/machine/unattached/device[1]/thread[7]", + "qom-path": "/machine/unattached/device[1]/thread[7]", "halted": false, - "thread_id": 21933 + "thread-id": 21933 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 8, + "cpu-index": 8, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[0]", + "qom-path": "/machine/peripheral/vcpu1/thread[0]", "halted": false, - "thread_id": 22131 + "thread-id": 22131 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 9, + "cpu-index": 9, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[1]", + "qom-path": "/machine/peripheral/vcpu1/thread[1]", "halted": false, - "thread_id": 22132 + "thread-id": 22132 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 10, + "cpu-index": 10, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[2]", + "qom-path": "/machine/peripheral/vcpu1/thread[2]", "halted": false, - "thread_id": 22133 + "thread-id": 22133 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 11, + "cpu-index": 11, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[3]", + "qom-path": "/machine/peripheral/vcpu1/thread[3]", "halted": false, - "thread_id": 22134 + "thread-id": 22134 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 12, + "cpu-index": 12, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[4]", + "qom-path": "/machine/peripheral/vcpu1/thread[4]", "halted": false, - "thread_id": 22135 + "thread-id": 22135 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 13, + "cpu-index": 13, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[5]", + "qom-path": "/machine/peripheral/vcpu1/thread[5]", "halted": false, - "thread_id": 22136 + "thread-id": 22136 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 14, + "cpu-index": 14, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[6]", + "qom-path": "/machine/peripheral/vcpu1/thread[6]", "halted": false, - "thread_id": 22137 + "thread-id": 22137 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 15, + "cpu-index": 15, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu1/thread[7]", + "qom-path": "/machine/peripheral/vcpu1/thread[7]", "halted": false, - "thread_id": 22138 + "thread-id": 22138 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 16, + "cpu-index": 16, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu2/thread[0]", + "qom-path": "/machine/peripheral/vcpu2/thread[0]", "halted": false, - "thread_id": 22223 + "thread-id": 22223 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 17, + "cpu-index": 17, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu2/thread[1]", + "qom-path": "/machine/peripheral/vcpu2/thread[1]", "halted": false, - "thread_id": 22224 + "thread-id": 22224 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 18, + "cpu-index": 18, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu2/thread[2]", + "qom-path": "/machine/peripheral/vcpu2/thread[2]", "halted": false, - "thread_id": 22225 + "thread-id": 22225 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 19, + "cpu-index": 19, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu2/thread[3]", + "qom-path": "/machine/peripheral/vcpu2/thread[3]", "halted": false, - "thread_id": 22226 + "thread-id": 22226 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 20, + "cpu-index": 20, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu2/thread[4]", + "qom-path": "/machine/peripheral/vcpu2/thread[4]", "halted": false, - "thread_id": 22227 + "thread-id": 22227 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 21, + "cpu-index": 21, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu2/thread[5]", + "qom-path": "/machine/peripheral/vcpu2/thread[5]", "halted": false, - "thread_id": 22228 + "thread-id": 22228 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 22, + "cpu-index": 22, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu2/thread[6]", + "qom-path": "/machine/peripheral/vcpu2/thread[6]", "halted": false, - "thread_id": 22229 + "thread-id": 22229 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 23, + "cpu-index": 23, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu2/thread[7]", + "qom-path": "/machine/peripheral/vcpu2/thread[7]", "halted": false, - "thread_id": 22230 + "thread-id": 22230 } ], "id": "libvirt-17" diff --git a/tests/qemuhotplugtestcpus/ppc64-modern-individual-monitor.json b/tests/qemuhotplugtestcpus/ppc64-modern-individual-monitor.json index ad5cc984a8..b90c4acb73 100644 --- a/tests/qemuhotplugtestcpus/ppc64-modern-individual-monitor.json +++ b/tests/qemuhotplugtestcpus/ppc64-modern-individual-monitor.json @@ -35,81 +35,81 @@ "id": "libvirt-15" } -{"execute":"query-cpus","id":"libvirt-2"} +{"execute":"query-cpus-fast","id":"libvirt-2"} { "return": [ { - "arch": "ppc", + "target": "ppc", "current": true, - "CPU": 0, + "cpu-index": 0, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[0]", + "qom-path": "/machine/unattached/device[1]/thread[0]", "halted": false, - "thread_id": 21925 + "thread-id": 21925 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 1, + "cpu-index": 1, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[1]", + "qom-path": "/machine/unattached/device[1]/thread[1]", "halted": false, - "thread_id": 21926 + "thread-id": 21926 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 2, + "cpu-index": 2, "nip": -4611686018422360608, - "qom_path": "/machine/unattached/device[1]/thread[2]", + "qom-path": "/machine/unattached/device[1]/thread[2]", "halted": false, - "thread_id": 21927 + "thread-id": 21927 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 3, + "cpu-index": 3, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[3]", + "qom-path": "/machine/unattached/device[1]/thread[3]", "halted": false, - "thread_id": 21928 + "thread-id": 21928 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 4, + "cpu-index": 4, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[4]", + "qom-path": "/machine/unattached/device[1]/thread[4]", "halted": false, - "thread_id": 21930 + "thread-id": 21930 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 5, + "cpu-index": 5, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[5]", + "qom-path": "/machine/unattached/device[1]/thread[5]", "halted": false, - "thread_id": 21931 + "thread-id": 21931 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 6, + "cpu-index": 6, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[6]", + "qom-path": "/machine/unattached/device[1]/thread[6]", "halted": false, - "thread_id": 21932 + "thread-id": 21932 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 7, + "cpu-index": 7, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[7]", + "qom-path": "/machine/unattached/device[1]/thread[7]", "halted": false, - "thread_id": 21933 + "thread-id": 21933 } ], "id": "libvirt-12" @@ -165,153 +165,153 @@ "id": "libvirt-15" } -{"execute":"query-cpus","id":"libvirt-5"} +{"execute":"query-cpus-fast","id":"libvirt-5"} { "return": [ { - "arch": "ppc", + "target": "ppc", "current": true, - "CPU": 0, + "cpu-index": 0, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[0]", + "qom-path": "/machine/unattached/device[1]/thread[0]", "halted": false, - "thread_id": 21925 + "thread-id": 21925 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 1, + "cpu-index": 1, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[1]", + "qom-path": "/machine/unattached/device[1]/thread[1]", "halted": false, - "thread_id": 21926 + "thread-id": 21926 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 2, + "cpu-index": 2, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[2]", + "qom-path": "/machine/unattached/device[1]/thread[2]", "halted": false, - "thread_id": 21927 + "thread-id": 21927 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 3, + "cpu-index": 3, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[3]", + "qom-path": "/machine/unattached/device[1]/thread[3]", "halted": false, - "thread_id": 21928 + "thread-id": 21928 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 4, + "cpu-index": 4, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[4]", + "qom-path": "/machine/unattached/device[1]/thread[4]", "halted": false, - "thread_id": 21930 + "thread-id": 21930 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 5, + "cpu-index": 5, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[5]", + "qom-path": "/machine/unattached/device[1]/thread[5]", "halted": false, - "thread_id": 21931 + "thread-id": 21931 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 6, + "cpu-index": 6, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[6]", + "qom-path": "/machine/unattached/device[1]/thread[6]", "halted": false, - "thread_id": 21932 + "thread-id": 21932 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 7, + "cpu-index": 7, "nip": -4611686018426772172, - "qom_path": "/machine/unattached/device[1]/thread[7]", + "qom-path": "/machine/unattached/device[1]/thread[7]", "halted": false, - "thread_id": 21933 + "thread-id": 21933 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 8, + "cpu-index": 8, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu16/thread[0]", + "qom-path": "/machine/peripheral/vcpu16/thread[0]", "halted": false, - "thread_id": 22131 + "thread-id": 22131 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 9, + "cpu-index": 9, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu16/thread[1]", + "qom-path": "/machine/peripheral/vcpu16/thread[1]", "halted": false, - "thread_id": 22132 + "thread-id": 22132 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 10, + "cpu-index": 10, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu16/thread[2]", + "qom-path": "/machine/peripheral/vcpu16/thread[2]", "halted": false, - "thread_id": 22133 + "thread-id": 22133 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 11, + "cpu-index": 11, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu16/thread[3]", + "qom-path": "/machine/peripheral/vcpu16/thread[3]", "halted": false, - "thread_id": 22134 + "thread-id": 22134 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 12, + "cpu-index": 12, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu16/thread[4]", + "qom-path": "/machine/peripheral/vcpu16/thread[4]", "halted": false, - "thread_id": 22135 + "thread-id": 22135 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 13, + "cpu-index": 13, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu16/thread[5]", + "qom-path": "/machine/peripheral/vcpu16/thread[5]", "halted": false, - "thread_id": 22136 + "thread-id": 22136 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 14, + "cpu-index": 14, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu16/thread[6]", + "qom-path": "/machine/peripheral/vcpu16/thread[6]", "halted": false, - "thread_id": 22137 + "thread-id": 22137 }, { - "arch": "ppc", + "target": "ppc", "current": false, - "CPU": 15, + "cpu-index": 15, "nip": -4611686018426772172, - "qom_path": "/machine/peripheral/vcpu16/thread[7]", + "qom-path": "/machine/peripheral/vcpu16/thread[7]", "halted": false, - "thread_id": 22138 + "thread-id": 22138 } ], "id": "libvirt-14" diff --git a/tests/qemuhotplugtestcpus/x86-modern-bulk-monitor.json b/tests/qemuhotplugtestcpus/x86-modern-bulk-monitor.json index b1d02b8d43..a412ccaf6e 100644 --- a/tests/qemuhotplugtestcpus/x86-modern-bulk-monitor.json +++ b/tests/qemuhotplugtestcpus/x86-modern-bulk-monitor.json @@ -83,54 +83,54 @@ "id": "libvirt-23" } -{"execute":"query-cpus","id":"libvirt-2"} +{"execute":"query-cpus-fast","id":"libvirt-2"} { "return": [ { - "arch": "x86", + "target": "x86", "current": true, - "CPU": 0, - "qom_path": "/machine/unattached/device[0]", + "cpu-index": 0, + "qom-path": "/machine/unattached/device[0]", "pc": -2130415978, "halted": true, - "thread_id": 518291 + "thread-id": 518291 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 1, - "qom_path": "/machine/unattached/device[2]", + "cpu-index": 1, + "qom-path": "/machine/unattached/device[2]", "pc": -2130415978, "halted": true, - "thread_id": 518292 + "thread-id": 518292 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 2, - "qom_path": "/machine/unattached/device[3]", + "cpu-index": 2, + "qom-path": "/machine/unattached/device[3]", "pc": -2130415978, "halted": true, - "thread_id": 518294 + "thread-id": 518294 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 3, - "qom_path": "/machine/unattached/device[4]", + "cpu-index": 3, + "qom-path": "/machine/unattached/device[4]", "pc": -2130415978, "halted": true, - "thread_id": 518295 + "thread-id": 518295 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 4, - "qom_path": "/machine/unattached/device[5]", + "cpu-index": 4, + "qom-path": "/machine/unattached/device[5]", "pc": -2130415978, "halted": true, - "thread_id": 518296 + "thread-id": 518296 } ], "id": "libvirt-22" @@ -236,63 +236,63 @@ "id": "libvirt-23" } -{"execute":"query-cpus","id":"libvirt-5"} +{"execute":"query-cpus-fast","id":"libvirt-5"} { "return": [ { - "arch": "x86", + "target": "x86", "current": true, - "CPU": 0, - "qom_path": "/machine/unattached/device[0]", + "cpu-index": 0, + "qom-path": "/machine/unattached/device[0]", "pc": -2130415978, "halted": true, - "thread_id": 518291 + "thread-id": 518291 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 1, - "qom_path": "/machine/unattached/device[2]", + "cpu-index": 1, + "qom-path": "/machine/unattached/device[2]", "pc": -2130415978, "halted": true, - "thread_id": 518292 + "thread-id": 518292 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 2, - "qom_path": "/machine/unattached/device[3]", + "cpu-index": 2, + "qom-path": "/machine/unattached/device[3]", "pc": -2130415978, "halted": true, - "thread_id": 518294 + "thread-id": 518294 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 3, - "qom_path": "/machine/unattached/device[4]", + "cpu-index": 3, + "qom-path": "/machine/unattached/device[4]", "pc": -2130415978, "halted": true, - "thread_id": 518295 + "thread-id": 518295 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 4, - "qom_path": "/machine/unattached/device[5]", + "cpu-index": 4, + "qom-path": "/machine/unattached/device[5]", "pc": -2130415978, "halted": true, - "thread_id": 518296 + "thread-id": 518296 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 5, - "qom_path": "/machine/peripheral/vcpu5", + "cpu-index": 5, + "qom-path": "/machine/peripheral/vcpu5", "pc": -2130415978, "halted": true, - "thread_id": 518297 + "thread-id": 518297 } ], "id": "libvirt-22" @@ -399,72 +399,72 @@ "id": "libvirt-23" } -{"execute":"query-cpus","id":"libvirt-8"} +{"execute":"query-cpus-fast","id":"libvirt-8"} { "return": [ { - "arch": "x86", + "target": "x86", "current": true, - "CPU": 0, - "qom_path": "/machine/unattached/device[0]", + "cpu-index": 0, + "qom-path": "/machine/unattached/device[0]", "pc": -2130415978, "halted": true, - "thread_id": 518291 + "thread-id": 518291 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 1, - "qom_path": "/machine/unattached/device[2]", + "cpu-index": 1, + "qom-path": "/machine/unattached/device[2]", "pc": -2130415978, "halted": true, - "thread_id": 518292 + "thread-id": 518292 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 2, - "qom_path": "/machine/unattached/device[3]", + "cpu-index": 2, + "qom-path": "/machine/unattached/device[3]", "pc": -2130415978, "halted": true, - "thread_id": 518294 + "thread-id": 518294 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 3, - "qom_path": "/machine/unattached/device[4]", + "cpu-index": 3, + "qom-path": "/machine/unattached/device[4]", "pc": -2130415978, "halted": true, - "thread_id": 518295 + "thread-id": 518295 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 4, - "qom_path": "/machine/unattached/device[5]", + "cpu-index": 4, + "qom-path": "/machine/unattached/device[5]", "pc": -2130415978, "halted": true, - "thread_id": 518296 + "thread-id": 518296 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 5, - "qom_path": "/machine/peripheral/vcpu5", + "cpu-index": 5, + "qom-path": "/machine/peripheral/vcpu5", "pc": -2130415978, "halted": true, - "thread_id": 518297 + "thread-id": 518297 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 6, - "qom_path": "/machine/peripheral/vcpu6", + "cpu-index": 6, + "qom-path": "/machine/peripheral/vcpu6", "pc": -2130415978, "halted": true, - "thread_id": 518298 + "thread-id": 518298 } ], "id": "libvirt-22" diff --git a/tests/qemuhotplugtestcpus/x86-modern-individual-add-monitor.json b/tests/qemuhotplugtestcpus/x86-modern-individual-add-monitor.json index df05e5e3a9..0acf2d0cd9 100644 --- a/tests/qemuhotplugtestcpus/x86-modern-individual-add-monitor.json +++ b/tests/qemuhotplugtestcpus/x86-modern-individual-add-monitor.json @@ -83,54 +83,54 @@ "id": "libvirt-23" } -{"execute":"query-cpus","id":"libvirt-2"} +{"execute":"query-cpus-fast","id":"libvirt-2"} { "return": [ { - "arch": "x86", + "target": "x86", "current": true, - "CPU": 0, - "qom_path": "/machine/unattached/device[0]", + "cpu-index": 0, + "qom-path": "/machine/unattached/device[0]", "pc": -2130415978, "halted": true, - "thread_id": 518291 + "thread-id": 518291 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 1, - "qom_path": "/machine/unattached/device[2]", + "cpu-index": 1, + "qom-path": "/machine/unattached/device[2]", "pc": -2130415978, "halted": true, - "thread_id": 518292 + "thread-id": 518292 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 2, - "qom_path": "/machine/unattached/device[3]", + "cpu-index": 2, + "qom-path": "/machine/unattached/device[3]", "pc": -2130415978, "halted": true, - "thread_id": 518294 + "thread-id": 518294 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 3, - "qom_path": "/machine/unattached/device[4]", + "cpu-index": 3, + "qom-path": "/machine/unattached/device[4]", "pc": -2130415978, "halted": true, - "thread_id": 518295 + "thread-id": 518295 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 4, - "qom_path": "/machine/unattached/device[5]", + "cpu-index": 4, + "qom-path": "/machine/unattached/device[5]", "pc": -2130415978, "halted": true, - "thread_id": 518296 + "thread-id": 518296 } ], "id": "libvirt-22" @@ -236,63 +236,63 @@ "id": "libvirt-23" } -{"execute":"query-cpus","id":"libvirt-5"} +{"execute":"query-cpus-fast","id":"libvirt-5"} { "return": [ { - "arch": "x86", + "target": "x86", "current": true, - "CPU": 0, - "qom_path": "/machine/unattached/device[0]", + "cpu-index": 0, + "qom-path": "/machine/unattached/device[0]", "pc": -2130415978, "halted": true, - "thread_id": 518291 + "thread-id": 518291 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 1, - "qom_path": "/machine/unattached/device[2]", + "cpu-index": 1, + "qom-path": "/machine/unattached/device[2]", "pc": -2130415978, "halted": true, - "thread_id": 518292 + "thread-id": 518292 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 2, - "qom_path": "/machine/unattached/device[3]", + "cpu-index": 2, + "qom-path": "/machine/unattached/device[3]", "pc": -2130415978, "halted": true, - "thread_id": 518294 + "thread-id": 518294 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 3, - "qom_path": "/machine/unattached/device[4]", + "cpu-index": 3, + "qom-path": "/machine/unattached/device[4]", "pc": -2130415978, "halted": true, - "thread_id": 518295 + "thread-id": 518295 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 4, - "qom_path": "/machine/unattached/device[5]", + "cpu-index": 4, + "qom-path": "/machine/unattached/device[5]", "pc": -2130415978, "halted": true, - "thread_id": 518296 + "thread-id": 518296 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 5, - "qom_path": "/machine/peripheral/vcpu7", + "cpu-index": 5, + "qom-path": "/machine/peripheral/vcpu7", "pc": -2130415978, "halted": true, - "thread_id": 518297 + "thread-id": 518297 } ], "id": "libvirt-22" diff --git a/tests/qemuhotplugtestcpus/x86-old-bulk-monitor.json b/tests/qemuhotplugtestcpus/x86-old-bulk-monitor.json index 6caf8cc184..626c0a5699 100644 --- a/tests/qemuhotplugtestcpus/x86-old-bulk-monitor.json +++ b/tests/qemuhotplugtestcpus/x86-old-bulk-monitor.json @@ -1,51 +1,51 @@ -{"execute":"query-cpus","id":"libvirt-1"} +{"execute":"query-cpus-fast","id":"libvirt-1"} { "return": [ { - "arch": "x86", + "target": "x86", "current": true, - "CPU": 0, - "qom_path": "/machine/unattached/device[0]", + "cpu-index": 0, + "qom-path": "/machine/unattached/device[0]", "pc": -2130415978, "halted": true, - "thread_id": 518291 + "thread-id": 518291 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 1, - "qom_path": "/machine/unattached/device[2]", + "cpu-index": 1, + "qom-path": "/machine/unattached/device[2]", "pc": -2130415978, "halted": true, - "thread_id": 518292 + "thread-id": 518292 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 2, - "qom_path": "/machine/unattached/device[3]", + "cpu-index": 2, + "qom-path": "/machine/unattached/device[3]", "pc": -2130415978, "halted": true, - "thread_id": 518294 + "thread-id": 518294 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 3, - "qom_path": "/machine/unattached/device[4]", + "cpu-index": 3, + "qom-path": "/machine/unattached/device[4]", "pc": -2130415978, "halted": true, - "thread_id": 518295 + "thread-id": 518295 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 4, - "qom_path": "/machine/unattached/device[5]", + "cpu-index": 4, + "qom-path": "/machine/unattached/device[5]", "pc": -2130415978, "halted": true, - "thread_id": 518296 + "thread-id": 518296 } ], "id": "libvirt-22" @@ -55,63 +55,63 @@ {"return": {}} -{"execute":"query-cpus","id":"libvirt-3"} +{"execute":"query-cpus-fast","id":"libvirt-3"} { "return": [ { - "arch": "x86", + "target": "x86", "current": true, - "CPU": 0, - "qom_path": "/machine/unattached/device[0]", + "cpu-index": 0, + "qom-path": "/machine/unattached/device[0]", "pc": -2130415978, "halted": true, - "thread_id": 518291 + "thread-id": 518291 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 1, - "qom_path": "/machine/unattached/device[2]", + "cpu-index": 1, + "qom-path": "/machine/unattached/device[2]", "pc": -2130415978, "halted": true, - "thread_id": 518292 + "thread-id": 518292 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 2, - "qom_path": "/machine/unattached/device[3]", + "cpu-index": 2, + "qom-path": "/machine/unattached/device[3]", "pc": -2130415978, "halted": true, - "thread_id": 518294 + "thread-id": 518294 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 3, - "qom_path": "/machine/unattached/device[4]", + "cpu-index": 3, + "qom-path": "/machine/unattached/device[4]", "pc": -2130415978, "halted": true, - "thread_id": 518295 + "thread-id": 518295 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 4, - "qom_path": "/machine/unattached/device[5]", + "cpu-index": 4, + "qom-path": "/machine/unattached/device[5]", "pc": -2130415978, "halted": true, - "thread_id": 518296 + "thread-id": 518296 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 5, - "qom_path": "/machine/peripheral/vcpu5", + "cpu-index": 5, + "qom-path": "/machine/peripheral/vcpu5", "pc": -2130415978, "halted": true, - "thread_id": 518297 + "thread-id": 518297 } ], "id": "libvirt-22" @@ -121,72 +121,72 @@ {"return": {}} -{"execute":"query-cpus","id":"libvirt-5"} +{"execute":"query-cpus-fast","id":"libvirt-5"} { "return": [ { - "arch": "x86", + "target": "x86", "current": true, - "CPU": 0, - "qom_path": "/machine/unattached/device[0]", + "cpu-index": 0, + "qom-path": "/machine/unattached/device[0]", "pc": -2130415978, "halted": true, - "thread_id": 518291 + "thread-id": 518291 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 1, - "qom_path": "/machine/unattached/device[2]", + "cpu-index": 1, + "qom-path": "/machine/unattached/device[2]", "pc": -2130415978, "halted": true, - "thread_id": 518292 + "thread-id": 518292 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 2, - "qom_path": "/machine/unattached/device[3]", + "cpu-index": 2, + "qom-path": "/machine/unattached/device[3]", "pc": -2130415978, "halted": true, - "thread_id": 518294 + "thread-id": 518294 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 3, - "qom_path": "/machine/unattached/device[4]", + "cpu-index": 3, + "qom-path": "/machine/unattached/device[4]", "pc": -2130415978, "halted": true, - "thread_id": 518295 + "thread-id": 518295 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 4, - "qom_path": "/machine/unattached/device[5]", + "cpu-index": 4, + "qom-path": "/machine/unattached/device[5]", "pc": -2130415978, "halted": true, - "thread_id": 518296 + "thread-id": 518296 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 5, - "qom_path": "/machine/peripheral/vcpu5", + "cpu-index": 5, + "qom-path": "/machine/peripheral/vcpu5", "pc": -2130415978, "halted": true, - "thread_id": 518297 + "thread-id": 518297 }, { - "arch": "x86", + "target": "x86", "current": false, - "CPU": 6, - "qom_path": "/machine/peripheral/vcpu6", + "cpu-index": 6, + "qom-path": "/machine/peripheral/vcpu6", "pc": -2130415978, "halted": true, - "thread_id": 518298 + "thread-id": 518298 } ], "id": "libvirt-22" -- 2.24.1

On 3/4/20 11:16 AM, Peter Krempa wrote:
I take a look at Markus' QMP deprecation-introspection series. While that requires a lot more work I've fixed a few things along.
Peter Krempa (3): util: json: Convert virJSONValueNewObject() to g_new0 qemuMonitorJSONSetMigrationParams: Refactor command construction and cleanup qemuhotplugtestcpus: Always use 'query-cpus-fast'
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
participants (2)
-
Daniel Henrique Barboza
-
Peter Krempa