From nobody Fri Oct 24 09:43:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518784865117803.6138188727634; Fri, 16 Feb 2018 04:41:05 -0800 (PST) Received: from localhost ([::1]:44468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfK4-0005sP-9j for importer@patchew.org; Fri, 16 Feb 2018 07:41:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfHx-0004Hz-GB for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emfHv-0003X5-J2 for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:53 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45236 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 1emfHv-0003Wt-E8 for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:51 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0028C8424C; Fri, 16 Feb 2018 12:38:51 +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 ABF3EAF027; Fri, 16 Feb 2018 12:38:49 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 13:37:13 +0100 Message-Id: <1518784641-43151-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1518784641-43151-1-git-send-email-imammedo@redhat.com> References: <1518784641-43151-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Feb 2018 12:38:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Feb 2018 12:38:51 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 v3 1/9] 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: peter.maydell@linaro.org, pkrempa@redhat.com, ehabkost@redhat.com, cohuck@redhat.com, armbru@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au 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 --- 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 5d44583..7d014b0 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -715,7 +715,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; @@ -770,7 +770,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 7e0e789..1b2820a 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 Fri Oct 24 09:43:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518785045643462.6887557080256; Fri, 16 Feb 2018 04:44:05 -0800 (PST) Received: from localhost ([::1]:44484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfMv-0008Fr-8w for importer@patchew.org; Fri, 16 Feb 2018 07:44:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfHy-0004Ih-1v for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emfHx-0003Y8-2m for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:54 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45242 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 1emfHw-0003Xv-Td for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:53 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D06984221; Fri, 16 Feb 2018 12:38:52 +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 3322BAF027; Fri, 16 Feb 2018 12:38:51 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 13:37:14 +0100 Message-Id: <1518784641-43151-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1518784641-43151-1-git-send-email-imammedo@redhat.com> References: <1518784641-43151-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Feb 2018 12:38:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Feb 2018 12:38:52 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 v3 2/9] numa: split out NumaOptions parsing into parse_NumaOptions() 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: peter.maydell@linaro.org, pkrempa@redhat.com, ehabkost@redhat.com, cohuck@redhat.com, armbru@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au 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 parse_NumaOptions() for parsing configuration commands received via QMP interface Signed-off-by: Igor Mammedov --- include/sysemu/numa.h | 1 + numa.c | 48 +++++++++++++++++++++++++++++------------------- 2 files changed, 30 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 1b2820a..04e34eb 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 parse_NumaOptions(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,33 @@ static int parse_numa(void *opaque, QemuOpts *opts, Er= ror **errp) } =20 end: + if (err) { + 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); + } + + parse_NumaOptions(ms, object, &err); + +end: qapi_free_NumaOptions(object); if (err) { error_report_err(err); --=20 2.7.4 From nobody Fri Oct 24 09:43:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518784868138851.5853995454482; Fri, 16 Feb 2018 04:41:08 -0800 (PST) Received: from localhost ([::1]:44469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfK7-0005uq-5x for importer@patchew.org; Fri, 16 Feb 2018 07:41:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfHz-0004KX-WC for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emfHy-0003Z7-In for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:56 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39374 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 1emfHy-0003Yy-Dn for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:54 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 01DDCEAE91; Fri, 16 Feb 2018 12:38:54 +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 AE657B07B7; Fri, 16 Feb 2018 12:38:52 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 13:37:15 +0100 Message-Id: <1518784641-43151-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1518784641-43151-1-git-send-email-imammedo@redhat.com> References: <1518784641-43151-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 16 Feb 2018 12:38:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 16 Feb 2018 12:38:54 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 v3 3/9] 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: peter.maydell@linaro.org, pkrempa@redhat.com, ehabkost@redhat.com, cohuck@redhat.com, armbru@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au 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" Option allows to pause QEMU at new RUN_STATE_PRECONFIG time, which would allow to configure QEMU from QMP before machine jumps into board initialization code machine_run_board_init(). Intent is to allow management to query machine state and additionally configure it using previous query results within one QEMU instance (i.e. eliminate need to start QEMU twice, 1st to query board specific parameters and 2nd for for actual VM start using query result for additional parameters). Initially it's planned to be used for configuring numa topology depending on cpu layout. Signed-off-by: Igor Mammedov --- include/sysemu/sysemu.h | 1 + qapi/run-state.json | 3 ++- qemu-options.hx | 11 +++++++++++ qmp.c | 5 +++++ vl.c | 35 ++++++++++++++++++++++++++++++++++- 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 77bb3da..99d1aad 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -64,6 +64,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/run-state.json b/qapi/run-state.json index bca46a8..d24a4e8 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -49,12 +49,13 @@ # @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 machine is created. ## { '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 5050a49..ed0b4b7 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3283,6 +3283,17 @@ 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 machine is created, +which allows to query and configure properties affecting machine +initialization. Use QMP command 'cont' to exit paused state. +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 793f6f3..2c6e147 100644 --- a/qmp.c +++ b/qmp.c @@ -164,6 +164,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 7a5554b..7fc133d 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,9 @@ typedef struct { =20 static const RunStateTransition runstate_transitions_def[] =3D { /* from -> to */ + { RUN_STATE_PRECONFIG, RUN_STATE_PRELAUNCH }, + { 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 +1633,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 +1718,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. */ @@ -1880,6 +1889,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); } @@ -3701,6 +3717,14 @@ int main(int argc, char **argv, char **envp) exit(1); } break; + case QEMU_OPTION_preconfig: + if (runstate_check(RUN_STATE_INMIGRATE)) { + error_report("option can not be used with " + "-incoming option"); + exit(EXIT_FAILURE); + } + 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); @@ -3908,6 +3932,11 @@ int main(int argc, char **argv, char **envp) } break; case QEMU_OPTION_incoming: + if (!preconfig_exit_requested) { + error_report("option can not be used with " + "-preconfig option"); + exit(EXIT_FAILURE); + } if (!incoming) { runstate_set(RUN_STATE_INMIGRATE); } @@ -4607,6 +4636,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 Fri Oct 24 09:43:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518785114091995.5584133371472; Fri, 16 Feb 2018 04:45:14 -0800 (PST) Received: from localhost ([::1]:44489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfO5-0000q0-AI for importer@patchew.org; Fri, 16 Feb 2018 07:45:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfI0-0004LI-RK for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emfI0-0003Zf-1d for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:56 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45248 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 1emfHz-0003ZW-To for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:55 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CB417D85D; Fri, 16 Feb 2018 12:38:55 +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 34C90F41C4; Fri, 16 Feb 2018 12:38:54 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 13:37:16 +0100 Message-Id: <1518784641-43151-5-git-send-email-imammedo@redhat.com> In-Reply-To: <1518784641-43151-1-git-send-email-imammedo@redhat.com> References: <1518784641-43151-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Feb 2018 12:38:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Feb 2018 12:38:55 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 v3 4/9] 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: peter.maydell@linaro.org, pkrempa@redhat.com, ehabkost@redhat.com, cohuck@redhat.com, armbru@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au 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 --- --- monitor.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/monitor.c b/monitor.c index f499250..fcb5386 100644 --- a/monitor.c +++ b/monitor.c @@ -3097,6 +3097,10 @@ 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 precofig state\n"); + } + cmd =3D monitor_parse_command(mon, cmdline, &cmdline, mon->cmd_table); if (!cmd) { return; --=20 2.7.4 From nobody Fri Oct 24 09:43:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151878527027736.64135568028598; Fri, 16 Feb 2018 04:47:50 -0800 (PST) Received: from localhost ([::1]:44865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfQb-0003E8-Cx for importer@patchew.org; Fri, 16 Feb 2018 07:47:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfI4-0004Qe-GP for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emfI1-0003aG-O1 for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:00 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39380 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 1emfI1-0003a5-Hd for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:57 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FA8FEAE91; Fri, 16 Feb 2018 12:38:57 +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 AFF20B07B7; Fri, 16 Feb 2018 12:38:55 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 13:37:17 +0100 Message-Id: <1518784641-43151-6-git-send-email-imammedo@redhat.com> In-Reply-To: <1518784641-43151-1-git-send-email-imammedo@redhat.com> References: <1518784641-43151-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 16 Feb 2018 12:38:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 16 Feb 2018 12:38:57 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 v3 5/9] QAPI: allow to specify valid runstates per 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: peter.maydell@linaro.org, pkrempa@redhat.com, ehabkost@redhat.com, cohuck@redhat.com, armbru@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au 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 optional 'runstates' parameter in QAPI command definition, which will permit to specify RunState variations in which a command could be exectuted via QMP monitor. For compatibility reasons, commands, that don't use 'runstates' explicitly, are not permited to run in preconfig state but allowed in all other states. New option will be used to allow commands, which are prepared/need to run this early, to run in preconfig state. It will include query-hotpluggable-cpus and new set-numa-node commands. Other commands that should be able to run in preconfig state, should be ammeded to not expect machine in initialized state. Signed-off-by: Igor Mammedov --- include/qapi/qmp/dispatch.h | 5 +++- monitor.c | 28 +++++++++++++++++--- qapi-schema.json | 12 +++++++-- qapi/qmp-dispatch.c | 39 ++++++++++++++++++++++++++++ qapi/qmp-registry.c | 4 ++- qapi/run-state.json | 6 ++++- scripts/qapi-commands.py | 46 ++++++++++++++++++++++++++---= ---- scripts/qapi-introspect.py | 2 +- scripts/qapi.py | 15 +++++++---- scripts/qapi2texi.py | 2 +- 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 | 18 ++++++------- tests/qapi-schema/test-qapi.py | 6 ++--- 15 files changed, 151 insertions(+), 42 deletions(-) diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index 1e694b5..f821781 100644 --- a/include/qapi/qmp/dispatch.h +++ b/include/qapi/qmp/dispatch.h @@ -15,6 +15,7 @@ #define QAPI_QMP_DISPATCH_H =20 #include "qemu/queue.h" +#include "qapi-types.h" =20 typedef void (QmpCommandFunc)(QDict *, QObject **, Error **); =20 @@ -31,12 +32,14 @@ typedef struct QmpCommand QmpCommandOptions options; QTAILQ_ENTRY(QmpCommand) node; bool enabled; + const RunState *valid_runstates; } QmpCommand; =20 typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList; =20 void qmp_register_command(QmpCommandList *cmds, const char *name, - QmpCommandFunc *fn, QmpCommandOptions options); + QmpCommandFunc *fn, QmpCommandOptions options, + const RunState valid_runstates[]); void qmp_unregister_command(QmpCommandList *cmds, const char *name); QmpCommand *qmp_find_command(QmpCommandList *cmds, const char *name); QObject *qmp_dispatch(QmpCommandList *cmds, QObject *request); diff --git a/monitor.c b/monitor.c index fcb5386..2edc96c 100644 --- a/monitor.c +++ b/monitor.c @@ -224,6 +224,25 @@ static mon_cmd_t mon_cmds[]; static mon_cmd_t info_cmds[]; =20 QmpCommandList qmp_commands, qmp_cap_negotiation_commands; +const RunState cap_negotiation_valid_runstates[] =3D { + RUN_STATE_DEBUG, + RUN_STATE_INMIGRATE, + RUN_STATE_INTERNAL_ERROR, + RUN_STATE_IO_ERROR, + RUN_STATE_PAUSED, + RUN_STATE_POSTMIGRATE, + RUN_STATE_PRELAUNCH, + RUN_STATE_FINISH_MIGRATE, + RUN_STATE_RESTORE_VM, + RUN_STATE_RUNNING, + RUN_STATE_SAVE_VM, + RUN_STATE_SHUTDOWN, + RUN_STATE_SUSPENDED, + RUN_STATE_WATCHDOG, + RUN_STATE_GUEST_PANICKED, + RUN_STATE_COLO, + RUN_STATE_PRECONFIG, +}; =20 Monitor *cur_mon; =20 @@ -1016,17 +1035,18 @@ void monitor_init_qmp_commands(void) =20 qmp_register_command(&qmp_commands, "query-qmp-schema", qmp_query_qmp_schema, - QCO_NO_OPTIONS); + QCO_NO_OPTIONS, NULL); qmp_register_command(&qmp_commands, "device_add", qmp_device_add, - QCO_NO_OPTIONS); + QCO_NO_OPTIONS, NULL); qmp_register_command(&qmp_commands, "netdev_add", qmp_netdev_add, - QCO_NO_OPTIONS); + QCO_NO_OPTIONS, NULL); =20 qmp_unregister_commands_hack(); =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_NO_OPTIONS, + cap_negotiation_valid_runstates); } =20 void qmp_qmp_capabilities(Error **errp) diff --git a/qapi-schema.json b/qapi-schema.json index 0262b9f..ee1053d 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -219,7 +219,11 @@ # Note: This example has been shortened as the real response is too long. # ## -{ 'command': 'query-commands', 'returns': ['CommandInfo'] } +{ 'command': 'query-commands', 'returns': ['CommandInfo'], + 'runstates': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paus= ed', + 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm= ', + 'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', + 'guest-panicked', 'colo', 'preconfig' ] } =20 ## # @LostTickPolicy: @@ -1146,7 +1150,11 @@ # <- { "return": {} } # ## -{ 'command': 'cont' } +{ 'command': 'cont', + 'runstates': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paus= ed', + 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm= ', + 'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', + 'guest-panicked', 'colo', 'preconfig' ] } =20 ## # @system_wakeup: diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index e31ac4b..26cba19 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -17,6 +17,7 @@ #include "qapi/qmp/json-parser.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" +#include "sysemu/sysemu.h" =20 static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp) { @@ -65,6 +66,40 @@ static QDict *qmp_dispatch_check_obj(const QObject *requ= est, Error **errp) return dict; } =20 +static bool is_cmd_permited(const QmpCommand *cmd, Error **errp) +{ + int i; + char *list =3D NULL; + + /* Old commands that don't have explicit runstate in schema + * are permited to run except of at PRECONFIG stage + */ + if (!cmd->valid_runstates) { + if (runstate_check(RUN_STATE_PRECONFIG)) { + const char *state =3D RunState_str(RUN_STATE_PRECONFIG); + error_setg(errp, "The command '%s' isn't valid in '%s'", + cmd->name, state); + return false; + } + return true; + } + + for (i =3D 0; cmd->valid_runstates[i] !=3D RUN_STATE__MAX; i++) { + if (runstate_check(cmd->valid_runstates[i])) { + return true; + } + } + + for (i =3D 0; cmd->valid_runstates[i] !=3D RUN_STATE__MAX; i++) { + const char *state =3D RunState_str(cmd->valid_runstates[i]); + list =3D g_strjoin(", ", state, list, NULL); + } + error_setg(errp, "The command '%s' is valid only in '%s'", cmd->name, = list); + g_free(list); + + return false; +} + static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request, Error **errp) { @@ -92,6 +127,10 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, Q= Object *request, return NULL; } =20 + if (!is_cmd_permited(cmd, errp)) { + return NULL; + } + if (!qdict_haskey(dict, "arguments")) { args =3D qdict_new(); } else { diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c index 5af484c..59a5b85 100644 --- a/qapi/qmp-registry.c +++ b/qapi/qmp-registry.c @@ -16,7 +16,8 @@ #include "qapi/qmp/dispatch.h" =20 void qmp_register_command(QmpCommandList *cmds, const char *name, - QmpCommandFunc *fn, QmpCommandOptions options) + QmpCommandFunc *fn, QmpCommandOptions options, + const RunState valid_runstates[]) { QmpCommand *cmd =3D g_malloc0(sizeof(*cmd)); =20 @@ -24,6 +25,7 @@ void qmp_register_command(QmpCommandList *cmds, const cha= r *name, cmd->fn =3D fn; cmd->enabled =3D true; cmd->options =3D options; + cmd->valid_runstates =3D valid_runstates; QTAILQ_INSERT_TAIL(cmds, cmd, node); } =20 diff --git a/qapi/run-state.json b/qapi/run-state.json index d24a4e8..1c1c9b8 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -92,7 +92,11 @@ # "status": "running" } } # ## -{ 'command': 'query-status', 'returns': 'StatusInfo' } +{ 'command': 'query-status', 'returns': 'StatusInfo', + 'runstates': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paus= ed', + 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm= ', + 'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', + 'guest-panicked', 'colo', 'preconfig' ] } =20 ## # @SHUTDOWN: diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index f89d748..659e167 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -192,17 +192,45 @@ out: return ret =20 =20 -def gen_register_command(name, success_response): +def gen_register_command(name, success_response, runstates): options =3D 'QCO_NO_OPTIONS' if not success_response: options =3D 'QCO_NO_SUCCESS_RESP' =20 - ret =3D mcgen(''' - qmp_register_command(cmds, "%(name)s", - qmp_marshal_%(c_name)s, %(opts)s); -''', - name=3Dname, c_name=3Dc_name(name), - opts=3Doptions) + if runstates is None: + ret =3D mcgen(''' + qmp_register_command(cmds, "%(name)s", + qmp_marshal_%(c_name)s, %(opts)s, + NULL); + ''', + name=3Dname, c_name=3Dc_name(name), + opts=3Doptions) + else: + ret =3D mcgen(''' + static const RunState qmp_valid_states_%(c_name)s[] =3D { +''' + , c_name=3Dc_name(name)) + + for value in runstates: + ret +=3D mcgen(''' + %(c_enum)s, +''' + , c_enum=3Dc_enum_const('RunState', value)) + + ret +=3D mcgen(''' + %(c_enum)s, + }; +''' + , c_enum=3Dc_enum_const('RunState', "_MAX")) + + ret +=3D mcgen(''' + qmp_register_command(cmds, "%(name)s", + qmp_marshal_%(c_name)s, %(opts)s, + qmp_valid_states_%(c_name)s); + ''', + name=3Dname, c_name=3Dc_name(name), + opts=3Doptions) + return ret =20 =20 @@ -241,7 +269,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): self._visited_ret_types =3D None =20 def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): + gen, success_response, boxed, runstates): if not gen: return self.decl +=3D gen_command_decl(name, arg_type, boxed, ret_type) @@ -250,7 +278,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): self.defn +=3D gen_marshal_output(ret_type) self.decl +=3D gen_marshal_decl(name) self.defn +=3D gen_marshal(name, arg_type, boxed, ret_type) - self._regy +=3D gen_register_command(name, success_response) + self._regy +=3D gen_register_command(name, success_response, runst= ates) =20 =20 (input_file, output_dir, do_c, do_h, prefix, opts) =3D parse_command_line() diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py index 032bcea..ede86ac 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi-introspect.py @@ -154,7 +154,7 @@ const char %(c_name)s[] =3D %(c_string)s; for m in variants.variants]}) =20 def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): + gen, success_response, boxed, runstates): 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_json(name, 'command', diff --git a/scripts/qapi.py b/scripts/qapi.py index 58f995b..5c5037e 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -919,7 +919,8 @@ def check_exprs(exprs): elif 'command' in expr: meta =3D 'command' check_keys(expr_elem, 'command', [], - ['data', 'returns', 'gen', 'success-response', 'box= ed']) + ['data', 'returns', 'gen', 'success-response', 'box= ed', + 'runstates']) elif 'event' in expr: meta =3D 'event' check_keys(expr_elem, 'event', [], ['data', 'boxed']) @@ -1030,7 +1031,7 @@ class QAPISchemaVisitor(object): pass =20 def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): + gen, success_response, boxed, runstates): pass =20 def visit_event(self, name, info, arg_type, boxed): @@ -1397,7 +1398,7 @@ class QAPISchemaAlternateType(QAPISchemaType): =20 class QAPISchemaCommand(QAPISchemaEntity): def __init__(self, name, info, doc, arg_type, ret_type, - gen, success_response, boxed): + gen, success_response, boxed, runstates): QAPISchemaEntity.__init__(self, name, info, doc) assert not arg_type or isinstance(arg_type, str) assert not ret_type or isinstance(ret_type, str) @@ -1408,6 +1409,7 @@ class QAPISchemaCommand(QAPISchemaEntity): self.gen =3D gen self.success_response =3D success_response self.boxed =3D boxed + self.runstates =3D runstates =20 def check(self, schema): if self._arg_type_name: @@ -1431,7 +1433,8 @@ class QAPISchemaCommand(QAPISchemaEntity): def visit(self, visitor): visitor.visit_command(self.name, self.info, self.arg_type, self.ret_type, - self.gen, self.success_response, self.boxed) + self.gen, self.success_response, self.boxed, + self.runstates) =20 =20 class QAPISchemaEvent(QAPISchemaEntity): @@ -1639,6 +1642,7 @@ class QAPISchema(object): gen =3D expr.get('gen', True) success_response =3D expr.get('success-response', True) boxed =3D expr.get('boxed', False) + runstates =3D expr.get('runstates') if isinstance(data, OrderedDict): data =3D self._make_implicit_object_type( name, info, doc, 'arg', self._make_members(data, info)) @@ -1646,7 +1650,8 @@ class QAPISchema(object): assert len(rets) =3D=3D 1 rets =3D self._make_array_type(rets[0], info) self._def_entity(QAPISchemaCommand(name, info, doc, data, rets, - gen, success_response, boxed)) + gen, success_response, boxed, + runstates)) =20 def _def_event(self, expr, info, doc): name =3D expr['event'] diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py index bf1c57b..d28594c 100755 --- a/scripts/qapi2texi.py +++ b/scripts/qapi2texi.py @@ -227,7 +227,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): body=3Dtexi_entity(doc, 'Members')) =20 def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): + gen, success_response, boxed, runstates): doc =3D self.cur_doc if boxed: body =3D texi_body(doc) diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 1d2c250..a47d6f6 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -18,9 +18,9 @@ object Variant1 member var1: str optional=3DFalse object Variant2 command cmd q_obj_cmd-arg -> Object - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse, runstates=3DNone command cmd-boxed Object -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue + gen=3DTrue success_response=3DTrue boxed=3DTrue, runstates=3DNone object q_empty object q_obj_Variant1-wrapper member data: Variant1 optional=3DFalse diff --git a/tests/qapi-schema/ident-with-escape.out b/tests/qapi-schema/id= ent-with-escape.out index b5637cb..d9a272b 100644 --- a/tests/qapi-schema/ident-with-escape.out +++ b/tests/qapi-schema/ident-with-escape.out @@ -1,7 +1,7 @@ enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE command fooA q_obj_fooA-arg -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse, runstates=3DNone object q_empty object q_obj_fooA-arg member bar1: str optional=3DFalse diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indent= ed-expr.out index 586795f..4b128d5 100644 --- a/tests/qapi-schema/indented-expr.out +++ b/tests/qapi-schema/indented-expr.out @@ -1,7 +1,7 @@ enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE command eins None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse, runstates=3DNone object q_empty command zwei None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse, runstates=3DNone diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 3b1e908..787c228 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -153,15 +153,15 @@ object __org.qemu_x-Union2 tag __org.qemu_x-member1 case __org.qemu_x-value: __org.qemu_x-Struct2 command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> __org.qemu_= x-Union1 - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse, runstates=3DNone command boxed-struct UserDefZero -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue + gen=3DTrue success_response=3DTrue boxed=3DTrue, runstates=3DNone command boxed-union UserDefNativeListUnion -> None - gen=3DTrue success_response=3DTrue boxed=3DTrue + gen=3DTrue success_response=3DTrue boxed=3DTrue, runstates=3DNone command guest-get-time q_obj_guest-get-time-arg -> int - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse, runstates=3DNone command guest-sync q_obj_guest-sync-arg -> any - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse, runstates=3DNone object q_empty object q_obj_EVENT_C-arg member a: int optional=3DTrue @@ -222,10 +222,10 @@ object q_obj_user_def_cmd2-arg member ud1a: UserDefOne optional=3DFalse member ud1b: UserDefOne optional=3DTrue command user_def_cmd None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse, runstates=3DNone command user_def_cmd0 Empty2 -> Empty2 - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse, runstates=3DNone command user_def_cmd1 q_obj_user_def_cmd1-arg -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse, runstates=3DNone command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo - gen=3DTrue success_response=3DTrue boxed=3DFalse + gen=3DTrue success_response=3DTrue boxed=3DFalse, runstates=3DNone diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index ac43d34..958576d 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -37,11 +37,11 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): self._print_variants(variants) =20 def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): + gen, success_response, boxed, runstates): 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' % \ - (gen, success_response, boxed)) + print(' gen=3D%s success_response=3D%s boxed=3D%s, runstates=3D%= s' % \ + (gen, success_response, boxed, runstates)) =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 Fri Oct 24 09:43:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518784870495688.7383724667486; Fri, 16 Feb 2018 04:41:10 -0800 (PST) Received: from localhost ([::1]:44470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfK9-0005yH-NX for importer@patchew.org; Fri, 16 Feb 2018 07:41:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfI6-0004SQ-7M for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emfI3-0003af-5C for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:02 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45254 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 1emfI3-0003aV-16 for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:38:59 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 99EE47D85D; Fri, 16 Feb 2018 12:38:58 +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 524BCB07B7; Fri, 16 Feb 2018 12:38:57 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 13:37:18 +0100 Message-Id: <1518784641-43151-7-git-send-email-imammedo@redhat.com> In-Reply-To: <1518784641-43151-1-git-send-email-imammedo@redhat.com> References: <1518784641-43151-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Feb 2018 12:38:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Feb 2018 12:38:58 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 v3 6/9] tests: extend qmp test with pereconfig 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: peter.maydell@linaro.org, pkrempa@redhat.com, ehabkost@redhat.com, cohuck@redhat.com, armbru@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au 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 in 'preconfig' state. It should work for all targets, but won't work with machine 'none' as it's limited to -smp 1 only. So use PC machine for testing preconfig and 'runstate' parameter. Signed-off-by: Igor Mammedov --- tests/qmp-test.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 5808483..3adc485 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -304,8 +304,54 @@ static void add_query_tests(QmpSchema *schema) } } =20 +static bool is_err(QDict *rsp) +{ + const char *desc =3D NULL; + QDict *error =3D qdict_get_qdict(rsp, "error"); + if (error) { + desc =3D qdict_get_try_str(error, "desc"); + } + QDECREF(rsp); + return !!desc; +} + +static void test_qmp_preconfig(void) +{ + QDict *rsp, *ret; + QTestState *qs =3D qtest_startf("-nodefaults -preconfig -smp 2"); + + /* preconfig state */ + /* enabled commands, no error expected */ + g_assert(!is_err(qtest_qmp(qs, "{ 'execute': 'query-commands' }"))); + + /* forbidden commands, expected error */ + g_assert(is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }"))); + + 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(!is_err(qtest_qmp(qs, "{ 'execute': 'cont' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + 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(!is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }"))); + + qtest_quit(qs); +} + int main(int argc, char *argv[]) { + const char *arch =3D qtest_get_arch(); QmpSchema schema; int ret; =20 @@ -314,6 +360,9 @@ int main(int argc, char *argv[]) qtest_add_func("qmp/protocol", test_qmp_protocol); qmp_schema_init(&schema); add_query_tests(&schema); + if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64")) { + qtest_add_func("qmp/preconfig", test_qmp_preconfig); + } =20 ret =3D g_test_run(); =20 --=20 2.7.4 From nobody Fri Oct 24 09:43:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151878504848737.07016817409635; Fri, 16 Feb 2018 04:44:08 -0800 (PST) Received: from localhost ([::1]:44485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfN1-0008Kq-Hl for importer@patchew.org; Fri, 16 Feb 2018 07:44:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfI6-0004SR-7K for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emfI4-0003b7-M3 for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:02 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39388 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 1emfI4-0003ax-Hs for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:00 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2287AEB705; Fri, 16 Feb 2018 12:39:00 +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 CD8E0AF033; Fri, 16 Feb 2018 12:38:58 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 13:37:19 +0100 Message-Id: <1518784641-43151-8-git-send-email-imammedo@redhat.com> In-Reply-To: <1518784641-43151-1-git-send-email-imammedo@redhat.com> References: <1518784641-43151-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 16 Feb 2018 12:39:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 16 Feb 2018 12:39:00 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 v3 7/9] 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: peter.maydell@linaro.org, pkrempa@redhat.com, ehabkost@redhat.com, cohuck@redhat.com, armbru@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au 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. *) 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 Signed-off-by: Igor Mammedov --- qapi-schema.json | 6 +++++- tests/qmp-test.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/qapi-schema.json b/qapi-schema.json index ee1053d..4365dfe 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3167,7 +3167,11 @@ # ]} # ## -{ 'command': 'query-hotpluggable-cpus', 'returns': ['HotpluggableCPU'] } +{ 'command': 'query-hotpluggable-cpus', 'returns': ['HotpluggableCPU'], + 'runstates': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paus= ed', + 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm= ', + 'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', + 'guest-panicked', 'colo', 'preconfig' ] } =20 ## # @GuidInfo: diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 3adc485..4ab0b7c 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -323,6 +323,7 @@ static void test_qmp_preconfig(void) /* preconfig state */ /* enabled commands, no error expected */ g_assert(!is_err(qtest_qmp(qs, "{ 'execute': 'query-commands' }"))); + g_assert(!is_err(qtest_qmp(qs, "{ 'execute': 'query-hotpluggable-cpus'= }"))); =20 /* forbidden commands, expected error */ g_assert(is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }"))); --=20 2.7.4 From nobody Fri Oct 24 09:43:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518785223352392.5329422976629; Fri, 16 Feb 2018 04:47:03 -0800 (PST) Received: from localhost ([::1]:44830 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfPq-0002hg-Jq for importer@patchew.org; Fri, 16 Feb 2018 07:47:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfI7-0004TH-5w for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emfI6-0003bW-6m for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:03 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33986 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 1emfI6-0003bP-2L for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:02 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B83C407519B; Fri, 16 Feb 2018 12:39:01 +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 5467EAF033; Fri, 16 Feb 2018 12:39:00 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 13:37:20 +0100 Message-Id: <1518784641-43151-9-git-send-email-imammedo@redhat.com> In-Reply-To: <1518784641-43151-1-git-send-email-imammedo@redhat.com> References: <1518784641-43151-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 16 Feb 2018 12:39:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 16 Feb 2018 12:39:01 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 v3 8/9] 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: peter.maydell@linaro.org, pkrempa@redhat.com, ehabkost@redhat.com, cohuck@redhat.com, armbru@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au 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-schema.json | 14 ++++++++++++++ tests/qmp-test.c | 6 ++++++ 3 files changed, 25 insertions(+) diff --git a/numa.c b/numa.c index 04e34eb..e3b7f15 100644 --- a/numa.c +++ b/numa.c @@ -446,6 +446,11 @@ void parse_numa_opts(MachineState *ms) } } =20 +void qmp_set_numa_node(NumaOptions *cmd, Error **errp) +{ + parse_NumaOptions(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-schema.json b/qapi-schema.json index 4365dfe..a96c31f 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3201,3 +3201,17 @@ # Since: 2.11 ## { 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} } + +## +# @set-numa-node: +# +# Runtime equivalent of '-numa' CLI option, available at +# preconfigure stage to configure numa mapping before initializing +# machine. +# +# Since 2.12 +## +{ 'command': 'set-numa-node', 'boxed': true, + 'data': 'NumaOptions', + 'runstates': [ 'preconfig' ] +} diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 4ab0b7c..b0de2b1 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -324,6 +324,8 @@ static void test_qmp_preconfig(void) /* enabled commands, no error expected */ g_assert(!is_err(qtest_qmp(qs, "{ 'execute': 'query-commands' }"))); g_assert(!is_err(qtest_qmp(qs, "{ 'execute': 'query-hotpluggable-cpus'= }"))); + g_assert(!is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," + " 'arguments': { 'type': 'node', 'nodeid': 0 } }"))); =20 /* forbidden commands, expected error */ g_assert(is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }"))); @@ -347,6 +349,10 @@ static void test_qmp_preconfig(void) /* enabled commands, no error expected */ g_assert(!is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }"))); =20 + /* forbidden commands, expected error */ + g_assert(is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," + " 'arguments': { 'type': 'node', 'nodeid': 1 } }"))); + qtest_quit(qs); } =20 --=20 2.7.4 From nobody Fri Oct 24 09:43:26 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518785051325978.7539868954507; Fri, 16 Feb 2018 04:44:11 -0800 (PST) Received: from localhost ([::1]:44487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfN4-0008PS-Ip for importer@patchew.org; Fri, 16 Feb 2018 07:44:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emfI8-0004U6-OK for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emfI7-0003cA-NJ for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:04 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45260 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 1emfI7-0003c6-In for qemu-devel@nongnu.org; Fri, 16 Feb 2018 07:39:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2249E7D85D; Fri, 16 Feb 2018 12:39:03 +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 CF1F8AF02A; Fri, 16 Feb 2018 12:39:01 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 13:37:21 +0100 Message-Id: <1518784641-43151-10-git-send-email-imammedo@redhat.com> In-Reply-To: <1518784641-43151-1-git-send-email-imammedo@redhat.com> References: <1518784641-43151-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Feb 2018 12:39:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 16 Feb 2018 12:39:03 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 v3 9/9] 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: peter.maydell@linaro.org, pkrempa@redhat.com, ehabkost@redhat.com, cohuck@redhat.com, armbru@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au 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 --- tests/numa-test.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 71 insertions(+) diff --git a/tests/numa-test.c b/tests/numa-test.c index 68aca9c..11c2842 100644 --- a/tests/numa-test.c +++ b/tests/numa-test.c @@ -260,6 +260,76 @@ static void aarch64_numa_cpu(const void *data) g_free(cli); } =20 +static bool is_err(QDict *response) +{ + const char *desc =3D NULL; + QDict *error =3D qdict_get_qdict(response, "error"); + if (error) { + desc =3D qdict_get_try_str(error, "desc"); + } + QDECREF(response); + return !!desc; +} + +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(!is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," + " 'arguments': { 'type': 'node', 'nodeid': 0 } }"))); + g_assert(!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(!is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node'," + " 'arguments': { 'type': 'cpu', 'node-id': 0, 'socket-id': 1 } }")= )); + g_assert(!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(!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); + } + + qtest_quit(qs); +} + int main(int argc, char **argv) { const char *args =3D NULL; @@ -278,6 +348,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")) { --=20 2.7.4