From nobody Sat Nov 1 22:15:46 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 1527721672748271.0476916274863; Wed, 30 May 2018 16:07:52 -0700 (PDT) Received: from localhost ([::1]:41103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAC6-0005jF-BR for importer@patchew.org; Wed, 30 May 2018 19:07:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOA9v-0004Tn-74 for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOA9t-0008Sm-Hd for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50746) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOA9t-0008SX-CJ for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:33 -0400 Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A111C30C28F6; Wed, 30 May 2018 23:05:32 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31148309128B; Wed, 30 May 2018 23:05:32 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:17 -0300 Message-Id: <20180530230528.30166-2-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 30 May 2018 23:05:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/12] numa: clarify error message when node index is out of range in -numa dist, ... 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: Igor Mammedov 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" From: Igor Mammedov When using following CLI: -numa dist,src=3D128,dst=3D1,val=3D20 user gets a rather confusing error message: "Invalid node 128, max possible could be 128" Where 128 is number of nodes that QEMU supports (MAX_NODES), while src/dst is an index up to that limit, so it should be MAX_NODES - 1 in error message. Make error message to explicitly state valid range for node index to be more clear. Signed-off-by: Igor Mammedov Message-Id: <1526483174-169008-1-git-send-email-imammedo@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Eduardo Habkost --- numa.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/numa.c b/numa.c index aac22a9612..efc78b2f17 100644 --- a/numa.c +++ b/numa.c @@ -141,9 +141,8 @@ static void parse_numa_distance(NumaDistOptions *dist, = Error **errp) uint8_t val =3D dist->val; =20 if (src >=3D MAX_NODES || dst >=3D MAX_NODES) { - error_setg(errp, - "Invalid node %d, max possible could be %d", - MAX(src, dst), MAX_NODES); + error_setg(errp, "Parameter '%s' expects an integer between 0 and = %d", + src >=3D MAX_NODES ? "src" : "dst", MAX_NODES - 1); return; } =20 --=20 2.17.1 From nobody Sat Nov 1 22:15:46 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 1527721830485235.57021572809356; Wed, 30 May 2018 16:10:30 -0700 (PDT) Received: from localhost ([::1]:41117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAEf-0007ta-8h for importer@patchew.org; Wed, 30 May 2018 19:10:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOA9w-0004Ui-BK for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOA9v-0008Tj-Bf for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52928) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOA9v-0008TP-4D for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 63E6930C942B; Wed, 30 May 2018 23:05:34 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB68216D3F; Wed, 30 May 2018 23:05:33 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:18 -0300 Message-Id: <20180530230528.30166-3-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 30 May 2018 23:05:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/12] 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: Igor Mammedov 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" From: Igor Mammedov 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 Message-Id: <1525423069-61903-2-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- 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 d99e5474b4..21713b7e2f 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 2040177664..617e5f8d75 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 efc78b2f17..ad1d7934f2 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.17.1 From nobody Sat Nov 1 22:15:46 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 1527721671648480.6761837505255; Wed, 30 May 2018 16:07:51 -0700 (PDT) Received: from localhost ([::1]:41102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAC5-0005iS-JG for importer@patchew.org; Wed, 30 May 2018 19:07:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOA9y-0004Wg-8A for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOA9x-0008Ua-4f for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46680) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOA9w-0008UK-V6 for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:37 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3645C15F473; Wed, 30 May 2018 23:05:36 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id C00A62010CB7; Wed, 30 May 2018 23:05:35 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:19 -0300 Message-Id: <20180530230528.30166-4-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 30 May 2018 23:05:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/12] 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: Igor Mammedov 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" From: Igor Mammedov it will allow to reuse set_numa_options() for parsing configuration commands received via QMP interface Signed-off-by: Igor Mammedov Message-Id: <1525423069-61903-3-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- 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 21713b7e2f..7a0ae751aa 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 ad1d7934f2..53bd65a05d 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); @@ -223,6 +206,31 @@ static int parse_numa(void *opaque, QemuOpts *opts, Er= ror **errp) abort(); } =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) { --=20 2.17.1 From nobody Sat Nov 1 22:15:46 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 1527721833891787.4711109818722; Wed, 30 May 2018 16:10:33 -0700 (PDT) Received: from localhost ([::1]:41118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAEj-0007vv-3y for importer@patchew.org; Wed, 30 May 2018 19:10:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOA9z-0004YO-UB for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOA9z-0008VO-0f for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36612) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOA9y-0008VC-QP for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13D0230C0E92; Wed, 30 May 2018 23:05:38 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CB445D6B4; Wed, 30 May 2018 23:05:37 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:20 -0300 Message-Id: <20180530230528.30166-5-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 30 May 2018 23:05:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/12] qapi: introduce preconfig runstate 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: Igor Mammedov 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" From: Igor Mammedov New preconfig runstate will be used in follow up patches related to introducing --preconfig CLI option and is intended to replace prelaunch runstate from QEMU start up to machine_init callback. Signed-off-by: Igor Mammedov Message-Id: <1525423069-61903-4-git-send-email-imammedo@redhat.com> Reviewed-by: Eric Blake [ehabkost: Changed "since 2.13" to "since 3.0"] Signed-off-by: Eduardo Habkost --- qapi/run-state.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qapi/run-state.json b/qapi/run-state.json index 1c9fff3aef..d3c2a9113b 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 3.0) ## { '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: --=20 2.17.1 From nobody Sat Nov 1 22:15:46 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 1527721808699697.1741726570122; Wed, 30 May 2018 16:10:08 -0700 (PDT) Received: from localhost ([::1]:41115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAEJ-0007cu-RH for importer@patchew.org; Wed, 30 May 2018 19:10:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAA1-0004aF-RV for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOAA0-0008WE-P4 for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56460) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOAA0-0008Vn-Im for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:40 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CCDF130BE976; Wed, 30 May 2018 23:05:39 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C834308BDA2; Wed, 30 May 2018 23:05:39 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:21 -0300 Message-Id: <20180530230528.30166-6-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 30 May 2018 23:05:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/12] 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: Igor Mammedov 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" From: Igor Mammedov 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 Reviewed-by: Eric Blake Message-Id: <1525423069-61903-5-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- monitor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/monitor.c b/monitor.c index 46814af533..9e50418afe 100644 --- a/monitor.c +++ b/monitor.c @@ -3371,6 +3371,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.17.1 From nobody Sat Nov 1 22:15:46 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 1527721970572948.2322196974643; Wed, 30 May 2018 16:12:50 -0700 (PDT) Received: from localhost ([::1]:41132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAGv-0001PR-MX for importer@patchew.org; Wed, 30 May 2018 19:12:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAA5-0004cb-48 for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOAA2-00005K-QO for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOAA2-00005A-HB for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:42 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5F6E1B3E03; Wed, 30 May 2018 23:05:41 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2545B2010CB7; Wed, 30 May 2018 23:05:40 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:22 -0300 Message-Id: <20180530230528.30166-7-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 30 May 2018 23:05:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/12] qapi: introduce new cmd option "allow-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: Igor Mammedov 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" From: Igor Mammedov 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 amended to not expect machine in initialized state or deal with it. For compatibility reasons, commands that don't use new flag 'allow-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 exit-preconfig 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 patches. Signed-off-by: Igor Mammedov Message-Id: <1526057503-39287-1-git-send-email-imammedo@redhat.com> Reviewed-by: Eric Blake [ehabkost: Changed "since 2.13" to "since 3.0"] Signed-off-by: Eduardo Habkost --- docs/devel/qapi-code-gen.txt | 11 ++++++++++- qapi/introspect.json | 5 ++++- qapi/misc.json | 9 ++++++--- qapi/run-state.json | 3 ++- scripts/qapi/commands.py | 11 +++++++---- scripts/qapi/common.py | 18 +++++++++++------- scripts/qapi/doc.py | 4 ++-- scripts/qapi/introspect.py | 7 ++++--- include/qapi/qmp/dispatch.h | 1 + monitor.c | 5 ++--- tests/qapi-schema/test-qapi.py | 4 ++-- 11 files changed, 51 insertions(+), 27 deletions(-) diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index b9b6eabd08..1366228b2a 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, '*allow-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,15 @@ OOB command handlers must satisfy the following condit= ions: =20 If in doubt, do not implement OOB execution support. =20 +A command may use the optional 'allow-preconfig' key to permit its executi= on +at early runtime configuration stage (preconfig runstate). +If not specified then a command defaults to 'allow-preconfig': false. + +An example of declaring a command that is enabled during preconfig: + { 'command': 'qmp_capabilities', + 'data': { '*enable': [ 'QMPCapability' ] }, + 'allow-preconfig': true } + =3D=3D=3D Events =3D=3D=3D =20 Usage: { 'event': STRING, '*data': COMPLEX-TYPE-NAME-OR-DICT, diff --git a/qapi/introspect.json b/qapi/introspect.json index c7f67b7d78..80a0a3e656 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) # +# @allow-preconfig: command can be executed in preconfig runstate, +# default: false (Since 3.0) +# # 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', 'allow-preconfig': 'bool' } } =20 ## # @SchemaInfoEvent: diff --git a/qapi/misc.json b/qapi/misc.json index 99bcaacd62..ae2bb27b83 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -37,7 +37,8 @@ # ## { 'command': 'qmp_capabilities', - 'data': { '*enable': [ 'QMPCapability' ] } } + 'data': { '*enable': [ 'QMPCapability' ] }, + 'allow-preconfig': true } =20 ## # @QMPCapability: @@ -155,7 +156,8 @@ # Note: This example has been shortened as the real response is too long. # ## -{ 'command': 'query-commands', 'returns': ['CommandInfo'] } +{ 'command': 'query-commands', 'returns': ['CommandInfo'], + 'allow-preconfig': true } =20 ## # @LostTickPolicy: @@ -2648,7 +2650,8 @@ # ## {'command': 'query-command-line-options', 'data': { '*option': 'str' }, - 'returns': ['CommandLineOptionInfo'] } + 'returns': ['CommandLineOptionInfo'], + 'allow-preconfig': true } =20 ## # @X86CPURegister32: diff --git a/qapi/run-state.json b/qapi/run-state.json index d3c2a9113b..332e44897b 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', + 'allow-preconfig': true } =20 ## # @SHUTDOWN: diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 0c5da3a54d..3b0867c14f 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -193,13 +193,15 @@ out: return ret =20 =20 -def gen_register_command(name, success_response, allow_oob): +def gen_register_command(name, success_response, allow_oob, allow_preconfi= g): options =3D [] =20 if not success_response: options +=3D ['QCO_NO_SUCCESS_RESP'] if allow_oob: options +=3D ['QCO_ALLOW_OOB'] + if allow_preconfig: + options +=3D ['QCO_ALLOW_PRECONFIG'] =20 if not options: options =3D ['QCO_NO_OPTIONS'] @@ -275,8 +277,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, allow_preconfig): if not gen: return self._genh.add(gen_command_decl(name, arg_type, boxed, ret_type)) @@ -285,7 +287,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, + allow_preconfig) =20 =20 def gen_commands(schema, output_dir, prefix): diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index a032cec375..e82990f0f2 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 'allow-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', 'allow-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, allow_preconfig): 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, allow_preconfig): 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.allow_preconfig =3D allow_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.allow_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) + allow_preconfig =3D expr.get('allow-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,7 @@ 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, allow_preconf= ig)) =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 9b312b2c51..b5630844f9 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, allow_preconfig): 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 f9e67e8227..5b6c72c7b2 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, allow_preconfig): 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, + 'allow-preconfig': allow_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/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index ffb4652f71..b366bb48bd 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_ALLOW_PRECONFIG =3D (1U << 2), } QmpCommandOptions; =20 typedef struct QmpCommand diff --git a/monitor.c b/monitor.c index 9e50418afe..922cfc041e 100644 --- a/monitor.c +++ b/monitor.c @@ -1179,8 +1179,7 @@ static void monitor_init_qmp_commands(void) qmp_init_marshal(&qmp_commands); =20 qmp_register_command(&qmp_commands, "query-qmp-schema", - qmp_query_qmp_schema, - QCO_NO_OPTIONS); + qmp_query_qmp_schema, QCO_ALLOW_PRECONFIG); qmp_register_command(&qmp_commands, "device_add", qmp_device_add, QCO_NO_OPTIONS); qmp_register_command(&qmp_commands, "netdev_add", qmp_netdev_add, @@ -1190,7 +1189,7 @@ 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_ALLOW_PRECONFIG= ); } =20 static bool qmp_cap_enabled(Monitor *mon, QMPCapability cap) diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index c1a144ba29..89b92eddd4 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, allow_preconfig): 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.17.1 From nobody Sat Nov 1 22:15:46 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 1527721946919552.1494332050161; Wed, 30 May 2018 16:12:26 -0700 (PDT) Received: from localhost ([::1]:41130 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAGX-00016P-Te for importer@patchew.org; Wed, 30 May 2018 19:12:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAA6-0004dW-8I for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOAA4-00005n-LD for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46266) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOAA4-00005Y-Cc for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:44 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5F9E37B2F9; Wed, 30 May 2018 23:05:43 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 318E3308BDA2; Wed, 30 May 2018 23:05:43 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:23 -0300 Message-Id: <20180530230528.30166-8-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 30 May 2018 23:05:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/12] tests: qapi-schema tests for allow-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: Igor Mammedov 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" From: Igor Mammedov use new allow-preconfig parameter in tests and make sure that the QAPISchema can parse allow-preconfig correctly Signed-off-by: Igor Mammedov Reviewed-by: Eric Blake Message-Id: <1526058959-41425-1-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- tests/test-qmp-cmds.c | 2 +- tests/Makefile.include | 1 + tests/qapi-schema/allow-preconfig-test.err | 1 + tests/qapi-schema/allow-preconfig-test.exit | 1 + tests/qapi-schema/allow-preconfig-test.json | 2 ++ tests/qapi-schema/allow-preconfig-test.out | 0 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.json | 4 ++-- tests/qapi-schema/qapi-schema-test.out | 22 ++++++++++----------- tests/qapi-schema/test-qapi.py | 4 ++-- 12 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 tests/qapi-schema/allow-preconfig-test.err create mode 100644 tests/qapi-schema/allow-preconfig-test.exit create mode 100644 tests/qapi-schema/allow-preconfig-test.json create mode 100644 tests/qapi-schema/allow-preconfig-test.out diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index e0ed461f58..491b0c4a44 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -16,7 +16,7 @@ void qmp_user_def_cmd(Error **errp) { } =20 -void qmp_an_oob_command(Error **errp) +void qmp_test_flags_command(Error **errp) { } =20 diff --git a/tests/Makefile.include b/tests/Makefile.include index b499ba1813..86f90c0cb0 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -525,6 +525,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 allow-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/allow-preconfig-test.err b/tests/qapi-schema= /allow-preconfig-test.err new file mode 100644 index 0000000000..700d583306 --- /dev/null +++ b/tests/qapi-schema/allow-preconfig-test.err @@ -0,0 +1 @@ +tests/qapi-schema/allow-preconfig-test.json:2: 'allow-preconfig' of comman= d 'allow-preconfig-test' should only use true value diff --git a/tests/qapi-schema/allow-preconfig-test.exit b/tests/qapi-schem= a/allow-preconfig-test.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/allow-preconfig-test.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/allow-preconfig-test.json b/tests/qapi-schem= a/allow-preconfig-test.json new file mode 100644 index 0000000000..d9f0e914df --- /dev/null +++ b/tests/qapi-schema/allow-preconfig-test.json @@ -0,0 +1,2 @@ +# Check against allow-preconfig illegal value +{ 'command': 'allow-preconfig-test', 'allow-preconfig': 'some-string' } diff --git a/tests/qapi-schema/allow-preconfig-test.out b/tests/qapi-schema= /allow-preconfig-test.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 63058b1590..9c8a4838e1 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 82213aa51d..24c976f473 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 862678f8f4..bd8a48630e 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.json b/tests/qapi-schema/qa= pi-schema-test.json index 06e30f452e..46c7282945 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -139,8 +139,8 @@ { 'command': 'boxed-struct', 'boxed': true, 'data': 'UserDefZero' } { 'command': 'boxed-union', 'data': 'UserDefNativeListUnion', 'boxed': tru= e } =20 -# Smoke test on Out-Of-Band -{ 'command': 'an-oob-command', 'allow-oob': true } +# Smoke test on Out-Of-Band and allow-preconfig-test +{ 'command': 'test-flags-command', 'allow-oob': true, 'allow-preconfig': t= rue } =20 # 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 467577d770..542a19c407 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 -command an-oob-command None -> None - gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DTrue + gen=3DTrue success_response=3DTrue boxed=3DTrue oob=3DFalse preconfig= =3DFalse +command test-flags-command None -> None + gen=3DTrue success_response=3DTrue boxed=3DFalse oob=3DTrue preconfig= =3DTrue 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 89b92eddd4..4512a41504 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, allow_preconfig): 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, allow_preconfig)) =20 def visit_event(self, name, info, arg_type, boxed): print('event %s %s' % (name, arg_type and arg_type.name)) --=20 2.17.1 From nobody Sat Nov 1 22:15:46 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 15277219680061015.7954965090787; Wed, 30 May 2018 16:12:48 -0700 (PDT) Received: from localhost ([::1]:41131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAGs-0001NW-Lo for importer@patchew.org; Wed, 30 May 2018 19:12:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAA8-0004g0-Kn for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOAA6-00007H-Re for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55888) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOAA6-00006R-II for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:46 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD3F530C54CA; Wed, 30 May 2018 23:05:45 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DC265C689; Wed, 30 May 2018 23:05:44 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:24 -0300 Message-Id: <20180530230528.30166-9-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 30 May 2018 23:05:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/12] 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: Igor Mammedov 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" From: Igor Mammedov 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 initialized with all devices wired up and ready to execute guest code (QEMU needs only to unpause VCPUs 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 allows the configuration of machine parameters which will be used by board init code. When early introspection/configuration is done, command 'exit-preconfig' 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 Reviewed-by: Eric Blake Message-Id: <1526059483-42847-1-git-send-email-imammedo@redhat.com> [ehabkost: Changed "since 2.13" to "since 3.0"] Signed-off-by: Eduardo Habkost --- qapi/misc.json | 23 +++++++++++++++++++++++ include/sysemu/sysemu.h | 1 + qapi/qmp-dispatch.c | 8 ++++++++ qmp.c | 10 ++++++++++ vl.c | 35 ++++++++++++++++++++++++++++++++++- qemu-options.hx | 13 +++++++++++++ qemu-tech.texi | 40 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 129 insertions(+), 1 deletion(-) diff --git a/qapi/misc.json b/qapi/misc.json index ae2bb27b83..bd6d1805ab 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -1244,6 +1244,29 @@ ## { 'command': 'cont' } =20 +## +# @exit-preconfig: +# +# Exit from "preconfig" state +# +# This command makes QEMU exit the preconfig state and proceed with +# VM initialization using configuration data provided on the command line +# and via the QMP monitor during the preconfig state. The command is only +# available during the preconfig state (i.e. when the --preconfig command +# line option was in use). +# +# Since 3.0 +# +# Returns: nothing +# +# Example: +# +# -> { "execute": "exit-preconfig" } +# <- { "return": {} } +# +## +{ 'command': 'exit-preconfig', 'allow-preconfig': true } + ## # @system_wakeup: # diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 544ab77a2b..e893f72f3b 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 f9377b27fd..935f9e159c 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_ALLOW_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/qmp.c b/qmp.c index 25fdc9a5b2..73e46d795f 100644 --- a/qmp.c +++ b/qmp.c @@ -161,6 +161,16 @@ SpiceInfo *qmp_query_spice(Error **errp) }; #endif =20 +void qmp_exit_preconfig(Error **errp) +{ + if (!runstate_check(RUN_STATE_PRECONFIG)) { + error_setg(errp, "The command is permitted only in '%s' state", + RunState_str(RUN_STATE_PRECONFIG)); + return; + } + qemu_exit_preconfig_request(); +} + void qmp_cont(Error **errp) { BlockBackend *blk; diff --git a/vl.c b/vl.c index 038d7f8042..c4fe25560c 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); } @@ -3667,6 +3687,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); @@ -4031,6 +4054,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); @@ -4548,6 +4577,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(); diff --git a/qemu-options.hx b/qemu-options.hx index abbfa6ae9e..2f61ea42ee 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3299,6 +3299,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 'exit-preconfig' 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/qemu-tech.texi b/qemu-tech.texi index 52a56ae25e..dcecba83cb 100644 --- a/qemu-tech.texi +++ b/qemu-tech.texi @@ -5,6 +5,7 @@ * CPU emulation:: * Translator Internals:: * QEMU compared to other emulators:: +* Managed start up options:: * Bibliography:: @end menu =20 @@ -314,6 +315,45 @@ VirtualBox [9], Xen [10] and KVM [11] are based on QEM= U. QEMU-SystemC [12] uses QEMU to simulate a system where some hardware devices are developed in SystemC. =20 +@node Managed start up options +@section Managed start up options + +In system mode emulation, it's possible to create a VM in a paused state u= sing +the -S command line option. In this state the machine is completely initia= lized +according to command line options and ready to execute VM code but VCPU th= reads +are not executing any code. The VM state in this paused state depends on t= he way +QEMU was started. It could be in: +@table @asis +@item initial state (after reset/power on state) +@item with direct kernel loading, the initial state could be amended to ex= ecute +code loaded by QEMU in the VM's RAM and with incoming migration +@item with incoming migration, initial state will by amended with the migr= ated +machine state after migration completes. +@end table + +This paused state is typically used by users to query machine state and/or +additionally configure the machine (by hotplugging devices) in runtime bef= ore +allowing VM code to run. + +However, at the -S pause point, it's impossible to configure options that = affect +initial VM creation (like: -smp/-m/-numa ...) or cold plug devices. That's +when the --preconfig command line option should be used. It allows pausing= QEMU +before the initial VM creation, in a new preconfig state, where additional +queries and configuration can be performed via QMP before moving on to +the resulting configuration startup. In the preconfig state, QEMU only all= ows +a limited set of commands over the QMP monitor, where the commands do not +depend on an initialized machine, including but not limited to: +@table @asis +@item qmp_capabilities +@item query-qmp-schema +@item query-commands +@item query-status +@item exit-preconfig +@end table +The full list of commands is in QMP schema which could be queried with +query-qmp-schema, where commands supported at preconfig state have option +'allow-preconfig' set to true. + @node Bibliography @section Bibliography =20 --=20 2.17.1 From nobody Sat Nov 1 22:15:46 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 152772207975915.432254335424886; Wed, 30 May 2018 16:14:39 -0700 (PDT) Received: from localhost ([::1]:41140 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAIh-0002nj-0r for importer@patchew.org; Wed, 30 May 2018 19:14:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAA9-0004gH-Du for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOAA8-00008l-G3 for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42090) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOAA8-00007d-AQ for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:48 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86C3BC0E674E; Wed, 30 May 2018 23:05:47 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E67316C0C; Wed, 30 May 2018 23:05:46 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:25 -0300 Message-Id: <20180530230528.30166-10-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 30 May 2018 23:05:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/12] 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: Igor Mammedov 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" From: Igor Mammedov Add permission checks for commands at 'preconfig' stage. Signed-off-by: Igor Mammedov Message-Id: <1526556524-267991-1-git-send-email-imammedo@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Eduardo Habkost --- tests/qmp-test.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 88f867f8c0..2ee441cdb3 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -392,6 +392,52 @@ static void add_query_tests(QmpSchema *schema) } } =20 +static bool qmp_rsp_is_err(QDict *rsp) +{ + QDict *error =3D qdict_get_qdict(rsp, "error"); + qobject_unref(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"); + qobject_unref(rsp); + + /* exit preconfig state */ + g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'exit-preconfig' = }"))); + 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"); + qobject_unref(rsp); + + /* check that exit-preconfig returns error after exiting preconfig */ + g_assert(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'exit-preconfig' }= "))); + + /* 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 +449,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.17.1 From nobody Sat Nov 1 22:15:46 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 1527722104872916.1971942931356; Wed, 30 May 2018 16:15:04 -0700 (PDT) Received: from localhost ([::1]:41144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAJ1-0003Ap-Dz for importer@patchew.org; Wed, 30 May 2018 19:14:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAAB-0004gK-7l for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOAAA-0000Ao-9Z for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33350) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOAAA-00009U-3t for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:50 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56AB931782A8; Wed, 30 May 2018 23:05:49 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8BCF5D6B4; Wed, 30 May 2018 23:05:48 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:26 -0300 Message-Id: <20180530230528.30166-11-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 30 May 2018 23:05:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/12] 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: Igor Mammedov 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" From: Igor Mammedov 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. 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 Signed-off-by: Igor Mammedov Message-Id: <1525423069-61903-10-git-send-email-imammedo@redhat.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- qapi/misc.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qapi/misc.json b/qapi/misc.json index bd6d1805ab..b155db2642 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -3285,7 +3285,8 @@ # ]} # ## -{ 'command': 'query-hotpluggable-cpus', 'returns': ['HotpluggableCPU'] } +{ 'command': 'query-hotpluggable-cpus', 'returns': ['HotpluggableCPU'], + 'allow-preconfig': true } =20 ## # @GuidInfo: --=20 2.17.1 From nobody Sat Nov 1 22:15:46 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 1527722250527101.02573705101895; Wed, 30 May 2018 16:17:30 -0700 (PDT) Received: from localhost ([::1]:41158 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOALR-00054Z-OK for importer@patchew.org; Wed, 30 May 2018 19:17:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAAE-0004jh-GD for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOAAC-0000Bm-54 for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46302) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOAAB-0000BT-Uh for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:52 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BC0D37B2E4; Wed, 30 May 2018 23:05:51 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id B060F2010CB7; Wed, 30 May 2018 23:05:50 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:27 -0300 Message-Id: <20180530230528.30166-12-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 30 May 2018 23:05:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/12] 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: Igor Mammedov 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" From: Igor Mammedov 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. Example of configuration session: $QEMU -smp 2 --preconfig ... QMP: -> {'execute': 'query-hotpluggable-cpus' } <- {'return': [ {'props': {'core-id': 0, 'thread-id': 0, 'socket-id': 1}, ... }, {'props': {'core-id': 0, 'thread-id': 0, 'socket-id': 0}, ... } ]} -> {'execute': 'set-numa-node', 'arguments': { 'type': 'node', 'nodeid': 0 = } } <- {'return': {}} -> {'execute': 'set-numa-node', 'arguments': { 'type': 'cpu', 'node-id': 0, 'core-id': 0, 'thread-id': 0, 'socket-id': 1, } } <- {'return': {}} -> {'execute': 'set-numa-node', 'arguments': { 'type': 'node', 'nodeid': 1 = } } -> {'execute': 'set-numa-node', 'arguments': { 'type': 'cpu', 'node-id': 1, 'core-id': 0, 'thread-id': 0, 'socket-id': 0 } } <- {'return': {}} -> {'execute': 'query-hotpluggable-cpus' } <- {'return': [ {'props': {'core-id': 0, 'thread-id': 0, 'node-id': 0, 'socket-id': = 1}, ... }, {'props': {'core-id': 0, 'thread-id': 0, 'node-id': 1, 'socket-id': = 0}, ... } ]} Signed-off-by: Igor Mammedov Message-Id: <1525423069-61903-11-git-send-email-imammedo@redhat.com> Reviewed-by: Eduardo Habkost [ehabkost: Changed "since 2.13" to "since 3.0"] Signed-off-by: Eduardo Habkost --- qapi/misc.json | 14 ++++++++++++++ numa.c | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/qapi/misc.json b/qapi/misc.json index b155db2642..02bb295c13 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -3510,3 +3510,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 3.0 +## +{ 'command': 'set-numa-node', 'boxed': true, + 'data': 'NumaOptions', + 'allow-preconfig': true +} diff --git a/numa.c b/numa.c index 53bd65a05d..33572bfa74 100644 --- a/numa.c +++ b/numa.c @@ -444,6 +444,17 @@ void parse_numa_opts(MachineState *ms) } } =20 +void qmp_set_numa_node(NumaOptions *cmd, Error **errp) +{ + if (!runstate_check(RUN_STATE_PRECONFIG)) { + error_setg(errp, "The command is permitted only in '%s' state", + RunState_str(RUN_STATE_PRECONFIG)); + return; + } + + 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); --=20 2.17.1 From nobody Sat Nov 1 22:15:46 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 1527722225776785.0975238250682; Wed, 30 May 2018 16:17:05 -0700 (PDT) Received: from localhost ([::1]:41157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAL3-0004o9-1Q for importer@patchew.org; Wed, 30 May 2018 19:17:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOAAF-0004kv-Rv for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOAAE-0000E8-Kc for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37034) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fOAAE-0000Cc-Ca for qemu-devel@nongnu.org; Wed, 30 May 2018 19:05:54 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA8561FB3A4; Wed, 30 May 2018 23:05:53 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 095325D9C6; Wed, 30 May 2018 23:05:52 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 30 May 2018 20:05:28 -0300 Message-Id: <20180530230528.30166-13-ehabkost@redhat.com> In-Reply-To: <20180530230528.30166-1-ehabkost@redhat.com> References: <20180530230528.30166-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 30 May 2018 23:05:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 12/12] 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: Igor Mammedov 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" From: Igor Mammedov * 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 Message-Id: <1526556607-268163-1-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- 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 cbe8df4473..ac52872cbe 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 43fb97e035..e0ca19dbfe 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1098,3 +1098,10 @@ void qtest_qmp_device_del(const char *id) qobject_unref(response1); qobject_unref(response2); } + +bool qmp_rsp_is_err(QDict *rsp) +{ + QDict *error =3D qdict_get_qdict(rsp, "error"); + qobject_unref(rsp); + return !!error; +} diff --git a/tests/numa-test.c b/tests/numa-test.c index 169213fc1c..b7a6ef8815 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': 'exit-preconfig' = }"))); + 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_unref(e); + } + qobject_unref(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 2ee441cdb3..a49cbc6fde 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"); - qobject_unref(rsp); - return !!error; -} - static void test_qmp_preconfig(void) { QDict *rsp, *ret; --=20 2.17.1