From nobody Mon Apr 29 07:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522919329074159.32028951308632; Thu, 5 Apr 2018 02:08:49 -0700 (PDT) Received: from localhost ([::1]:41614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40st-0001z8-LZ for importer@patchew.org; Thu, 05 Apr 2018 05:08:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40qn-0000o1-58 for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f40qj-0006W1-VS for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:33 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60700 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f40qj-0006VW-Py for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D2D777D843 for ; Thu, 5 Apr 2018 09:06:23 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17D9D2024CA4; Thu, 5 Apr 2018 09:06:22 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 11:05:03 +0200 Message-Id: <1522919113-158775-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1522919113-158775-1-git-send-email-imammedo@redhat.com> References: <1522919113-158775-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 05 Apr 2018 09:06:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 05 Apr 2018 09:06:23 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.13 v5 01/11] numa: postpone options post-processing till machine_run_board_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkrempa@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" in preparation for numa options to being handled via QMP before machine_run_board_init(), move final numa configuration checks and processing to machine_run_board_init() so it could take into account both CLI (via parse_numa_opts()) and QMP input Signed-off-by: Igor Mammedov Reviewed-by: Eduardo Habkost --- v2: - remove duplicate qemu_opts_foreach() in numa_complete_configuration() that was causing non explicitly IDed node "-numa node" parsed twice. --- include/sysemu/numa.h | 1 + hw/core/machine.c | 5 +++-- numa.c | 13 ++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index d99e547..21713b7 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -23,6 +23,7 @@ struct NumaNodeMem { =20 extern NodeInfo numa_info[MAX_NODES]; void parse_numa_opts(MachineState *ms); +void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[]); extern QemuOptsList qemu_numa_opts; void numa_legacy_auto_assign_ram(MachineClass *mc, NodeInfo *nodes, diff --git a/hw/core/machine.c b/hw/core/machine.c index 2040177..617e5f8 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -737,7 +737,7 @@ static char *cpu_slot_to_string(const CPUArchId *cpu) return g_string_free(s, false); } =20 -static void machine_numa_finish_init(MachineState *machine) +static void machine_numa_finish_cpu_init(MachineState *machine) { int i; bool default_mapping; @@ -792,7 +792,8 @@ void machine_run_board_init(MachineState *machine) MachineClass *machine_class =3D MACHINE_GET_CLASS(machine); =20 if (nb_numa_nodes) { - machine_numa_finish_init(machine); + numa_complete_configuration(machine); + machine_numa_finish_cpu_init(machine); } =20 /* If the machine supports the valid_cpu_types check and the user diff --git a/numa.c b/numa.c index 1116c90..e970c38 100644 --- a/numa.c +++ b/numa.c @@ -338,15 +338,11 @@ void numa_default_auto_assign_ram(MachineClass *mc, N= odeInfo *nodes, nodes[i].node_mem =3D size - usedmem; } =20 -void parse_numa_opts(MachineState *ms) +void numa_complete_configuration(MachineState *ms) { int i; MachineClass *mc =3D MACHINE_GET_CLASS(ms); =20 - if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, NULL)) { - exit(1); - } - /* * If memory hotplug is enabled (slots > 0) but without '-numa' * options explicitly on CLI, guestes will break. @@ -433,6 +429,13 @@ void parse_numa_opts(MachineState *ms) } } =20 +void parse_numa_opts(MachineState *ms) +{ + if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, NULL)) { + exit(1); + } +} + void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **er= rp) { int node_id =3D object_property_get_int(OBJECT(dev), "node-id", &error= _abort); --=20 2.7.4 From nobody Mon Apr 29 07:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522919594468527.2567034006972; Thu, 5 Apr 2018 02:13:14 -0700 (PDT) Received: from localhost ([::1]:41635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40xC-0005X3-6M for importer@patchew.org; Thu, 05 Apr 2018 05:13:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40qo-0000oP-BS for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f40qk-0006WN-18 for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:34 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60704 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f40qj-0006VX-SX for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D200C722EA for ; Thu, 5 Apr 2018 09:06:24 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 171E62024CA4; Thu, 5 Apr 2018 09:06:23 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 11:05:04 +0200 Message-Id: <1522919113-158775-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1522919113-158775-1-git-send-email-imammedo@redhat.com> References: <1522919113-158775-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 05 Apr 2018 09:06:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 05 Apr 2018 09:06:24 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.13 v5 02/11] numa: split out NumaOptions parsing into set_numa_options() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkrempa@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" it will allow to reuse set_numa_options() for parsing configuration commands received via QMP interface Signed-off-by: Igor Mammedov --- v5: - (Eduardo Habkost ) * drop if (err) guard around error_propagate() * s/parse_NumaOptions/set_numa_options/ --- include/sysemu/numa.h | 1 + numa.c | 46 +++++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 21713b7..7a0ae75 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -22,6 +22,7 @@ struct NumaNodeMem { }; =20 extern NodeInfo numa_info[MAX_NODES]; +int parse_numa(void *opaque, QemuOpts *opts, Error **errp); void parse_numa_opts(MachineState *ms); void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[]); diff --git a/numa.c b/numa.c index e970c38..11cae25 100644 --- a/numa.c +++ b/numa.c @@ -169,28 +169,11 @@ static void parse_numa_distance(NumaDistOptions *dist= , Error **errp) have_numa_distance =3D true; } =20 -static int parse_numa(void *opaque, QemuOpts *opts, Error **errp) +static +void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp) { - NumaOptions *object =3D NULL; - MachineState *ms =3D opaque; Error *err =3D NULL; =20 - { - Visitor *v =3D opts_visitor_new(opts); - visit_type_NumaOptions(v, NULL, &object, &err); - visit_free(v); - } - - if (err) { - goto end; - } - - /* Fix up legacy suffix-less format */ - if ((object->type =3D=3D NUMA_OPTIONS_TYPE_NODE) && object->u.node.has= _mem) { - const char *mem_str =3D qemu_opt_get(opts, "mem"); - qemu_strtosz_MiB(mem_str, NULL, &object->u.node.mem); - } - switch (object->type) { case NUMA_OPTIONS_TYPE_NODE: parse_numa_node(ms, &object->u.node, &err); @@ -224,6 +207,31 @@ static int parse_numa(void *opaque, QemuOpts *opts, Er= ror **errp) } =20 end: + error_propagate(errp, err); +} + +int parse_numa(void *opaque, QemuOpts *opts, Error **errp) +{ + NumaOptions *object =3D NULL; + MachineState *ms =3D MACHINE(opaque); + Error *err =3D NULL; + Visitor *v =3D opts_visitor_new(opts); + + visit_type_NumaOptions(v, NULL, &object, &err); + visit_free(v); + if (err) { + goto end; + } + + /* Fix up legacy suffix-less format */ + if ((object->type =3D=3D NUMA_OPTIONS_TYPE_NODE) && object->u.node.has= _mem) { + const char *mem_str =3D qemu_opt_get(opts, "mem"); + qemu_strtosz_MiB(mem_str, NULL, &object->u.node.mem); + } + + set_numa_options(ms, object, &err); + +end: qapi_free_NumaOptions(object); if (err) { error_report_err(err); --=20 2.7.4 From nobody Mon Apr 29 07:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522919697492258.6251509514665; Thu, 5 Apr 2018 02:14:57 -0700 (PDT) Received: from localhost ([::1]:41671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40yq-0006xj-ES for importer@patchew.org; Thu, 05 Apr 2018 05:14:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40qp-0000oc-0Z for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f40qk-0006WX-1x for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51480 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f40qj-0006VZ-SN for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1B014023112 for ; Thu, 5 Apr 2018 09:06:25 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 161CF2024CA4; Thu, 5 Apr 2018 09:06:24 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 11:05:05 +0200 Message-Id: <1522919113-158775-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1522919113-158775-1-git-send-email-imammedo@redhat.com> References: <1522919113-158775-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:25 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.13 v5 03/11] cli: add --preconfig option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkrempa@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This option allows pausing QEMU in the new RUN_STATE_PRECONFIG state, allowing the configuration of QEMU from QMP before the machine jumps into board initialization code of machine_run_board_init() The intent is to allow management to query machine state and additionally configure it using previous query results within one QEMU instance (i.e. eliminate the need to start QEMU twice, 1st to query board specific parameters and 2nd for actual VM start using query results for additional parameters). The new option complements -S option and could be used with or without it. The difference is that -S pauses QEMU when the machine is completely built with all devices wired up and ready to run (QEMU needs only to unpause CPUs to let guest execute its code), while the "preconfig" option pauses QEMU early before board specific init callback (machine_run_board_init) is executed and will allow the configuration of machine parameters which will be used by board init code. When early introspection/configuration is done, command 'cont' should be used to exit RUN_STATE_PRECONFIG and transition to the next requested state (i.e. if -S is used then QEMU will pause the second time when board/device initialization is completed or start guest execution if -S isn't provided on CLI) PS: Initially 'preconfig' is planned to be used for configuring numa topology depending on board specified possible cpus layout. Signed-off-by: Igor Mammedov --- v4: * Explain more on behaviour in commit message and use suggested wording in message and patch (Eric Blake ) v5: - (Eric Blake ) * more spelling/wording fixes * s/-preconfig/--preconfig/ * s/2.12/2.13/ - (Eduardo Habkost ) * move QCO_ALLOWED_IN_PRECONFIG and do_qmp_dispatch() runstate check from the later patch 'qapi: introduce new cmd option "allowed-in-pre= config"' to here for better bissectability * add TODO comment to '{ RUN_STATE_PRECONFIG, RUN_STATE_INMIGRATE }' tr= ansition * check for incoming && preconfig outside of option parsing loop --- include/qapi/qmp/dispatch.h | 1 + include/sysemu/sysemu.h | 1 + qapi/qmp-dispatch.c | 8 ++++++++ qapi/run-state.json | 5 ++++- qemu-options.hx | 13 +++++++++++++ qmp.c | 5 +++++ vl.c | 35 ++++++++++++++++++++++++++++++++++- 7 files changed, 66 insertions(+), 2 deletions(-) diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index ffb4652..6242cfc 100644 --- a/include/qapi/qmp/dispatch.h +++ b/include/qapi/qmp/dispatch.h @@ -23,6 +23,7 @@ typedef enum QmpCommandOptions QCO_NO_OPTIONS =3D 0x0, QCO_NO_SUCCESS_RESP =3D (1U << 0), QCO_ALLOW_OOB =3D (1U << 1), + QCO_ALLOWED_IN_PRECONFIG =3D (1U << 2), } QmpCommandOptions; =20 typedef struct QmpCommand diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 2b42151..5085978 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -66,6 +66,7 @@ typedef enum WakeupReason { QEMU_WAKEUP_REASON_OTHER, } WakeupReason; =20 +void qemu_exit_preconfig_request(void); void qemu_system_reset_request(ShutdownCause reason); void qemu_system_suspend_request(void); void qemu_register_suspend_notifier(Notifier *notifier); diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index dd05907..2604115 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -18,6 +18,7 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qbool.h" +#include "sysemu/sysemu.h" =20 QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp) { @@ -101,6 +102,13 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, = QObject *request, return NULL; } =20 + if (runstate_check(RUN_STATE_PRECONFIG) && + !(cmd->options & QCO_ALLOWED_IN_PRECONFIG)) { + error_setg(errp, "The command '%s' isn't permitted in '%s' state", + cmd->name, RunState_str(RUN_STATE_PRECONFIG)); + return NULL; + } + if (!qdict_haskey(dict, "arguments")) { args =3D qdict_new(); } else { diff --git a/qapi/run-state.json b/qapi/run-state.json index 1c9fff3..9694a9f 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -49,12 +49,15 @@ # @colo: guest is paused to save/restore VM state under colo checkpoint, # VM can not get into this state unless colo capability is enabled # for migration. (since 2.8) +# @preconfig: QEMU is paused before board specific init callback is execut= ed. +# The state is reachable only if the --preconfig CLI option is= used. +# (Since 2.13) ## { 'enum': 'RunState', 'data': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paused', 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm', 'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', - 'guest-panicked', 'colo' ] } + 'guest-panicked', 'colo', 'preconfig' ] } =20 ## # @StatusInfo: diff --git a/qemu-options.hx b/qemu-options.hx index 3ece30d..f8818ee 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3304,6 +3304,19 @@ STEXI Run the emulation in single step mode. ETEXI =20 +DEF("preconfig", 0, QEMU_OPTION_preconfig, \ + "--preconfig pause QEMU before machine is initialized\n", + QEMU_ARCH_ALL) +STEXI +@item --preconfig +@findex --preconfig +Pause QEMU for interactive configuration before the machine is created, +which allows querying and configuring properties that will affect +machine initialization. Use the QMP command 'cont' to exit the preconfig +state and move to the next state (ie. run guest if -S isn't used or +pause the second time if -S is used). +ETEXI + DEF("S", 0, QEMU_OPTION_S, \ "-S freeze CPU at startup (use 'c' to start execution)\n", QEMU_ARCH_ALL) diff --git a/qmp.c b/qmp.c index f722616..cd1b62f 100644 --- a/qmp.c +++ b/qmp.c @@ -166,6 +166,11 @@ void qmp_cont(Error **errp) BlockBackend *blk; Error *local_err =3D NULL; =20 + if (runstate_check(RUN_STATE_PRECONFIG)) { + qemu_exit_preconfig_request(); + return; + } + /* if there is a dump in background, we should wait until the dump * finished */ if (dump_in_progress()) { diff --git a/vl.c b/vl.c index fce1fd1..0d56908 100644 --- a/vl.c +++ b/vl.c @@ -594,7 +594,7 @@ static int default_driver_check(void *opaque, QemuOpts = *opts, Error **errp) /***********************************************************/ /* QEMU state */ =20 -static RunState current_run_state =3D RUN_STATE_PRELAUNCH; +static RunState current_run_state =3D RUN_STATE_PRECONFIG; =20 /* We use RUN_STATE__MAX but any invalid value will do */ static RunState vmstop_requested =3D RUN_STATE__MAX; @@ -607,6 +607,13 @@ typedef struct { =20 static const RunStateTransition runstate_transitions_def[] =3D { /* from -> to */ + { RUN_STATE_PRECONFIG, RUN_STATE_PRELAUNCH }, + /* Early switch to inmigrate state to allow -incoming CLI option wo= rk + * as it used to. TODO: delay actual switching to inmigrate state to + * the point after machine is built and remove this hack. + */ + { RUN_STATE_PRECONFIG, RUN_STATE_INMIGRATE }, + { RUN_STATE_DEBUG, RUN_STATE_RUNNING }, { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_DEBUG, RUN_STATE_PRELAUNCH }, @@ -1630,6 +1637,7 @@ static pid_t shutdown_pid; static int powerdown_requested; static int debug_requested; static int suspend_requested; +static bool preconfig_exit_requested =3D true; static WakeupReason wakeup_reason; static NotifierList powerdown_notifiers =3D NOTIFIER_LIST_INITIALIZER(powerdown_notifiers); @@ -1714,6 +1722,11 @@ static int qemu_debug_requested(void) return r; } =20 +void qemu_exit_preconfig_request(void) +{ + preconfig_exit_requested =3D true; +} + /* * Reset the VM. Issue an event unless @reason is SHUTDOWN_CAUSE_NONE. */ @@ -1887,6 +1900,13 @@ static bool main_loop_should_exit(void) RunState r; ShutdownCause request; =20 + if (preconfig_exit_requested) { + if (runstate_check(RUN_STATE_PRECONFIG)) { + runstate_set(RUN_STATE_PRELAUNCH); + } + preconfig_exit_requested =3D false; + return true; + } if (qemu_debug_requested()) { vm_stop(RUN_STATE_DEBUG); } @@ -3704,6 +3724,9 @@ int main(int argc, char **argv, char **envp) exit(1); } break; + case QEMU_OPTION_preconfig: + preconfig_exit_requested =3D false; + break; case QEMU_OPTION_enable_kvm: olist =3D qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "accel=3Dkvm", false); @@ -4073,6 +4096,12 @@ int main(int argc, char **argv, char **envp) =20 replay_configure(icount_opts); =20 + if (incoming && !preconfig_exit_requested) { + error_report("'preconfig' and 'incoming' options are " + "mutually exclusive"); + exit(EXIT_FAILURE); + } + machine_class =3D select_machine(); =20 set_memory_options(&ram_slots, &maxram_size, machine_class); @@ -4604,6 +4633,10 @@ int main(int argc, char **argv, char **envp) } parse_numa_opts(current_machine); =20 + /* do monitor/qmp handling at preconfig state if requested */ + main_loop(); + + /* from here on runstate is RUN_STATE_PRELAUNCH */ machine_run_board_init(current_machine); =20 realtime_init(); --=20 2.7.4 From nobody Mon Apr 29 07:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522919328041522.8258804924102; Thu, 5 Apr 2018 02:08:48 -0700 (PDT) Received: from localhost ([::1]:41612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40ss-0001yv-JQ for importer@patchew.org; Thu, 05 Apr 2018 05:08:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40qn-0000o4-5Q for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f40qk-0006WH-0d for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:33 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60702 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f40qj-0006VY-Sc for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D048B722F1 for ; Thu, 5 Apr 2018 09:06:26 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 152BC2024CA4; Thu, 5 Apr 2018 09:06:25 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 11:05:06 +0200 Message-Id: <1522919113-158775-5-git-send-email-imammedo@redhat.com> In-Reply-To: <1522919113-158775-1-git-send-email-imammedo@redhat.com> References: <1522919113-158775-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 05 Apr 2018 09:06:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 05 Apr 2018 09:06:26 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.13 v5 04/11] hmp: disable monitor in preconfig state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkrempa@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Ban it for now, if someone would need it to work early, one would have to implement checks if HMP command is valid at preconfig state. Signed-off-by: Igor Mammedov --- v5: * add 'use QMP instead" to error message, suggesting user the right interface to use v4: * v3 was only printing error but not preventing command execution, Fix it by returning after printing error message. ("Dr. David Alan Gilbert" ) --- monitor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/monitor.c b/monitor.c index 51f4cf4..fd1e7c8 100644 --- a/monitor.c +++ b/monitor.c @@ -3374,6 +3374,12 @@ static void handle_hmp_command(Monitor *mon, const c= har *cmdline) =20 trace_handle_hmp_command(mon, cmdline); =20 + if (runstate_check(RUN_STATE_PRECONFIG)) { + monitor_printf(mon, "HMP not available in preconfig state, " + "use QMP instead\n"); + return; + } + cmd =3D monitor_parse_command(mon, cmdline, &cmdline, mon->cmd_table); if (!cmd) { return; --=20 2.7.4 From nobody Mon Apr 29 07:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522919331985487.65308494998965; Thu, 5 Apr 2018 02:08:51 -0700 (PDT) Received: from localhost ([::1]:41615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40t0-000261-W0 for importer@patchew.org; Thu, 05 Apr 2018 05:08:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40qn-0000o3-5U for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f40qk-0006WO-1M for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:33 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51481 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f40qj-0006VV-Qh for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC0F34023113 for ; Thu, 5 Apr 2018 09:06:27 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13BF62024CA4; Thu, 5 Apr 2018 09:06:26 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 11:05:07 +0200 Message-Id: <1522919113-158775-6-git-send-email-imammedo@redhat.com> In-Reply-To: <1522919113-158775-1-git-send-email-imammedo@redhat.com> References: <1522919113-158775-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:27 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.13 v5 05/11] qapi: introduce new cmd option "allowed-in-preconfig" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkrempa@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" New option will be used to allow commands, which are prepared/need to run, during preconfig state. Other commands that should be able to run in preconfig state, should be ameded to not expect machine in initialized state or deal with it. For compatibility reasons, commands that don't use new flag 'allowed-in-preconfig' explicitly are not permitted to run in preconfig state but allowed in all other states like they used to be. Within this patch allow following commands in preconfig state: qmp_capabilities query-qmp-schema query-commands query-command-line-options query-status cont to allow qmp connection, basic introspection and moving to the next state. PS: set-numa-node and query-hotpluggable-cpus will be enabled later in a separate patch. Signed-off-by: Igor Mammedov --- v5: * allow query-command-line-options in preconfig state * rebase on top of OOB changes that's now in master * spelling/wording fixups * make sure that allowed-in-preconfig could be set only to True * move out QCO_ALLOWED_IN_PRECONFIG check in do_qmp_dispatch() to earlier 'cli: add -preconfig option' patch v4: * replaces complex "universal" approach "[PATCH v3 5/9] QAPI: allow to specify valid runstates per command" with a simpler new command flag "allowed-in-preconfig". (Eric Blake ) --- docs/devel/qapi-code-gen.txt | 10 +++++++++- monitor.c | 5 +++-- qapi/introspect.json | 5 ++++- qapi/misc.json | 11 +++++++---- qapi/run-state.json | 3 ++- scripts/qapi/commands.py | 12 ++++++++---- scripts/qapi/common.py | 19 ++++++++++++------- scripts/qapi/doc.py | 4 ++-- scripts/qapi/introspect.py | 7 ++++--- tests/qapi-schema/test-qapi.py | 4 ++-- 10 files changed, 53 insertions(+), 27 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index a569d24..31c4646 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -559,7 +559,7 @@ following example objects: Usage: { 'command': STRING, '*data': COMPLEX-TYPE-NAME-OR-DICT, '*returns': TYPE-NAME, '*boxed': true, '*gen': false, '*success-response': false, - '*allow-oob': true } + '*allow-oob': true, '*allowed-in-preconfig': true } =20 Commands are defined by using a dictionary containing several members, where three members are most common. The 'command' member is a @@ -683,6 +683,14 @@ OOB command handlers must satisfy the following condit= ions: =20 If in doubt, do not implement OOB execution support. =20 +A command may use optional 'allowed-in-preconfig' key to permit +its execution at early runtime configuration stage (preconfig runstate). +If not specified then a command defaults to 'allowed-in-preconfig: false'. + +An example of declaring preconfig enabled command: + { 'command': 'qmp_capabilities', + 'allowed-in-preconfig': true } + =3D=3D=3D Events =3D=3D=3D =20 Usage: { 'event': STRING, '*data': COMPLEX-TYPE-NAME-OR-DICT, diff --git a/monitor.c b/monitor.c index fd1e7c8..18a47c9 100644 --- a/monitor.c +++ b/monitor.c @@ -1183,7 +1183,7 @@ static void monitor_init_qmp_commands(void) =20 qmp_register_command(&qmp_commands, "query-qmp-schema", qmp_query_qmp_schema, - QCO_NO_OPTIONS); + QCO_ALLOWED_IN_PRECONFIG); qmp_register_command(&qmp_commands, "device_add", qmp_device_add, QCO_NO_OPTIONS); qmp_register_command(&qmp_commands, "netdev_add", qmp_netdev_add, @@ -1193,7 +1193,8 @@ static void monitor_init_qmp_commands(void) =20 QTAILQ_INIT(&qmp_cap_negotiation_commands); qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities", - qmp_marshal_qmp_capabilities, QCO_NO_OPTIONS); + qmp_marshal_qmp_capabilities, + QCO_ALLOWED_IN_PRECONFIG); } =20 static bool qmp_cap_enabled(Monitor *mon, QMPCapability cap) diff --git a/qapi/introspect.json b/qapi/introspect.json index c7f67b7..8036154 100644 --- a/qapi/introspect.json +++ b/qapi/introspect.json @@ -262,13 +262,16 @@ # @allow-oob: whether the command allows out-of-band execution. # (Since: 2.12) # +# @allowed-in-preconfig: command can be executed in preconfig runstate, +# default: 'false' (Since 2.13) +# # TODO: @success-response (currently irrelevant, because it's QGA, not QMP) # # Since: 2.5 ## { 'struct': 'SchemaInfoCommand', 'data': { 'arg-type': 'str', 'ret-type': 'str', - 'allow-oob': 'bool' } } + 'allow-oob': 'bool', 'allowed-in-preconfig': 'bool' } } =20 ## # @SchemaInfoEvent: diff --git a/qapi/misc.json b/qapi/misc.json index 5636f4a..579900f 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -35,7 +35,8 @@ # ## { 'command': 'qmp_capabilities', - 'data': { '*enable': [ 'QMPCapability' ] } } + 'data': { '*enable': [ 'QMPCapability' ] }, + 'allowed-in-preconfig': true } =20 ## # @QMPCapability: @@ -153,7 +154,8 @@ # Note: This example has been shortened as the real response is too long. # ## -{ 'command': 'query-commands', 'returns': ['CommandInfo'] } +{ 'command': 'query-commands', 'returns': ['CommandInfo'], + 'allowed-in-preconfig': true } =20 ## # @LostTickPolicy: @@ -1206,7 +1208,7 @@ # <- { "return": {} } # ## -{ 'command': 'cont' } +{ 'command': 'cont', 'allowed-in-preconfig': true } =20 ## # @system_wakeup: @@ -2614,7 +2616,8 @@ # ## {'command': 'query-command-line-options', 'data': { '*option': 'str' }, - 'returns': ['CommandLineOptionInfo'] } + 'returns': ['CommandLineOptionInfo'], + 'allowed-in-preconfig': true } =20 ## # @X86CPURegister32: diff --git a/qapi/run-state.json b/qapi/run-state.json index 9694a9f..d6ed5d8 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -94,7 +94,8 @@ # "status": "running" } } # ## -{ 'command': 'query-status', 'returns': 'StatusInfo' } +{ 'command': 'query-status', 'returns': 'StatusInfo', + 'allowed-in-preconfig': true } =20 ## # @SHUTDOWN: diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 0c5da3a..9975d95 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -193,13 +193,16 @@ out: return ret =20 =20 -def gen_register_command(name, success_response, allow_oob): +def gen_register_command(name, success_response, allow_oob, + allowed_in_preconfig): options =3D [] =20 if not success_response: options +=3D ['QCO_NO_SUCCESS_RESP'] if allow_oob: options +=3D ['QCO_ALLOW_OOB'] + if allowed_in_preconfig: + options +=3D ['QCO_ALLOWED_IN_PRECONFIG'] =20 if not options: options =3D ['QCO_NO_OPTIONS'] @@ -275,8 +278,8 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); c_prefix=3Dc_name(self._prefix, protect=3DFalse))) genc.add(gen_registry(self._regy, self._prefix)) =20 - def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed, allow_oob): + def visit_command(self, name, info, arg_type, ret_type, gen, + success_response, boxed, allow_oob, allowed_in_preco= nfig): if not gen: return self._genh.add(gen_command_decl(name, arg_type, boxed, ret_type)) @@ -285,7 +288,8 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); self._genc.add(gen_marshal_output(ret_type)) self._genh.add(gen_marshal_decl(name)) self._genc.add(gen_marshal(name, arg_type, boxed, ret_type)) - self._regy +=3D gen_register_command(name, success_response, allow= _oob) + self._regy +=3D gen_register_command(name, success_response, allow= _oob, + allowed_in_preconfig) =20 =20 def gen_commands(schema, output_dir, prefix): diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 3e14bc4..87273a2 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -872,7 +872,8 @@ def check_keys(expr_elem, meta, required, optional=3D[]= ): raise QAPISemError(info, "'%s' of %s '%s' should only use false valu= e" % (key, meta, name)) - if (key =3D=3D 'boxed' or key =3D=3D 'allow-oob') and value is not= True: + if (key =3D=3D 'boxed' or key =3D=3D 'allow-oob' or + key =3D=3D 'allowed-in-preconfig') and value is not True: raise QAPISemError(info, "'%s' of %s '%s' should only use true value" % (key, meta, name)) @@ -922,7 +923,7 @@ def check_exprs(exprs): meta =3D 'command' check_keys(expr_elem, 'command', [], ['data', 'returns', 'gen', 'success-response', - 'boxed', 'allow-oob']) + 'boxed', 'allow-oob', 'allowed-in-preconfig']) elif 'event' in expr: meta =3D 'event' check_keys(expr_elem, 'event', [], ['data', 'boxed']) @@ -1044,8 +1045,8 @@ class QAPISchemaVisitor(object): def visit_alternate_type(self, name, info, variants): pass =20 - def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed, allow_oob): + def visit_command(self, name, info, arg_type, ret_type, gen, + success_response, boxed, allow_oob, allowed_in_preco= nfig): pass =20 def visit_event(self, name, info, arg_type, boxed): @@ -1422,7 +1423,7 @@ class QAPISchemaAlternateType(QAPISchemaType): =20 class QAPISchemaCommand(QAPISchemaEntity): def __init__(self, name, info, doc, arg_type, ret_type, - gen, success_response, boxed, allow_oob): + gen, success_response, boxed, allow_oob, allowed_in_preco= nfig): QAPISchemaEntity.__init__(self, name, info, doc) assert not arg_type or isinstance(arg_type, str) assert not ret_type or isinstance(ret_type, str) @@ -1434,6 +1435,7 @@ class QAPISchemaCommand(QAPISchemaEntity): self.success_response =3D success_response self.boxed =3D boxed self.allow_oob =3D allow_oob + self.allowed_in_preconfig =3D allowed_in_preconfig =20 def check(self, schema): if self._arg_type_name: @@ -1458,7 +1460,8 @@ class QAPISchemaCommand(QAPISchemaEntity): visitor.visit_command(self.name, self.info, self.arg_type, self.ret_type, self.gen, self.success_response, - self.boxed, self.allow_oob) + self.boxed, self.allow_oob, + self.allowed_in_preconfig) =20 =20 class QAPISchemaEvent(QAPISchemaEntity): @@ -1678,6 +1681,7 @@ class QAPISchema(object): success_response =3D expr.get('success-response', True) boxed =3D expr.get('boxed', False) allow_oob =3D expr.get('allow-oob', False) + allowed_in_preconfig =3D expr.get('allowed-in-preconfig', False) if isinstance(data, OrderedDict): data =3D self._make_implicit_object_type( name, info, doc, 'arg', self._make_members(data, info)) @@ -1686,7 +1690,8 @@ class QAPISchema(object): rets =3D self._make_array_type(rets[0], info) self._def_entity(QAPISchemaCommand(name, info, doc, data, rets, gen, success_response, - boxed, allow_oob)) + boxed, allow_oob, + allowed_in_preconfig)) =20 def _def_event(self, expr, info, doc): name =3D expr['event'] diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index 9b312b2..cb6f2e1 100644 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -226,8 +226,8 @@ class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVis= itor): name=3Ddoc.symbol, body=3Dtexi_entity(doc, 'Members'))) =20 - def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed, allow_oob): + def visit_command(self, name, info, arg_type, ret_type, gen, + success_response, boxed, allow_oob, allowed_in_preco= nfig): doc =3D self.cur_doc if boxed: body =3D texi_body(doc) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index f9e67e8..5246be1 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -171,14 +171,15 @@ const QLitObject %(c_name)s =3D %(c_string)s; {'members': [{'type': self._use_type(m.type)} for m in variants.variants]}) =20 - def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed, allow_oob): + def visit_command(self, name, info, arg_type, ret_type, gen, + success_response, boxed, allow_oob, allowed_in_preco= nfig): arg_type =3D arg_type or self._schema.the_empty_object_type ret_type =3D ret_type or self._schema.the_empty_object_type self._gen_qlit(name, 'command', {'arg-type': self._use_type(arg_type), 'ret-type': self._use_type(ret_type), - 'allow-oob': allow_oob}) + 'allow-oob': allow_oob, + 'allowed-in-preconfig': allowed_in_preconfig}) =20 def visit_event(self, name, info, arg_type, boxed): arg_type =3D arg_type or self._schema.the_empty_object_type diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index c1a144b..73d2c77 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -41,8 +41,8 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): print('alternate %s' % name) self._print_variants(variants) =20 - def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed, allow_oob): + def visit_command(self, name, info, arg_type, ret_type, gen, + success_response, boxed, allow_oob, allowed_in_preco= nfig): print('command %s %s -> %s' % \ (name, arg_type and arg_type.name, ret_type and ret_type.nam= e)) print(' gen=3D%s success_response=3D%s boxed=3D%s oob=3D%s' % \ --=20 2.7.4 From nobody Mon Apr 29 07:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522919519878509.94685961720245; Thu, 5 Apr 2018 02:11:59 -0700 (PDT) Received: from localhost ([::1]:41634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40w2-0004cp-U2 for importer@patchew.org; Thu, 05 Apr 2018 05:11:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40qn-0000o2-4t for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f40qj-0006W9-Vz for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:33 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60706 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f40qj-0006Vi-QU for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB183722F2 for ; Thu, 5 Apr 2018 09:06:28 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 302002024CA4; Thu, 5 Apr 2018 09:06:28 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 11:05:08 +0200 Message-Id: <1522919113-158775-7-git-send-email-imammedo@redhat.com> In-Reply-To: <1522919113-158775-1-git-send-email-imammedo@redhat.com> References: <1522919113-158775-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 05 Apr 2018 09:06:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 05 Apr 2018 09:06:28 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.13 v5 06/11] tests: let qapi-schema tests detect allowed-in-preconfig X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkrempa@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" use new allowed-in-preconfig parameter in tests. Signed-off-by: Igor Mammedov --- tests/qapi-schema/doc-good.out | 4 ++-- tests/qapi-schema/ident-with-escape.out | 2 +- tests/qapi-schema/indented-expr.out | 4 ++-- tests/qapi-schema/qapi-schema-test.out | 20 ++++++++++---------- tests/qapi-schema/test-qapi.py | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 63058b1..9c8a483 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -28,9 +28,9 @@ object q_obj_cmd-arg member arg2: str optional=3DTrue member arg3: bool optional=3DFalse command cmd q_obj_cmd-arg -> Object - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse command cmd-boxed Object -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse doc freeform body=3D =3D Section diff --git a/tests/qapi-schema/ident-with-escape.out b/tests/qapi-schema/id= ent-with-escape.out index 82213aa..24c976f 100644 --- a/tests/qapi-schema/ident-with-escape.out +++ b/tests/qapi-schema/ident-with-escape.out @@ -5,4 +5,4 @@ module ident-with-escape.json object q_obj_fooA-arg member bar1: str optional=3DFalse command fooA q_obj_fooA-arg -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indent= ed-expr.out index 862678f..bd8a486 100644 --- a/tests/qapi-schema/indented-expr.out +++ b/tests/qapi-schema/indented-expr.out @@ -3,6 +3,6 @@ enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'q= list', 'qbool'] prefix QTYPE module indented-expr.json command eins None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse command zwei None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 467577d..1f5038f 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -16,7 +16,7 @@ object Empty1 object Empty2 base Empty1 command user_def_cmd0 Empty2 -> Empty2 - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse enum QEnumTwo ['value1', 'value2'] prefix QENUM_TWO object UserDefOne @@ -143,31 +143,31 @@ object UserDefNativeListUnion case sizes: q_obj_sizeList-wrapper case any: q_obj_anyList-wrapper command user_def_cmd None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse object q_obj_user_def_cmd1-arg member ud1a: UserDefOne optional=3DFalse command user_def_cmd1 q_obj_user_def_cmd1-arg -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse object q_obj_user_def_cmd2-arg member ud1a: UserDefOne optional=3DFalse member ud1b: UserDefOne optional=3DTrue command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse object q_obj_guest-get-time-arg member a: int optional=3DFalse member b: int optional=3DTrue command guest-get-time q_obj_guest-get-time-arg -> int - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse object q_obj_guest-sync-arg member arg: any optional=3DFalse command guest-sync q_obj_guest-sync-arg -> any - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse command boxed-struct UserDefZero -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse command boxed-union UserDefNativeListUnion -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse command an-oob-command None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DTrue + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DTrue preconfig= =3DFalse object UserDefOptions member i64: intList optional=3DTrue member u64: uint64List optional=3DTrue @@ -231,4 +231,4 @@ object q_obj___org.qemu_x-command-arg member c: __org.qemu_x-Union2 optional=3DFalse member d: __org.qemu_x-Alt optional=3DFalse command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> __org.qemu_= x-Union1 - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DFalse diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index 73d2c77..f0ff701 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -45,8 +45,8 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): success_response, boxed, allow_oob, allowed_in_preco= nfig): print('command %s %s -> %s' % \ (name, arg_type and arg_type.name, ret_type and ret_type.nam= e)) - print(' gen=3D%s success_response=3D%s boxed=3D%s oob=3D%s' % \ - (gen, success_response, boxed, allow_oob)) + print(' gen=3D%s success_response=3D%s boxed=3D%s oob=3D%s preco= nfig=3D%s' % \ + (gen, success_response, boxed, allow_oob, allowed_in_preconf= ig)) =20 def visit_event(self, name, info, arg_type, boxed): print('event %s %s' % (name, arg_type and arg_type.name)) --=20 2.7.4 From nobody Mon Apr 29 07:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522919515276294.1209543598478; Thu, 5 Apr 2018 02:11:55 -0700 (PDT) Received: from localhost ([::1]:41633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40vr-0004UY-Br for importer@patchew.org; Thu, 05 Apr 2018 05:11:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40qn-0000o5-5Q for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f40qk-0006We-Fd for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:33 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51484 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f40qk-0006WV-Ac for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA7CC4023150 for ; Thu, 5 Apr 2018 09:06:29 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F1742024CA4; Thu, 5 Apr 2018 09:06:29 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 11:05:09 +0200 Message-Id: <1522919113-158775-8-git-send-email-imammedo@redhat.com> In-Reply-To: <1522919113-158775-1-git-send-email-imammedo@redhat.com> References: <1522919113-158775-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:29 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.13 v5 07/11] tests: add allowed-in-preconfig-test for qapi-schema X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkrempa@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" make sure the QAPISchema can parse allowed-in-preconfig correctly Signed-off-by: Igor Mammedov --- tests/Makefile.include | 1 + tests/qapi-schema/allowed-in-preconfig-test.err | 1 + tests/qapi-schema/allowed-in-preconfig-test.exit | 1 + tests/qapi-schema/allowed-in-preconfig-test.json | 2 ++ tests/qapi-schema/allowed-in-preconfig-test.out | 0 tests/qapi-schema/qapi-schema-test.json | 3 +++ tests/qapi-schema/qapi-schema-test.out | 2 ++ tests/test-qmp-cmds.c | 4 ++++ 8 files changed, 14 insertions(+) create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.err create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.exit create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.json create mode 100644 tests/qapi-schema/allowed-in-preconfig-test.out diff --git a/tests/Makefile.include b/tests/Makefile.include index 3b9a5e3..4d2460d 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -524,6 +524,7 @@ qapi-schema +=3D missing-type.json qapi-schema +=3D nested-struct-data.json qapi-schema +=3D non-objects.json qapi-schema +=3D oob-test.json +qapi-schema +=3D allowed-in-preconfig-test.json qapi-schema +=3D pragma-doc-required-crap.json qapi-schema +=3D pragma-extra-junk.json qapi-schema +=3D pragma-name-case-whitelist-crap.json diff --git a/tests/qapi-schema/allowed-in-preconfig-test.err b/tests/qapi-s= chema/allowed-in-preconfig-test.err new file mode 100644 index 0000000..2b0511b --- /dev/null +++ b/tests/qapi-schema/allowed-in-preconfig-test.err @@ -0,0 +1 @@ +tests/qapi-schema/allowed-in-preconfig-test.json:2: 'allowed-in-preconfig'= of command 'allowed-in-preconfig-test' should only use true value diff --git a/tests/qapi-schema/allowed-in-preconfig-test.exit b/tests/qapi-= schema/allowed-in-preconfig-test.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/qapi-schema/allowed-in-preconfig-test.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/allowed-in-preconfig-test.json b/tests/qapi-= schema/allowed-in-preconfig-test.json new file mode 100644 index 0000000..7e0e6cb --- /dev/null +++ b/tests/qapi-schema/allowed-in-preconfig-test.json @@ -0,0 +1,2 @@ +# Check against allowed-in-preconfig illegal value +{ 'command': 'allowed-in-preconfig-test', 'allowed-in-preconfig': 'some-st= ring' } diff --git a/tests/qapi-schema/allowed-in-preconfig-test.out b/tests/qapi-s= chema/allowed-in-preconfig-test.out new file mode 100644 index 0000000..e69de29 diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 06e30f4..608ca35 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -142,6 +142,9 @@ # Smoke test on Out-Of-Band { 'command': 'an-oob-command', 'allow-oob': true } =20 +# test allowed-in-preconfig flag +{ 'command': 'allowed-in-preconfig-test', 'allowed-in-preconfig': true } + # For testing integer range flattening in opts-visitor. The following sche= ma # corresponds to the option format: # diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 1f5038f..c955e2d 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -168,6 +168,8 @@ command boxed-union UserDefNativeListUnion -> None gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse command an-oob-command None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DTrue preconfig= =3DFalse +command allowed-in-preconfig-test None -> None + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DFalse preconfig= =3DTrue object UserDefOptions member i64: intList optional=3DTrue member u64: uint64List optional=3DTrue diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index db690cc..730476a 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -20,6 +20,10 @@ void qmp_an_oob_command(Error **errp) { } =20 +void qmp_allowed_in_preconfig_test(Error **errp) +{ +} + Empty2 *qmp_user_def_cmd0(Error **errp) { return g_new0(Empty2, 1); --=20 2.7.4 From nobody Mon Apr 29 07:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 152291951085017.13772634349914; Thu, 5 Apr 2018 02:11:50 -0700 (PDT) Received: from localhost ([::1]:41632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40vo-0004UF-UA for importer@patchew.org; Thu, 05 Apr 2018 05:11:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40qp-0000oe-7d for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f40ql-0006X0-DC for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60708 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f40ql-0006Wp-9M for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E917B722EA for ; Thu, 5 Apr 2018 09:06:30 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E0922024CA4; Thu, 5 Apr 2018 09:06:30 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 11:05:10 +0200 Message-Id: <1522919113-158775-9-git-send-email-imammedo@redhat.com> In-Reply-To: <1522919113-158775-1-git-send-email-imammedo@redhat.com> References: <1522919113-158775-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 05 Apr 2018 09:06:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 05 Apr 2018 09:06:30 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.13 v5 08/11] tests: extend qmp test with preconfig checks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkrempa@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add permission checks for commands at 'preconfig' stage. Signed-off-by: Igor Mammedov --- v5: * s/-preconfig/--preconfig/ v4: * s/is_err()/qmp_rsp_is_err()/ * return true even if 'error' doesn't contain 'desc' (Eric Blake ) --- tests/qmp-test.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 772058f..8bba913 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -392,6 +392,49 @@ static void add_query_tests(QmpSchema *schema) } } =20 +static bool qmp_rsp_is_err(QDict *rsp) +{ + QDict *error =3D qdict_get_qdict(rsp, "error"); + QDECREF(rsp); + return !!error; +} + +static void test_qmp_preconfig(void) +{ + QDict *rsp, *ret; + QTestState *qs =3D qtest_startf("%s --preconfig", common_args); + + /* preconfig state */ + /* enabled commands, no error expected */ + g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'query-commands' = }"))); + + /* forbidden commands, expected error */ + g_assert(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }"))); + + /* check that query-status returns preconfig state */ + rsp =3D qtest_qmp(qs, "{ 'execute': 'query-status' }"); + ret =3D qdict_get_qdict(rsp, "return"); + g_assert(ret); + g_assert_cmpstr(qdict_get_try_str(ret, "status"), =3D=3D, "preconfig"); + QDECREF(rsp); + + /* exit preconfig state */ + g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'cont' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + /* check that query-status returns running state */ + rsp =3D qtest_qmp(qs, "{ 'execute': 'query-status' }"); + ret =3D qdict_get_qdict(rsp, "return"); + g_assert(ret); + g_assert_cmpstr(qdict_get_try_str(ret, "status"), =3D=3D, "running"); + QDECREF(rsp); + + /* enabled commands, no error expected */ + g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }"))= ); + + qtest_quit(qs); +} + int main(int argc, char *argv[]) { QmpSchema schema; @@ -403,6 +446,7 @@ int main(int argc, char *argv[]) qtest_add_func("qmp/oob", test_qmp_oob); qmp_schema_init(&schema); add_query_tests(&schema); + qtest_add_func("qmp/preconfig", test_qmp_preconfig); =20 ret =3D g_test_run(); =20 --=20 2.7.4 From nobody Mon Apr 29 07:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522919692999442.6449154564484; Thu, 5 Apr 2018 02:14:52 -0700 (PDT) Received: from localhost ([::1]:41670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40yk-0006tx-RY for importer@patchew.org; Thu, 05 Apr 2018 05:14:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40qn-0000oD-H1 for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f40qm-0006XW-DG for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:33 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51486 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f40qm-0006XL-8P for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:32 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7A384023150 for ; Thu, 5 Apr 2018 09:06:31 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CC6D2024CA4; Thu, 5 Apr 2018 09:06:31 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 11:05:11 +0200 Message-Id: <1522919113-158775-10-git-send-email-imammedo@redhat.com> In-Reply-To: <1522919113-158775-1-git-send-email-imammedo@redhat.com> References: <1522919113-158775-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:31 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.13 v5 09/11] qmp: permit query-hotpluggable-cpus in preconfig state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkrempa@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" it will allow mgmt to query possible CPUs, which depends on used machine(version)/-smp options, without restarting QEMU and use results to configure numa mapping or adding CPUs with device_add* later. Signed-off-by: Igor Mammedov PS: *) device_add is not allowed to run at preconfig in this series but later it could be dealt with by injecting -device in preconfig state and letting existing -device handling to actually plug devices --- qapi/misc.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qapi/misc.json b/qapi/misc.json index 579900f..65cb56b 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -3228,7 +3228,8 @@ # ]} # ## -{ 'command': 'query-hotpluggable-cpus', 'returns': ['HotpluggableCPU'] } +{ 'command': 'query-hotpluggable-cpus', 'returns': ['HotpluggableCPU'], + 'allowed-in-preconfig': true } =20 ## # @GuidInfo: --=20 2.7.4 From nobody Mon Apr 29 07:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522919701249333.07981253914795; Thu, 5 Apr 2018 02:15:01 -0700 (PDT) Received: from localhost ([::1]:41673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40yy-00074f-CW for importer@patchew.org; Thu, 05 Apr 2018 05:15:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40qt-0000sE-3a for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f40qn-0006YE-BE for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:39 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51488 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f40qn-0006Xh-5f for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8B7A4023150 for ; Thu, 5 Apr 2018 09:06:32 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B7A02024CA4; Thu, 5 Apr 2018 09:06:32 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 11:05:12 +0200 Message-Id: <1522919113-158775-11-git-send-email-imammedo@redhat.com> In-Reply-To: <1522919113-158775-1-git-send-email-imammedo@redhat.com> References: <1522919113-158775-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:32 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.13 v5 10/11] qmp: add set-numa-node command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkrempa@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Command is allowed to run only in preconfig stage and will allow to configure numa mapping for CPUs depending on possible CPUs layout (query-hotpluggable-cpus) for given machine instance. Signed-off-by: Igor Mammedov --- numa.c | 5 +++++ qapi/misc.json | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/numa.c b/numa.c index 11cae25..e6d4363 100644 --- a/numa.c +++ b/numa.c @@ -444,6 +444,11 @@ void parse_numa_opts(MachineState *ms) } } =20 +void qmp_set_numa_node(NumaOptions *cmd, Error **errp) +{ + set_numa_options(MACHINE(qdev_get_machine()), cmd, errp); +} + void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **er= rp) { int node_id =3D object_property_get_int(OBJECT(dev), "node-id", &error= _abort); diff --git a/qapi/misc.json b/qapi/misc.json index 65cb56b..72f57d6 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -3453,3 +3453,17 @@ ## { 'command': 'x-oob-test', 'data' : { 'lock': 'bool' }, 'allow-oob': true } + +## +# @set-numa-node: +# +# Runtime equivalent of '-numa' CLI option, available at +# preconfigure stage to configure numa mapping before initializing +# machine. +# +# Since 2.13 +## +{ 'command': 'set-numa-node', 'boxed': true, + 'data': 'NumaOptions', + 'allowed-in-preconfig': true +} --=20 2.7.4 From nobody Mon Apr 29 07:11:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522919895106373.54062240044516; Thu, 5 Apr 2018 02:18:15 -0700 (PDT) Received: from localhost ([::1]:42047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f411y-0001KA-7q for importer@patchew.org; Thu, 05 Apr 2018 05:18:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f40qp-0000ou-JX for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f40qo-0006Yn-9y for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51492 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f40qo-0006Yd-5L for qemu-devel@nongnu.org; Thu, 05 Apr 2018 05:06:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C78EB4023150 for ; Thu, 5 Apr 2018 09:06:33 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C5B82024CA4; Thu, 5 Apr 2018 09:06:32 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 11:05:13 +0200 Message-Id: <1522919113-158775-12-git-send-email-imammedo@redhat.com> In-Reply-To: <1522919113-158775-1-git-send-email-imammedo@redhat.com> References: <1522919113-158775-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 05 Apr 2018 09:06:33 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-2.13 v5 11/11] tests: functional tests for QMP command set-numa-node X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pkrempa@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" * start QEMU with 2 unmapped cpus, * while in preconfig state * add 2 numa nodes * assign cpus to them * exit preconfig and in running state check that cpus are mapped correctly. Signed-off-by: Igor Mammedov --- v5: * s/qobject_to_qdict(/qobject_to(QDict,/ * s/-preconfig/--preconfig/ v4: * drop duplicate is_err() and reuse qmp_rsp_is_err() wich is moved to generic file libqtest.c. (Eric Blake ) FIXUP! tests: functional tests for QMP command set-numa-node --- tests/libqtest.h | 9 ++++++++ tests/libqtest.c | 7 +++++++ tests/numa-test.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qmp-test.c | 7 ------- 4 files changed, 77 insertions(+), 7 deletions(-) diff --git a/tests/libqtest.h b/tests/libqtest.h index cbe8df4..ac52872 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -972,4 +972,13 @@ void qtest_qmp_device_add(const char *driver, const ch= ar *id, const char *fmt, */ void qtest_qmp_device_del(const char *id); =20 +/** + * qmp_rsp_is_err: + * @rsp: QMP response to check for error + * + * Test @rsp for error and discard @rsp. + * Returns 'true' if there is error in @rsp and 'false' otherwise. + */ +bool qmp_rsp_is_err(QDict *rsp); + #endif diff --git a/tests/libqtest.c b/tests/libqtest.c index 6f33a37..33426d5 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1098,3 +1098,10 @@ void qtest_qmp_device_del(const char *id) QDECREF(response1); QDECREF(response2); } + +bool qmp_rsp_is_err(QDict *rsp) +{ + QDict *error =3D qdict_get_qdict(rsp, "error"); + QDECREF(rsp); + return !!error; +} diff --git a/tests/numa-test.c b/tests/numa-test.c index 0f861d8..5e4460d 100644 --- a/tests/numa-test.c +++ b/tests/numa-test.c @@ -260,6 +260,66 @@ static void aarch64_numa_cpu(const void *data) g_free(cli); } =20 +static void pc_dynamic_cpu_cfg(const void *data) +{ + QObject *e; + QDict *resp; + QList *cpus; + QTestState *qs; + + qs =3D qtest_startf("%s %s", data ? (char *)data : "", + "-nodefaults --preconfig -smp 2"); + + /* create 2 numa nodes */ + g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," + " 'arguments': { 'type': 'node', 'nodeid': 0 } }"))); + g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," + " 'arguments': { 'type': 'node', 'nodeid': 1 } }"))); + + /* map 2 cpus in non default reverse order + * i.e socket1->node0, socket0->node1 + */ + g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," + " 'arguments': { 'type': 'cpu', 'node-id': 0, 'socket-id': 1 } }")= )); + g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," + " 'arguments': { 'type': 'cpu', 'node-id': 1, 'socket-id': 0 } }")= )); + + /* let machine initialization to complete and run */ + g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'cont' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + /* check that CPUs are mapped as expected */ + resp =3D qtest_qmp(qs, "{ 'execute': 'query-hotpluggable-cpus'}"); + g_assert(qdict_haskey(resp, "return")); + cpus =3D qdict_get_qlist(resp, "return"); + g_assert(cpus); + while ((e =3D qlist_pop(cpus))) { + const QDict *cpu, *props; + int64_t socket, node; + + cpu =3D qobject_to(QDict, e); + g_assert(qdict_haskey(cpu, "props")); + props =3D qdict_get_qdict(cpu, "props"); + + g_assert(qdict_haskey(props, "node-id")); + node =3D qdict_get_int(props, "node-id"); + g_assert(qdict_haskey(props, "socket-id")); + socket =3D qdict_get_int(props, "socket-id"); + + if (socket =3D=3D 0) { + g_assert_cmpint(node, =3D=3D, 1); + } else if (socket =3D=3D 1) { + g_assert_cmpint(node, =3D=3D, 0); + } else { + g_assert(false); + } + qobject_decref(e); + } + QDECREF(resp); + + qtest_quit(qs); +} + int main(int argc, char **argv) { const char *args =3D NULL; @@ -278,6 +338,7 @@ int main(int argc, char **argv) =20 if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64")) { qtest_add_data_func("/numa/pc/cpu/explicit", args, pc_numa_cpu); + qtest_add_data_func("/numa/pc/dynamic/cpu", args, pc_dynamic_cpu_c= fg); } =20 if (!strcmp(arch, "ppc64")) { diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 8bba913..00bd9ae 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -392,13 +392,6 @@ static void add_query_tests(QmpSchema *schema) } } =20 -static bool qmp_rsp_is_err(QDict *rsp) -{ - QDict *error =3D qdict_get_qdict(rsp, "error"); - QDECREF(rsp); - return !!error; -} - static void test_qmp_preconfig(void) { QDict *rsp, *ret; --=20 2.7.4