From nobody Sun May 12 09:26:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1620894644; cv=none; d=zohomail.com; s=zohoarc; b=XP+dk54v17edV0YrzVM4K2U2KsfdC+rImE9PTo+wRz62SnNahqqrMhytIcH6GUOfkReZW3Q0EJX7Ju9yG7KKnxNOiQJQQxiyOnawc7jwv2uQhdXaf0QfhvbsMxB6JsMj3bEQseHycABsxXWglWvdsRfTQg2IXckFpds7cXynPu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620894644; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/atZYjSvZ3AvjWV8ApwNQtHVspelNgQxRu1GjX90r3E=; b=QA3HItCMfoNeRMzN7h2wkJ5mzeC6vV3knkeNW6eB/ClxxN/dLvjRmlD0TT1Kn8OtxraQMVlcHHRw8cnS+4cBj56/9rVfXdqJbLowgKhyze0uTdQAq6WFld0F2ZQZIUge2OGCSVDkx8pjbnwcyMJx91m9qIPWZts34frjiX+ms4E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620894644639258.25722702857695; Thu, 13 May 2021 01:30:44 -0700 (PDT) Received: from localhost ([::1]:49330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lh6jy-0008Hj-Im for importer@patchew.org; Thu, 13 May 2021 04:30:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gI-0004j2-QG for qemu-devel@nongnu.org; Thu, 13 May 2021 04:26:54 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:56634) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gF-0001Dk-Gj for qemu-devel@nongnu.org; Thu, 13 May 2021 04:26:54 -0400 Received: from localhost.localdomain (cable-24-135-22-90.dynamic.sbb.rs [24.135.22.90]) by beetle.greensocs.com (Postfix) with ESMTPSA id BBA0821C39; Thu, 13 May 2021 08:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1620894409; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/atZYjSvZ3AvjWV8ApwNQtHVspelNgQxRu1GjX90r3E=; b=6RWKqtxxRonwa5Jk6ADW3CBw51R/H13Ub6PuppW71LirFzF/KI83AZ55BpGBGSmo6EDMMN ftO6eWRZptMsD0DwvcUjBT/eDMrrjQuglkaVnifZjz+tj0KkfA8YyS9/kkwPVIGjvcBFEK YXBETqntylIG2GswkIV79fmkStN8DyY= From: Mirela Grujic To: qemu-devel@nongnu.org Subject: [RFC PATCH 1/9] vl: Allow finer control in advancing machine through phases Date: Thu, 13 May 2021 10:25:41 +0200 Message-Id: <20210513082549.114275-2-mirela.grujic@greensocs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513082549.114275-1-mirela.grujic@greensocs.com> References: <20210513082549.114275-1-mirela.grujic@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.135.226.135; envelope-from=mirela.grujic@greensocs.com; helo=beetle.greensocs.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, edgar.iglesias@xilinx.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , mark.burton@greensocs.com, Mirela Grujic , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In addition to the existing preconfig approach, which allows configuring the machine via QMP before the machine is initialized, we need the ability to configure the machine right after it's initialized. This patch will enable doing that in a scalable fashion as follows. The basic idea is to group machine initialization steps into chunks that need to be executed to advance machine initialization from one phase to the next one. Then, we add a finer control to allow executing only a chunk, i.e. to advance machine initialization to the next phase. Between the phases, we would configure the machine properties via QMP, add devices, etc. (depends on the phase). Advancing the machine to the next initialization phase would also be controllable via a QMP command. For example, the machine configuration could look like this: 1) Run QEMU with existing -preconfig command line option (this will cause QEMU to wait before the machine is initialized) Then, using QMP commands from a client: 2) Perform configuration that needs to be done before the machine is initialized 3) Advance machine initialization phase to the next (the 'next-machine-phase' command to be added) 4) Perform configuration that needs to be done after the machine is initialized 5) 'next-machine-phase' (same as in 3), etc. Available QMP commands will be specific to each phase, but the command 'next-machine-phase' will be common. In the implementation of the 'next-machine-phase' command, we will call qemu_machine_enter_phase function introduced in this patch. Function qemu_machine_enter_phase introduced here allows advancing the machine to the target phase. For the single-stepping configuration described above, the target phase would be the current machine phase + 1 (assuming some sanity checks on top). When this function is called for the PHASE_MACHINE_READY target phase (the final phase) it implements the same functionality as qmp_x_exit_preconfig before this patch. In other words, the body of this function implements the same initialization steps as before, but just groups them into chunks (if branches) and allows stepping through machine init phases. For now, the relevant target machine phases are only PHASE_MACHINE_INITIALIZED and PHASE_MACHINE_READY, but the approach allows to easily add more or split existing phases if needed. Signed-off-by: Mirela Grujic --- include/hw/qdev-core.h | 1 + hw/core/qdev.c | 5 +++ softmmu/vl.c | 87 ++++++++++++++++++++++++++++-------------- 3 files changed, 64 insertions(+), 29 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index bafc311bfa..6e52240d92 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -841,5 +841,6 @@ typedef enum MachineInitPhase { =20 extern bool phase_check(MachineInitPhase phase); extern void phase_advance(MachineInitPhase phase); +extern MachineInitPhase phase_get(void); =20 #endif diff --git a/hw/core/qdev.c b/hw/core/qdev.c index cefc5eaa0a..4a4a4d8c52 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1150,6 +1150,11 @@ void phase_advance(MachineInitPhase phase) machine_phase =3D phase; } =20 +MachineInitPhase phase_get(void) +{ + return machine_phase; +} + static const TypeInfo device_type_info =3D { .name =3D TYPE_DEVICE, .parent =3D TYPE_OBJECT, diff --git a/softmmu/vl.c b/softmmu/vl.c index aadb526138..cbf62abeb4 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2578,6 +2578,62 @@ static void qemu_machine_creation_done(void) } } =20 +static void qemu_machine_enter_phase(MachineInitPhase target_phase, + Error **errp) +{ + /* target phases before initialization are not handled here */ + if (target_phase < PHASE_MACHINE_INITIALIZED) { + error_setg(errp, "Target machine phase too early to enter this way= "); + return; + } + + /* check if machine has already passed through the target phase */ + if (phase_check(target_phase)) { + error_setg(errp, "Target machine phase already entered"); + return; + } + + /* + * if machine has not yet passed 'initialized' phase and according to = the + * target_phase it should + */ + if (target_phase >=3D PHASE_MACHINE_INITIALIZED && + phase_get() < PHASE_MACHINE_INITIALIZED) { + qemu_init_board(); + qemu_create_cli_devices(); + } + + if (target_phase >=3D PHASE_MACHINE_READY && + phase_get() < PHASE_MACHINE_READY) { + qemu_machine_creation_done(); + + if (loadvm) { + Error *local_err =3D NULL; + if (!load_snapshot(loadvm, NULL, false, NULL, &local_err)) { + error_report_err(local_err); + autostart =3D 0; + exit(1); + } + } + if (replay_mode !=3D REPLAY_MODE_NONE) { + replay_vmstate_init(); + } + + if (incoming) { + Error *local_err =3D NULL; + if (strcmp(incoming, "defer") !=3D 0) { + qmp_migrate_incoming(incoming, &local_err); + if (local_err) { + error_reportf_err(local_err, "-incoming %s: ", incomin= g); + exit(1); + } + } + } else if (autostart) { + qmp_cont(NULL); + } + } +} + void qmp_x_exit_preconfig(Error **errp) { if (phase_check(PHASE_MACHINE_INITIALIZED)) { @@ -2585,34 +2641,7 @@ void qmp_x_exit_preconfig(Error **errp) return; } =20 - qemu_init_board(); - qemu_create_cli_devices(); - qemu_machine_creation_done(); - - if (loadvm) { - Error *local_err =3D NULL; - if (!load_snapshot(loadvm, NULL, false, NULL, &local_err)) { - error_report_err(local_err); - autostart =3D 0; - exit(1); - } - } - if (replay_mode !=3D REPLAY_MODE_NONE) { - replay_vmstate_init(); - } - - if (incoming) { - Error *local_err =3D NULL; - if (strcmp(incoming, "defer") !=3D 0) { - qmp_migrate_incoming(incoming, &local_err); - if (local_err) { - error_reportf_err(local_err, "-incoming %s: ", incoming); - exit(1); - } - } - } else if (autostart) { - qmp_cont(NULL); - } + qemu_machine_enter_phase(PHASE_MACHINE_READY, errp); } =20 void qemu_init(int argc, char **argv, char **envp) @@ -3608,7 +3637,7 @@ void qemu_init(int argc, char **argv, char **envp) } =20 if (!preconfig_requested) { - qmp_x_exit_preconfig(&error_fatal); + qemu_machine_enter_phase(PHASE_MACHINE_READY, &error_fatal); } qemu_init_displays(); accel_setup_post(current_machine); --=20 2.25.1 From nobody Sun May 12 09:26:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1620895021; cv=none; d=zohomail.com; s=zohoarc; b=T9Dj5oeHRzmcN3UK6/S62jP5a8j7y44hpOz0cIVG7jOsEF+FeygAhyudLcz8NoSxDablv79fqvEyhJ6aUKjuK6Szn8idM5+l3HV+efCiXPjo8WgNd1Iv6DX0Vr6/la8Yta0fVhIw888IcYCjf+APkJPCI/WBgSe7zXEo8gr9FAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620895021; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WNo7CtIlV1nUC+MT6o5NPS0vP03TQKdfgKYWl92rKaI=; b=N4PaiqAy/bs5bHtp2STa+SM6SIzTzLPQ+pOUbT+wHrm+9i52Wm9AHhtnhuYQKZdzS32EZzIQFdXNgtX3QazCXdC24O+1AoboM9YJopwXlNTvyt3bnWvKCR/7KkO1u4gFZJYf8WYmUuOasvvYvtXshoRLqtkSyMe7pOu/p/JWZWM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620895021890958.796288008036; Thu, 13 May 2021 01:37:01 -0700 (PDT) Received: from localhost ([::1]:57364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lh6q4-0005Rc-J2 for importer@patchew.org; Thu, 13 May 2021 04:37:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gL-0004np-Cm for qemu-devel@nongnu.org; Thu, 13 May 2021 04:26:57 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:56654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gI-0001G2-W5 for qemu-devel@nongnu.org; Thu, 13 May 2021 04:26:57 -0400 Received: from localhost.localdomain (cable-24-135-22-90.dynamic.sbb.rs [24.135.22.90]) by beetle.greensocs.com (Postfix) with ESMTPSA id BE09421C73; Thu, 13 May 2021 08:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1620894413; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WNo7CtIlV1nUC+MT6o5NPS0vP03TQKdfgKYWl92rKaI=; b=raUbx9PLXmb6hfdp3VFgz2D7CZIglCEIMch2nis1ZPVm+1Myie5iyt5VAqkJMBlE9Zp/rV G9+i7vfzHT/S2wqpDUdUArIymP2RUcXPCOC60O5f8BU++9vCyRH5mtG6+8iCL506WYoqdt 9XGcMCDfem16g/DSNkXtfnBwpLG1o60= From: Mirela Grujic To: qemu-devel@nongnu.org Subject: [RFC PATCH 2/9] replace machine phase_check with machine_is_initialized/ready calls Date: Thu, 13 May 2021 10:25:42 +0200 Message-Id: <20210513082549.114275-3-mirela.grujic@greensocs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513082549.114275-1-mirela.grujic@greensocs.com> References: <20210513082549.114275-1-mirela.grujic@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.135.226.135; envelope-from=mirela.grujic@greensocs.com; helo=beetle.greensocs.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, edgar.iglesias@xilinx.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , mark.burton@greensocs.com, "Dr. David Alan Gilbert" , Eric Auger , Mirela Grujic , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Once we define MachineInitPhase in qapi, the generated enumeration constants will be prefixed with the MACHINE_INIT_PHASE_. We need to define the MachineInitPhase enum in qapi in order to add the QMP command that will query current machine init phase. Since in the existing definition of enum MachineInitPhase the enumeration constants are prefixed with PHASE_, there will be a massive find/replace to rename the existing enum constants. We'll do this in 2 phases: 1) hide explicit use of PHASE_ prefixed enums by replacing phase_check(PHASE_MACHINE_INITIALIZED) -> machine_is_initialized() phase_check(PHASE_MACHINE_READY) -> machine_is_ready() 2) rename enums Once 1) and 2) are done MachineInitPhase enum will be generated. Signed-off-by: Mirela Grujic --- include/hw/qdev-core.h | 2 ++ hw/core/machine-qmp-cmds.c | 2 +- hw/core/machine.c | 2 +- hw/core/qdev.c | 12 +++++++++++- hw/pci/pci.c | 2 +- hw/usb/core.c | 2 +- hw/virtio/virtio-iommu.c | 2 +- monitor/hmp.c | 2 +- softmmu/qdev-monitor.c | 9 ++++----- softmmu/vl.c | 2 +- ui/console.c | 2 +- 11 files changed, 25 insertions(+), 14 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 6e52240d92..5e3c6d4482 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -842,5 +842,7 @@ typedef enum MachineInitPhase { extern bool phase_check(MachineInitPhase phase); extern void phase_advance(MachineInitPhase phase); extern MachineInitPhase phase_get(void); +extern bool machine_is_initialized(void); +extern bool machine_is_ready(void); =20 #endif diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 68a942595a..be286882cc 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -149,7 +149,7 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error = **errp) =20 void qmp_set_numa_node(NumaOptions *cmd, Error **errp) { - if (phase_check(PHASE_MACHINE_INITIALIZED)) { + if (machine_is_initialized()) { error_setg(errp, "The command is permitted only before the machine= has been created"); return; } diff --git a/hw/core/machine.c b/hw/core/machine.c index 40def78183..eba046924d 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1239,7 +1239,7 @@ static NotifierList machine_init_done_notifiers =3D void qemu_add_machine_init_done_notifier(Notifier *notify) { notifier_list_add(&machine_init_done_notifiers, notify); - if (phase_check(PHASE_MACHINE_READY)) { + if (machine_is_ready()) { notify->notify(notify, NULL); } } diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 4a4a4d8c52..71906170f9 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -904,7 +904,7 @@ static void device_initfn(Object *obj) { DeviceState *dev =3D DEVICE(obj); =20 - if (phase_check(PHASE_MACHINE_READY)) { + if (machine_is_ready()) { dev->hotplugged =3D 1; qdev_hot_added =3D true; } @@ -1155,6 +1155,16 @@ MachineInitPhase phase_get(void) return machine_phase; } =20 +bool machine_is_initialized(void) +{ + return machine_phase >=3D PHASE_MACHINE_INITIALIZED; +} + +bool machine_is_ready(void) +{ + return machine_phase >=3D PHASE_MACHINE_READY; +} + static const TypeInfo device_type_info =3D { .name =3D TYPE_DEVICE, .parent =3D TYPE_OBJECT, diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 8f35e13a0c..19b584c3d1 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1071,7 +1071,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *p= ci_dev, address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_container_region, pci_dev->nam= e); =20 - if (phase_check(PHASE_MACHINE_READY)) { + if (machine_is_ready()) { pci_init_bus_master(pci_dev); } pci_dev->irq_state =3D 0; diff --git a/hw/usb/core.c b/hw/usb/core.c index 975f76250a..2ec0dea6a0 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -97,7 +97,7 @@ void usb_wakeup(USBEndpoint *ep, unsigned int stream) USBDevice *dev =3D ep->dev; USBBus *bus =3D usb_bus_from_device(dev); =20 - if (!phase_check(PHASE_MACHINE_READY)) { + if (!machine_is_ready()) { /* * This is machine init cold plug. No need to wakeup anyone, * all devices will be reset anyway. And trying to wakeup can diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 1b23e8e18c..8b1bcb2848 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -948,7 +948,7 @@ static int virtio_iommu_set_page_size_mask(IOMMUMemoryR= egion *mr, * accept it. Having a different masks is possible but the guest will = use * sub-optimal block sizes, so warn about it. */ - if (phase_check(PHASE_MACHINE_READY)) { + if (machine_is_ready()) { int new_granule =3D ctz64(new_mask); int cur_granule =3D ctz64(cur_mask); =20 diff --git a/monitor/hmp.c b/monitor/hmp.c index 6c0b33a0b1..c24511db6d 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -216,7 +216,7 @@ static bool cmd_can_preconfig(const HMPCommand *cmd) =20 static bool cmd_available(const HMPCommand *cmd) { - return phase_check(PHASE_MACHINE_READY) || cmd_can_preconfig(cmd); + return machine_is_ready() || cmd_can_preconfig(cmd); } =20 static void help_cmd_dump_one(Monitor *mon, diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index a9955b97a0..be8a892517 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -254,7 +254,7 @@ static DeviceClass *qdev_get_device_class(const char **= driver, Error **errp) =20 dc =3D DEVICE_CLASS(oc); if (!dc->user_creatable || - (phase_check(PHASE_MACHINE_READY) && !dc->hotpluggable)) { + (machine_is_ready() && !dc->hotpluggable)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver", "a pluggable device type"); return NULL; @@ -636,7 +636,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **er= rp) } } =20 - if (phase_check(PHASE_MACHINE_READY) && bus && !qbus_is_hotpluggable(b= us)) { + if (machine_is_ready() && bus && !qbus_is_hotpluggable(bus)) { error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name); return NULL; } @@ -650,7 +650,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **er= rp) dev =3D qdev_new(driver); =20 /* Check whether the hotplug is allowed by the machine */ - if (phase_check(PHASE_MACHINE_READY)) { + if (machine_is_ready()) { if (!qdev_hotplug_allowed(dev, errp)) { goto err_del_dev; } @@ -998,8 +998,7 @@ int qemu_global_option(const char *str) =20 bool qmp_command_available(const QmpCommand *cmd, Error **errp) { - if (!phase_check(PHASE_MACHINE_READY) && - !(cmd->options & QCO_ALLOW_PRECONFIG)) { + if (!machine_is_ready() && !(cmd->options & QCO_ALLOW_PRECONFIG)) { error_setg(errp, "The command '%s' is permitted only after machine= initialization has completed", cmd->name); return false; diff --git a/softmmu/vl.c b/softmmu/vl.c index cbf62abeb4..3af9743ceb 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2636,7 +2636,7 @@ static void qemu_machine_enter_phase(MachineInitPhase= target_phase, =20 void qmp_x_exit_preconfig(Error **errp) { - if (phase_check(PHASE_MACHINE_INITIALIZED)) { + if (machine_is_initialized()) { error_setg(errp, "The command is permitted only before machine ini= tialization"); return; } diff --git a/ui/console.c b/ui/console.c index 2de5f4105b..3513da6a54 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1353,7 +1353,7 @@ static QemuConsole *new_console(DisplayState *ds, con= sole_type_t console_type, if (QTAILQ_EMPTY(&consoles)) { s->index =3D 0; QTAILQ_INSERT_TAIL(&consoles, s, next); - } else if (console_type !=3D GRAPHIC_CONSOLE || phase_check(PHASE_MACH= INE_READY)) { + } else if (console_type !=3D GRAPHIC_CONSOLE || machine_is_ready()) { QemuConsole *last =3D QTAILQ_LAST(&consoles); s->index =3D last->index + 1; QTAILQ_INSERT_TAIL(&consoles, s, next); --=20 2.25.1 From nobody Sun May 12 09:26:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1620894664; cv=none; d=zohomail.com; s=zohoarc; b=lObKIkAPNxAOfqbrGUoXMC5cnKz7JeFGo+MuCIPXPRXumM2vuF+fIAtCJJaW6Y+nF5lp4t3u8Dsf2NjVVEL6GnHugzy9CqtaPME9zl1Y7Llb4DGqI5Lmqj4y5aMzE6AiJ+oVqWrsw7BB3xaF22FewVlypo4aAt6dDvT8lrPbcBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620894664; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NvrcHh9XzS4qlzg/AmEQaekxCiFH/0RIgnKkpYYShlY=; b=JJYvtwr4RDXQEDYIFvAz/th5ij3Tm2K+QEJHg1RlWsI6mx+BbUfnnLnlqyUK5l70NOwHIJjR3gbH8F9bT3MEXTjsK6VYk1H2kEHpplP61/wKG8dquTOOGVtqyvaAQ8wHwRPUn2F1hno5kio84Kxd/eA/2w0F8IBjXF8Cd5ne0Ac= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16208946645917.8753647272124; Thu, 13 May 2021 01:31:04 -0700 (PDT) Received: from localhost ([::1]:49494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lh6kH-0008OS-0N for importer@patchew.org; Thu, 13 May 2021 04:31:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gO-0004tH-3A for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:00 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:56672) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gL-0001I3-Sf for qemu-devel@nongnu.org; Thu, 13 May 2021 04:26:59 -0400 Received: from localhost.localdomain (cable-24-135-22-90.dynamic.sbb.rs [24.135.22.90]) by beetle.greensocs.com (Postfix) with ESMTPSA id A1E7D2078C; Thu, 13 May 2021 08:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1620894416; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NvrcHh9XzS4qlzg/AmEQaekxCiFH/0RIgnKkpYYShlY=; b=OoZyJtKZ8b1cGzHYl/1Q0FFqOYLpuhC/9ECPgTeUsFEwIImw0OIaamZ1PGEDJaTRrrLu39 1DLlh/hnZiNAkCyD7cboD4BuNp1SM36SjXkqbolIgi9oDf8f6gkF297l87yIvHny4b6nNp DWcnia8BdijM1IflNDkpE1FKkZ00nNo= From: Mirela Grujic To: qemu-devel@nongnu.org Subject: [RFC PATCH 3/9] rename MachineInitPhase enumeration constants Date: Thu, 13 May 2021 10:25:43 +0200 Message-Id: <20210513082549.114275-4-mirela.grujic@greensocs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513082549.114275-1-mirela.grujic@greensocs.com> References: <20210513082549.114275-1-mirela.grujic@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.135.226.135; envelope-from=mirela.grujic@greensocs.com; helo=beetle.greensocs.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, edgar.iglesias@xilinx.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , mark.burton@greensocs.com, Mirela Grujic , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This renaming is a second phase in getting the code ready for defining MachineInitPhase in qapi (enumeration constants are going to be generated and prefixed with a name derived from the enumeration type, i.e. MACHINE_INIT_PHASE_. Signed-off-by: Mirela Grujic --- include/hw/qdev-core.h | 10 +++++----- hw/core/machine.c | 4 ++-- hw/core/qdev.c | 4 ++-- softmmu/vl.c | 20 ++++++++++---------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 5e3c6d4482..dc2f63478b 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -813,30 +813,30 @@ bool qdev_should_hide_device(QemuOpts *opts); =20 typedef enum MachineInitPhase { /* current_machine is NULL. */ - PHASE_NO_MACHINE, + MACHINE_INIT_PHASE_NO_MACHINE, =20 /* current_machine is not NULL, but current_machine->accel is NULL. */ - PHASE_MACHINE_CREATED, + MACHINE_INIT_PHASE_MACHINE_CREATED, =20 /* * current_machine->accel is not NULL, but the machine properties have * not been validated and machine_class->init has not yet been called. */ - PHASE_ACCEL_CREATED, + MACHINE_INIT_PHASE_ACCEL_CREATED, =20 /* * machine_class->init has been called, thus creating any embedded * devices and validating machine properties. Devices created at * this time are considered to be cold-plugged. */ - PHASE_MACHINE_INITIALIZED, + MACHINE_INIT_PHASE_INITIALIZED, =20 /* * QEMU is ready to start CPUs and devices created at this time * are considered to be hot-plugged. The monitor is not restricted * to "preconfig" commands. */ - PHASE_MACHINE_READY, + MACHINE_INIT_PHASE_READY, } MachineInitPhase; =20 extern bool phase_check(MachineInitPhase phase); diff --git a/hw/core/machine.c b/hw/core/machine.c index eba046924d..16ce88407c 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1230,7 +1230,7 @@ void machine_run_board_init(MachineState *machine) } =20 machine_class->init(machine); - phase_advance(PHASE_MACHINE_INITIALIZED); + phase_advance(MACHINE_INIT_PHASE_INITIALIZED); } =20 static NotifierList machine_init_done_notifiers =3D @@ -1262,7 +1262,7 @@ void qdev_machine_creation_done(void) * ok, initial machine setup is done, starting from now we can * only create hotpluggable devices */ - phase_advance(PHASE_MACHINE_READY); + phase_advance(MACHINE_INIT_PHASE_READY); qdev_assert_realized_properly(); =20 /* TODO: once all bus devices are qdevified, this should be done diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 71906170f9..350f2acf74 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1157,12 +1157,12 @@ MachineInitPhase phase_get(void) =20 bool machine_is_initialized(void) { - return machine_phase >=3D PHASE_MACHINE_INITIALIZED; + return machine_phase >=3D MACHINE_INIT_PHASE_INITIALIZED; } =20 bool machine_is_ready(void) { - return machine_phase >=3D PHASE_MACHINE_READY; + return machine_phase >=3D MACHINE_INIT_PHASE_READY; } =20 static const TypeInfo device_type_info =3D { diff --git a/softmmu/vl.c b/softmmu/vl.c index 3af9743ceb..88f504aff9 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2510,7 +2510,7 @@ static void qemu_init_board(void) /* process plugin before CPUs are created, but once -smp has been pars= ed */ qemu_plugin_load_list(&plugin_list, &error_fatal); =20 - /* From here on we enter MACHINE_PHASE_INITIALIZED. */ + /* From here on we enter MACHINE_INIT_PHASE_INITIALIZED. */ machine_run_board_init(current_machine); =20 drive_check_orphaned(); @@ -2582,7 +2582,7 @@ static void qemu_machine_enter_phase(MachineInitPhase= target_phase, Error **errp) { /* target phases before initialization are not handled here */ - if (target_phase < PHASE_MACHINE_INITIALIZED) { + if (target_phase < MACHINE_INIT_PHASE_INITIALIZED) { error_setg(errp, "Target machine phase too early to enter this way= "); return; } @@ -2597,14 +2597,14 @@ static void qemu_machine_enter_phase(MachineInitPha= se target_phase, * if machine has not yet passed 'initialized' phase and according to = the * target_phase it should */ - if (target_phase >=3D PHASE_MACHINE_INITIALIZED && - phase_get() < PHASE_MACHINE_INITIALIZED) { + if (target_phase >=3D MACHINE_INIT_PHASE_INITIALIZED && + phase_get() < MACHINE_INIT_PHASE_INITIALIZED) { qemu_init_board(); qemu_create_cli_devices(); } =20 - if (target_phase >=3D PHASE_MACHINE_READY && - phase_get() < PHASE_MACHINE_READY) { + if (target_phase >=3D MACHINE_INIT_PHASE_READY && + phase_get() < MACHINE_INIT_PHASE_READY) { qemu_machine_creation_done(); =20 if (loadvm) { @@ -2641,7 +2641,7 @@ void qmp_x_exit_preconfig(Error **errp) return; } =20 - qemu_machine_enter_phase(PHASE_MACHINE_READY, errp); + qemu_machine_enter_phase(MACHINE_INIT_PHASE_READY, errp); } =20 void qemu_init(int argc, char **argv, char **envp) @@ -3580,14 +3580,14 @@ void qemu_init(int argc, char **argv, char **envp) qemu_create_early_backends(); =20 qemu_apply_machine_options(); - phase_advance(PHASE_MACHINE_CREATED); + phase_advance(MACHINE_INIT_PHASE_MACHINE_CREATED); =20 /* * Note: uses machine properties such as kernel-irqchip, must run * after machine_set_property(). */ configure_accelerators(argv[0]); - phase_advance(PHASE_ACCEL_CREATED); + phase_advance(MACHINE_INIT_PHASE_ACCEL_CREATED); =20 /* * Beware, QOM objects created before this point miss global and @@ -3637,7 +3637,7 @@ void qemu_init(int argc, char **argv, char **envp) } =20 if (!preconfig_requested) { - qemu_machine_enter_phase(PHASE_MACHINE_READY, &error_fatal); + qemu_machine_enter_phase(MACHINE_INIT_PHASE_READY, &error_fatal); } qemu_init_displays(); accel_setup_post(current_machine); --=20 2.25.1 From nobody Sun May 12 09:26:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1620895024; cv=none; d=zohomail.com; s=zohoarc; b=dM1F2VhZx7KUu1/K/HCqsazGRBpTTHQIhOd4uFqkFaLEIJN24pKy6fVJ/h6wm8kqUaUizHx1chhtL2hjUewrNhD63iuQ7jwJS6EHKGO0yA1WOExig1jFN4XpzcIhCn7IMW4XybY+Ea3HYyNiE8I0CGzAz2q1pscy7DWgStlKAFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620895024; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wJftWLtMFuO0oVdmPhys0x3dDmhseEKSmj/mwIWLtEk=; b=GK8mp482gFj8lwlREUAyHRCw+LcaMzi9RIdijxuyQbE+U4I51XlRRz8b+51jx7aV0MPWi9IWHGX5vMa3Ux29tmqQp40CjXcaTkxwLuNlzIpLN9IFHoMtgqYVQ2TzHeQ+k+jgLW1NXPLVGayD5p3FAAdQ/vHqsPi3KUqyUpEKKWs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620895024114111.90066494274095; Thu, 13 May 2021 01:37:04 -0700 (PDT) Received: from localhost ([::1]:57452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lh6q6-0005WF-TR for importer@patchew.org; Thu, 13 May 2021 04:37:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gQ-0004xh-1z for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:02 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:56696) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gO-0001Jf-10 for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:01 -0400 Received: from localhost.localdomain (cable-24-135-22-90.dynamic.sbb.rs [24.135.22.90]) by beetle.greensocs.com (Postfix) with ESMTPSA id 23DCB21EB6; Thu, 13 May 2021 08:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1620894418; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wJftWLtMFuO0oVdmPhys0x3dDmhseEKSmj/mwIWLtEk=; b=2r2d4EMvtVxrWXRdo90VgH8FN/injYxppccquadCd1gNh+o6PRcfhZP8M32lAjroDddaNM rmlmtoqc0+9ALrsL0V51xkcv0XmKkhypsdf0+AGP3V9+Ol3YT79U6vuxc1HaSA97LQ3OJF d8NhGU/bYh52TetMuHYJgcPtEjSK04w= From: Mirela Grujic To: qemu-devel@nongnu.org Subject: [RFC PATCH 4/9] qapi: Implement 'query-machine-phase' command Date: Thu, 13 May 2021 10:25:44 +0200 Message-Id: <20210513082549.114275-5-mirela.grujic@greensocs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513082549.114275-1-mirela.grujic@greensocs.com> References: <20210513082549.114275-1-mirela.grujic@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.135.226.135; envelope-from=mirela.grujic@greensocs.com; helo=beetle.greensocs.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, edgar.iglesias@xilinx.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , mark.burton@greensocs.com, Markus Armbruster , Mirela Grujic , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The command returns current machine initialization phase. From now on, the MachineInitPhase enum is generated. Signed-off-by: Mirela Grujic --- qapi/machine.json | 54 ++++++++++++++++++++++++++++++++++++++ include/hw/qdev-core.h | 29 +------------------- hw/core/machine-qmp-cmds.c | 9 +++++++ 3 files changed, 64 insertions(+), 28 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 6e90d463fc..47bdbec817 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1274,3 +1274,57 @@ ## { 'event': 'MEM_UNPLUG_ERROR', 'data': { 'device': 'str', 'msg': 'str' } } + +## +# @MachineInitPhase: +# +# Enumeration of machine initialization phases. +# +# @no-machine: machine does not exist +# +# @machine-created: machine is created, but its accelerator is not +# +# @accel-created: accelerator is created, but the machine properties have = not +# been validated and machine initialization is not done yet +# +# @initialized: machine is initialized, thus creating any embedded devices= and +# validating machine properties. Devices created at this tim= e are +# considered to be cold-plugged. +# +# @ready: QEMU is ready to start CPUs and devices created at this time are +# considered to be hot-plugged. The monitor is not restricted to +# "preconfig" commands. +## +{ 'enum': 'MachineInitPhase', + 'data': [ 'no-machine', 'machine-created', 'accel-created', 'initialized= ', + 'ready' ] } + +## +# @MachineInitPhaseStatus: +# +# Information about machine initialization phase +# +# @phase: the machine initialization phase +# +# Since: #FIXME +## +{ 'struct': 'MachineInitPhaseStatus', + 'data': { 'phase': 'MachineInitPhase' } } + +## +# @query-machine-phase: +# +# Return machine initialization phase +# +# Since: #FIXME +# +# Returns: MachineInitPhaseStatus +# +# Example: +# +# -> { "execute": "query-machine-phase" } +# <- { "return": { "phase": "initialized" } } +# +## +{ 'command': 'query-machine-phase', 'returns': 'MachineInitPhaseStatus', + 'allow-preconfig': true } diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index dc2f63478b..ca39b77ae6 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -1,6 +1,7 @@ #ifndef QDEV_CORE_H #define QDEV_CORE_H =20 +#include "qapi/qapi-types-machine.h" #include "qemu/queue.h" #include "qemu/bitmap.h" #include "qemu/rcu.h" @@ -811,34 +812,6 @@ void device_listener_unregister(DeviceListener *listen= er); */ bool qdev_should_hide_device(QemuOpts *opts); =20 -typedef enum MachineInitPhase { - /* current_machine is NULL. */ - MACHINE_INIT_PHASE_NO_MACHINE, - - /* current_machine is not NULL, but current_machine->accel is NULL. */ - MACHINE_INIT_PHASE_MACHINE_CREATED, - - /* - * current_machine->accel is not NULL, but the machine properties have - * not been validated and machine_class->init has not yet been called. - */ - MACHINE_INIT_PHASE_ACCEL_CREATED, - - /* - * machine_class->init has been called, thus creating any embedded - * devices and validating machine properties. Devices created at - * this time are considered to be cold-plugged. - */ - MACHINE_INIT_PHASE_INITIALIZED, - - /* - * QEMU is ready to start CPUs and devices created at this time - * are considered to be hot-plugged. The monitor is not restricted - * to "preconfig" commands. - */ - MACHINE_INIT_PHASE_READY, -} MachineInitPhase; - extern bool phase_check(MachineInitPhase phase); extern void phase_advance(MachineInitPhase phase); extern MachineInitPhase phase_get(void); diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index be286882cc..23f837dadb 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -198,3 +198,12 @@ MemdevList *qmp_query_memdev(Error **errp) object_child_foreach(obj, query_memdev, &list); return list; } + +MachineInitPhaseStatus *qmp_query_machine_phase(Error **errp) +{ + MachineInitPhaseStatus *status =3D g_malloc0(sizeof(*status)); + + status->phase =3D phase_get(); + + return status; +} --=20 2.25.1 From nobody Sun May 12 09:26:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1620895299; cv=none; d=zohomail.com; s=zohoarc; b=av+RVKgP3qhkXCm/ti3X3RTyzRbO0P3dWrd14F1Xhf6iYNF4ntYzPEe89L2vvzJ1ANfv9Ul4oxbNTxRW5qRITVI5DAeQ5f7+r0MoovQN6Ku1Y6mTnqCKG1bW29SXKuSguSEQnVcDFGmfi7O9U7yTrBRDfVK7xGcXq+iAUTOh4HM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620895299; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0L9WVsHpVsn+U2PyClRd9i7mpiz97H6Qub00HmSwQSE=; b=ghacHbE0UZ7YXh8TrdTM6Go17GGPDtnWWq7tjztqlzwRYNjmua0sazUYsTxQAPfhn02Set56EfhlgUCiRDSantfpOBSP591XFEToloCnH6BcgOkoYh0f5uRoHg5pcdVlCHiXJzxVlwgY1aSNgZ0vrc3QDgx6iB5Wd1V+HRHYgns= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620895299161465.15870460865096; Thu, 13 May 2021 01:41:39 -0700 (PDT) Received: from localhost ([::1]:37658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lh6uX-0002s5-T6 for importer@patchew.org; Thu, 13 May 2021 04:41:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gT-000578-Q1 for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:05 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:56710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gR-0001Lq-RL for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:05 -0400 Received: from localhost.localdomain (cable-24-135-22-90.dynamic.sbb.rs [24.135.22.90]) by beetle.greensocs.com (Postfix) with ESMTPSA id 41C3721CCE; Thu, 13 May 2021 08:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1620894422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0L9WVsHpVsn+U2PyClRd9i7mpiz97H6Qub00HmSwQSE=; b=2Vlx9oSJGolKPfctJ0VAuWkd245ExgVz58AF9KHlbGTgNVFXAqF4QYImM0C6JpMrN0N8vA 4Vc0c+0OG6ZBi+jSH7yUNzhl5rNN9nOVj5EJ6QhN7VNfbTzBbOQhoWX9Bjl63QD1wiU9yi dOGo3LKxgySvQxpD4ZHjTAqG0UkKlgQ= From: Mirela Grujic To: qemu-devel@nongnu.org Subject: [RFC PATCH 5/9] qapi: Implement 'next-machine-phase' command Date: Thu, 13 May 2021 10:25:45 +0200 Message-Id: <20210513082549.114275-6-mirela.grujic@greensocs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513082549.114275-1-mirela.grujic@greensocs.com> References: <20210513082549.114275-1-mirela.grujic@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.135.226.135; envelope-from=mirela.grujic@greensocs.com; helo=beetle.greensocs.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, edgar.iglesias@xilinx.com, Eduardo Habkost , mark.burton@greensocs.com, Markus Armbruster , Mirela Grujic , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This command will be used to control via QMP the advancing of machine through initialization phases. The feature is needed to enable the machine configuration via QMP. The command triggers QEMU to advance the machine to the next init phase, i.e. to execute initialization steps required to enter the next phase. The command is used in combination with -preconfig command line option. Note: advancing the machine to the final phase has the same effect as executing 'x-exit-preconfig' command. Signed-off-by: Mirela Grujic --- qapi/machine.json | 24 ++++++++++++++++++++++++ include/sysemu/sysemu.h | 3 +++ hw/core/machine-qmp-cmds.c | 12 ++++++++++++ softmmu/vl.c | 3 +-- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 47bdbec817..968d67dd95 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1328,3 +1328,27 @@ ## { 'command': 'query-machine-phase', 'returns': 'MachineInitPhaseStatus', 'allow-preconfig': true } + +## +# @next-machine-phase: +# +# Increment machine initialization phase +# +# Since: #FIXME +# +# Returns: If successful, nothing +# +# Notes: This command will trigger QEMU to execute initialization steps +# that are required to enter the next machine initialization phase. +# If by incrementing the initialization phase the machine reaches +# the final phase, the guest will start running immediately unless +# the -S option is used. The command is available only if the +# -preconfig command line option was passed. +# +# Example: +# +# -> { "execute": "next-machine-phase" } +# <- { "return": {} } +# +## +{ 'command': 'next-machine-phase', 'allow-preconfig': true } diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 8fae667172..0df06d095d 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -2,6 +2,7 @@ #define SYSEMU_H /* Misc. things related to the system emulator. */ =20 +#include "hw/qdev-core.h" #include "qemu/timer.h" #include "qemu/notify.h" #include "qemu/uuid.h" @@ -20,6 +21,8 @@ void qemu_run_machine_init_done_notifiers(void); void qemu_add_machine_init_done_notifier(Notifier *notify); void qemu_remove_machine_init_done_notifier(Notifier *notify); =20 +void qemu_machine_enter_phase(MachineInitPhase target_phase, Error **errp); + void configure_rtc(QemuOpts *opts); =20 void qemu_init_subsystems(void); diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 23f837dadb..8aa743d59b 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -207,3 +207,15 @@ MachineInitPhaseStatus *qmp_query_machine_phase(Error = **errp) =20 return status; } + +void qmp_next_machine_phase(Error **errp) +{ + MachineInitPhase target_phase =3D phase_get() + 1; + + if (target_phase >=3D MACHINE_INIT_PHASE__MAX) { + error_setg(errp, "Cannot increment machine init phase any further"= ); + return; + } + + qemu_machine_enter_phase(target_phase, errp); +} diff --git a/softmmu/vl.c b/softmmu/vl.c index 88f504aff9..0f402806f5 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2578,8 +2578,7 @@ static void qemu_machine_creation_done(void) } } =20 -static void qemu_machine_enter_phase(MachineInitPhase target_phase, - Error **errp) +void qemu_machine_enter_phase(MachineInitPhase target_phase, Error **errp) { /* target phases before initialization are not handled here */ if (target_phase < MACHINE_INIT_PHASE_INITIALIZED) { --=20 2.25.1 From nobody Sun May 12 09:26:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1620894717; cv=none; d=zohomail.com; s=zohoarc; b=cR4SFuNP7FMKXYPXtdtQ8iDgtKrPGhJI/xTeAEcIOx9gNm8WTBBoCey5V717LhBAPcXmlqR7uC5EaVXLmSJQ1kmlNa+H6yulFfnlYpa/jSFk949kYRYIbcJ0v7XJdvKMmSJiLsejxrzRe6BjiPnaer7N7VNSuxpikjwjNgGhPOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620894717; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=A6fBhBS3b7o3WLpluUkd8tn+mi7/KDouKZJvPHu/ugo=; b=IX14xu+LiDl7pg9LuhCAm/Q6iORWd53yt97Vees4AAixrBAcBSbbD+eHW4BzVAW6urA171y9fdo5HUu5O1rGjxxei9LEkaiwasrldMS6X+/GVC+tpmyt7eenYu6IEusj2nuyHCdkmE6rjbgxyYRGMqR/u25t/RPzAVkWcpehGCU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620894717817130.66832869511313; Thu, 13 May 2021 01:31:57 -0700 (PDT) Received: from localhost ([::1]:51134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lh6lA-00015Z-KM for importer@patchew.org; Thu, 13 May 2021 04:31:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gV-0005B7-Gd for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:07 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:56732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gT-0001Ni-Ki for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:07 -0400 Received: from localhost.localdomain (cable-24-135-22-90.dynamic.sbb.rs [24.135.22.90]) by beetle.greensocs.com (Postfix) with ESMTPSA id 093CB21EC1; Thu, 13 May 2021 08:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1620894424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A6fBhBS3b7o3WLpluUkd8tn+mi7/KDouKZJvPHu/ugo=; b=UaDR4nwW8dPHDuAD7C1U81Q8pEXmSiWeCoDVQ8bwC+IEexuU7/y8qCvHysjvPgo7COoAyj co/hZrTCk6jkCXNDFzwKnSfZuYL2poHY0ZdLLMMZCrsToeM4vYTbtuiJOc3sj9CCo+3cJv VaUf7dg+49ipz6e/baMsYBN8slb/Uw8= From: Mirela Grujic To: qemu-devel@nongnu.org Subject: [RFC PATCH 6/9] qapi: Implement 'advance-machine-phase' command Date: Thu, 13 May 2021 10:25:46 +0200 Message-Id: <20210513082549.114275-7-mirela.grujic@greensocs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513082549.114275-1-mirela.grujic@greensocs.com> References: <20210513082549.114275-1-mirela.grujic@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.135.226.135; envelope-from=mirela.grujic@greensocs.com; helo=beetle.greensocs.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, edgar.iglesias@xilinx.com, Eduardo Habkost , mark.burton@greensocs.com, Markus Armbruster , Mirela Grujic Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The command takes the target initialization phase as the argument and triggers QEMU to advance the machine to the target phase (i.e. execute all initialization steps required to enter the target phase). This command would be used as an alternative to 'next-machine-phase' if it's more convenient to jump to a target initialization phase than to single-step through phases. The command is used in combination with the -preconfig CLI option. Note: advancing the machine to the 'ready' phase has the same effect as executing the 'x-exit-preconfig' command when the machine is in 'accel-created' phase. Signed-off-by: Mirela Grujic --- qapi/machine.json | 26 ++++++++++++++++++++++++++ hw/core/machine-qmp-cmds.c | 10 ++++++++++ 2 files changed, 36 insertions(+) diff --git a/qapi/machine.json b/qapi/machine.json index 968d67dd95..31872aae72 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1352,3 +1352,29 @@ # ## { 'command': 'next-machine-phase', 'allow-preconfig': true } + +## +# @advance-machine-phase: +# +# Advance machine initialization phase to the target phase +# +# @phase: target machine initialization phase +# +# Since: #FIXME +# +# Returns: If successful, nothing +# +# Notes: This command will trigger QEMU to execute initialization steps +# that are required to enter the target machine initialization phas= e. +# If the target phase is the final initialization phase, the guest = will +# start running immediately unless the -S option is used. The comma= nd +# is available only if the -preconfig command line option was passe= d. +# +# Example: +# +# -> { "execute": "advance-machine-phase", "arguments": { "phase": "ready"= } } +# <- { "return": {} } +# +## +{ 'command': 'advance-machine-phase', 'data' : {'phase': 'MachineInitPhase= '}, + 'allow-preconfig': true } diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 8aa743d59b..6b21a3fdd5 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -219,3 +219,13 @@ void qmp_next_machine_phase(Error **errp) =20 qemu_machine_enter_phase(target_phase, errp); } + +void qmp_advance_machine_phase(MachineInitPhase phase, Error **errp) +{ + if (phase_get() =3D=3D phase) { + error_setg(errp, "Machine is already in the target phase"); + return; + } + + qemu_machine_enter_phase(phase, errp); +} --=20 2.25.1 From nobody Sun May 12 09:26:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1620895306; cv=none; d=zohomail.com; s=zohoarc; b=JAQ7VqIXZdCxljmf1C9xpRuQLFXDp3R58sJfK1FT8xLAZxMGN/7C3AmoDyQlc6BAEvROI10vhdGjrA+rLFmy3/aIn1eiDLaNdh3oRs/kz6uKpgVz3oGIxXwhbNZ1pw0rqIdVM4Dg9p0ZGK/fstxGpPE3hF+lfLlzhAm+ioSIiNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620895306; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AiWLtyGLuAVcM/hrboY5jmDN8vqn4i469A740x/y/Kg=; b=VW7/vSWGsEzgOpDf7bj8a+olqoTnBJGf5s1rv6QviubP2+HiTvsBRw8f0qqr/k4H7PfDawwOSYlqdPPW+ga/knt282E5Jj/hywP3VrzgKGyrcFotSr5BXiBkky4IjelM7A4ESYlPzJiGbWysGLGJFw9Ft8MeknLimPOeJASNgTk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620895306181917.4824731853591; Thu, 13 May 2021 01:41:46 -0700 (PDT) Received: from localhost ([::1]:37718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lh6ue-0002ub-1N for importer@patchew.org; Thu, 13 May 2021 04:41:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gX-0005F6-Nq for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:10 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:56756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gV-0001OX-G8 for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:09 -0400 Received: from localhost.localdomain (cable-24-135-22-90.dynamic.sbb.rs [24.135.22.90]) by beetle.greensocs.com (Postfix) with ESMTPSA id CE4D421EC0; Thu, 13 May 2021 08:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1620894426; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AiWLtyGLuAVcM/hrboY5jmDN8vqn4i469A740x/y/Kg=; b=yMdj6Tp72RYttVCPYYTbmj9P0F/jPzmLRQ47VXP0H6lZgFyC9/e3fjyEaWGdJ6+xWUnDFT ExZCL9knve8jbSJXi927TWa82p9zqYKGB9SziZdpFs6RoHFcpOCAG3RhIr7tPlic4k6pLu OdN6ScHgVi1Ar4tKpDRo50Fl3LZMY0A= From: Mirela Grujic To: qemu-devel@nongnu.org Subject: [RFC PATCH 7/9] qdev-monitor: Restructure and fix the check for command availability Date: Thu, 13 May 2021 10:25:47 +0200 Message-Id: <20210513082549.114275-8-mirela.grujic@greensocs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513082549.114275-1-mirela.grujic@greensocs.com> References: <20210513082549.114275-1-mirela.grujic@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.135.226.135; envelope-from=mirela.grujic@greensocs.com; helo=beetle.greensocs.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, edgar.iglesias@xilinx.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , mark.burton@greensocs.com, Mirela Grujic , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The existing code had to be restructured to make room for adding checks that are specific to the machine phases. The fix is related to the way that commands with the 'allow-preconfig' option are treated. Commands labelled with the 'allow-preconfig' option were meant to be allowed during the 'preconfig' state, i.e. before the machine is initialized. The equivalent of 'preconfig' state (after its removal) is machine init phase MACHINE_INIT_PHASE_ACCEL_CREATED. Therefore, commands with 'allow-preconfig' option should be allowed to run while the machine is in MACHINE_INIT_PHASE_ACCEL_CREATED phase. Before this patch, those commands were allowed to run if the machine is not ready, which includes three more phases besides the accel-created phase. Since there were no means to enter other phases via QMP, the implementation was fine. However, with the introduction of 'next-machine-phase' and 'advance-machine-phase' commands, one could enter machine 'initialized' phase and still have available 'preconfig' commands, which is incorrect. This patch makes available 'allow-preconfig' commands only when they're needed - before the machine is initialized, in the accel-created phase. To enable a command after the machine gets initialized and before it becomes ready, one should use 'allow-init-config' option that will be introduced in the following patch. Signed-off-by: Mirela Grujic --- softmmu/qdev-monitor.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index be8a892517..448f9dbb6f 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -998,10 +998,19 @@ int qemu_global_option(const char *str) =20 bool qmp_command_available(const QmpCommand *cmd, Error **errp) { - if (!machine_is_ready() && !(cmd->options & QCO_ALLOW_PRECONFIG)) { - error_setg(errp, "The command '%s' is permitted only after machine= initialization has completed", - cmd->name); - return false; + switch (phase_get()) { + case MACHINE_INIT_PHASE_ACCEL_CREATED: + if (cmd->options & QCO_ALLOW_PRECONFIG) { + return true; + } + break; + case MACHINE_INIT_PHASE_READY: + /* All commands are available when the machine is ready */ + return true; + default: + break; } - return true; + error_setg(errp, "The command '%s' is not permitted at this phase", + cmd->name); + return false; } --=20 2.25.1 From nobody Sun May 12 09:26:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1620895018; cv=none; d=zohomail.com; s=zohoarc; b=k47Dvg6ADPsul0lIfIKvSmNB5qZv1n4EszFOyNQ8Vtqwx1g/Lpm7kENbcoYQn5h2AI1s4tidhvSlPnaJpVrLiV4O/qA9h2xYf0obQCy6Zpm7r7wr+oSYI5mLDh3ikaLSOWulUco3T5Vve6Z3Q2wHp6Tg1fgQmZcDBbuXcuaEuY8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620895018; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OYt2ioAwjPKTG0t8HzXEn0rQ8QVS2WLAxNP177SPzXc=; b=gQGlTtBtccifLuBOsRfDM9A+jetNFOYbiohSg2MpkZWZNT5oSyJpxBPJeRSxq3pFCfjLSGucsOUrYsW4FGKdow3scXQQQRmwGnbxQqbSP2Cnria++FLuNM3ZHfFocKBM8+oy/QYYtog8omJZI8Uh0Kz1s1jHtKO/v60ozR2KjBU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16208950186771022.4611976343933; Thu, 13 May 2021 01:36:58 -0700 (PDT) Received: from localhost ([::1]:57278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lh6q0-0005ML-Sy for importer@patchew.org; Thu, 13 May 2021 04:36:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gd-0005Im-VA for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:16 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:56778) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gY-0001Q9-OG for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:15 -0400 Received: from localhost.localdomain (cable-24-135-22-90.dynamic.sbb.rs [24.135.22.90]) by beetle.greensocs.com (Postfix) with ESMTPSA id 93E6421EC3; Thu, 13 May 2021 08:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1620894429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OYt2ioAwjPKTG0t8HzXEn0rQ8QVS2WLAxNP177SPzXc=; b=UyJXGClMRjKE0Z9Se5k9COtmD+tDArGZyIn64xgQ3bVfghk7cBON809toGvYvJrsJUn7hX Zv3QJWttSPi644rKvCJJruS7gU8+5FoxE257bDMMz6Zx3CrkpvoOs8iFX5klXZ45d4R+DF RaH0aXv0ILggiSQVWKN0htJwkcP3xwA= From: Mirela Grujic To: qemu-devel@nongnu.org Subject: [RFC PATCH 8/9] qapi: Introduce 'allow-init-config' option Date: Thu, 13 May 2021 10:25:48 +0200 Message-Id: <20210513082549.114275-9-mirela.grujic@greensocs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513082549.114275-1-mirela.grujic@greensocs.com> References: <20210513082549.114275-1-mirela.grujic@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.135.226.135; envelope-from=mirela.grujic@greensocs.com; helo=beetle.greensocs.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, edgar.iglesias@xilinx.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Peter Maydell , Michael Roth , mark.burton@greensocs.com, Markus Armbruster , Mirela Grujic , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This option will be used to select the commands which are allowed to execute during the MACHINE_INIT_PHASE_INITIALIZED machine phase. Signed-off-by: Mirela Grujic --- docs/sphinx/qapidoc.py | 2 +- include/qapi/qmp/dispatch.h | 1 + softmmu/qdev-monitor.c | 5 +++++ scripts/qapi/commands.py | 10 +++++++--- scripts/qapi/expr.py | 5 +++-- scripts/qapi/introspect.py | 3 ++- scripts/qapi/schema.py | 10 ++++++---- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py index b7a2d39c10..5432560480 100644 --- a/docs/sphinx/qapidoc.py +++ b/docs/sphinx/qapidoc.py @@ -332,7 +332,7 @@ def visit_alternate_type(self, name, info, ifcond, feat= ures, variants): =20 def visit_command(self, name, info, ifcond, features, arg_type, ret_type, gen, success_response, boxed, allow_oob, - allow_preconfig, coroutine): + allow_preconfig, coroutine, allow_init_config): doc =3D self._cur_doc self._add_doc('Command', self._nodes_for_arguments(doc, diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index 075203dc67..ecdfc9c444 100644 --- a/include/qapi/qmp/dispatch.h +++ b/include/qapi/qmp/dispatch.h @@ -27,6 +27,7 @@ typedef enum QmpCommandOptions QCO_ALLOW_PRECONFIG =3D (1U << 2), QCO_COROUTINE =3D (1U << 3), QCO_DEPRECATED =3D (1U << 4), + QCO_ALLOW_INIT_CONFIG =3D (1U << 5), } QmpCommandOptions; =20 typedef struct QmpCommand diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 448f9dbb6f..92423f92db 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -1004,6 +1004,11 @@ bool qmp_command_available(const QmpCommand *cmd, Er= ror **errp) return true; } break; + case MACHINE_INIT_PHASE_INITIALIZED: + if (cmd->options & QCO_ALLOW_INIT_CONFIG) { + return true; + } + break; case MACHINE_INIT_PHASE_READY: /* All commands are available when the machine is ready */ return true; diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 0e13d51054..cc8fc89384 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -214,7 +214,8 @@ def gen_register_command(name: str, success_response: bool, allow_oob: bool, allow_preconfig: bool, - coroutine: bool) -> str: + coroutine: bool, + allow_init_config: bool) -> str: options =3D [] =20 if 'deprecated' in [f.name for f in features]: @@ -228,6 +229,8 @@ def gen_register_command(name: str, options +=3D ['QCO_ALLOW_PRECONFIG'] if coroutine: options +=3D ['QCO_COROUTINE'] + if allow_init_config: + options +=3D ['QCO_ALLOW_INIT_CONFIG'] =20 if not options: options =3D ['QCO_NO_OPTIONS'] @@ -310,7 +313,8 @@ def visit_command(self, boxed: bool, allow_oob: bool, allow_preconfig: bool, - coroutine: bool) -> None: + coroutine: bool, + allow_init_config: bool) -> None: if not gen: return # FIXME: If T is a user-defined type, the user is responsible @@ -331,7 +335,7 @@ def visit_command(self, with ifcontext(ifcond, self._genh, self._genc): self._genc.add(gen_register_command( name, features, success_response, allow_oob, - allow_preconfig, coroutine)) + allow_preconfig, coroutine, allow_init_config)) =20 =20 def gen_commands(schema: QAPISchema, diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 540b3982b1..45031c950c 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -107,7 +107,8 @@ def check_flags(expr, info): if key in expr and expr[key] is not False: raise QAPISemError( info, "flag '%s' may only use false value" % key) - for key in ['boxed', 'allow-oob', 'allow-preconfig', 'coroutine']: + for key in ['boxed', 'allow-oob', 'allow-preconfig', 'coroutine', + 'allow-init-config']: if key in expr and expr[key] is not True: raise QAPISemError( info, "flag '%s' may only use true value" % key) @@ -378,7 +379,7 @@ def check_exprs(exprs): ['command'], ['data', 'returns', 'boxed', 'if', 'features', 'gen', 'success-response', 'allow-oob', - 'allow-preconfig', 'coroutine']) + 'allow-preconfig', 'coroutine', 'allow-init-config= ']) normalize_members(expr.get('data')) check_command(expr, info) elif meta =3D=3D 'event': diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 9a348ca2e5..fccc67c6d4 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -353,7 +353,8 @@ def visit_command(self, name: str, info: Optional[QAPIS= ourceInfo], arg_type: Optional[QAPISchemaObjectType], ret_type: Optional[QAPISchemaType], gen: bool, success_response: bool, boxed: bool, allow_oob: bool, - allow_preconfig: bool, coroutine: bool) -> None: + allow_preconfig: bool, coroutine: bool, + allow_init_config: bool) -> None: assert self._schema is not None =20 arg_type =3D arg_type or self._schema.the_empty_object_type diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 703b446fd2..135f37d358 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -130,7 +130,7 @@ def visit_alternate_type(self, name, info, ifcond, feat= ures, variants): =20 def visit_command(self, name, info, ifcond, features, arg_type, ret_type, gen, success_response, boxed, - allow_oob, allow_preconfig, coroutine): + allow_oob, allow_preconfig, coroutine, allow_init_co= nfig): pass =20 def visit_event(self, name, info, ifcond, features, arg_type, boxed): @@ -746,7 +746,7 @@ class QAPISchemaCommand(QAPISchemaEntity): def __init__(self, name, info, doc, ifcond, features, arg_type, ret_type, gen, success_response, boxed, allow_oob, allow_preconfig, - coroutine): + coroutine, allow_init_config): super().__init__(name, info, doc, ifcond, features) assert not arg_type or isinstance(arg_type, str) assert not ret_type or isinstance(ret_type, str) @@ -760,6 +760,7 @@ def __init__(self, name, info, doc, ifcond, features, self.allow_oob =3D allow_oob self.allow_preconfig =3D allow_preconfig self.coroutine =3D coroutine + self.allow_init_config =3D allow_init_config =20 def check(self, schema): super().check(schema) @@ -803,7 +804,7 @@ def visit(self, visitor): self.name, self.info, self.ifcond, self.features, self.arg_type, self.ret_type, self.gen, self.success_response, self.boxed, self.allow_oob, self.allow_preconfig, - self.coroutine) + self.coroutine, self.allow_init_config) =20 =20 class QAPISchemaEvent(QAPISchemaEntity): @@ -1111,6 +1112,7 @@ def _def_command(self, expr, info, doc): allow_oob =3D expr.get('allow-oob', False) allow_preconfig =3D expr.get('allow-preconfig', False) coroutine =3D expr.get('coroutine', False) + allow_init_config =3D expr.get('allow-init-config', False) ifcond =3D expr.get('if') features =3D self._make_features(expr.get('features'), info) if isinstance(data, OrderedDict): @@ -1124,7 +1126,7 @@ def _def_command(self, expr, info, doc): data, rets, gen, success_response, boxed, allow_oob, allow_preconf= ig, - coroutine)) + coroutine, allow_init_config)) =20 def _def_event(self, expr, info, doc): name =3D expr['event'] --=20 2.25.1 From nobody Sun May 12 09:26:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1620895692; cv=none; d=zohomail.com; s=zohoarc; b=KXFoXQIr3qR5lNLiX2r9szIf+8o6Nm/chlDNkywd1TRxgjbXFHcKnYsTDSX8uH/JgFMAeEhCLB+fwZ7MGlNjv824pgfX2CV63b8vpVqlFmt2XGRkNj4VCVrxD1qi7Jc1LqMqPDv1duwj49GvTwR6jEecQVf3WALFxFfgJdkwCP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620895692; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kgJPQXOU6NHeyg5t7nw6JCc7Cpd8OiIZ0yXW23WKC/M=; b=nnrBoGc1wq57inq6MFCR9MZfT0V/c69djt9GFzBu8lbIhBYCpMDNbThNMy+OoPp45cd1cbPmfD66RiFA6H2tlUkTeappbWZpetxQ4t77OhtiN3nmwlLQLeJmTXuLDd+p3G2eAm9O//802+TxWoxqKsk0rZZFLQLvbJv0Gh43VNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620895692748579.8129096994226; Thu, 13 May 2021 01:48:12 -0700 (PDT) Received: from localhost ([::1]:44532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lh70s-0007m8-Nq for importer@patchew.org; Thu, 13 May 2021 04:48:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6gc-0005Hd-Jo for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:14 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:56786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh6ga-0001Ry-Dy for qemu-devel@nongnu.org; Thu, 13 May 2021 04:27:14 -0400 Received: from localhost.localdomain (cable-24-135-22-90.dynamic.sbb.rs [24.135.22.90]) by beetle.greensocs.com (Postfix) with ESMTPSA id 7AF0621EC6; Thu, 13 May 2021 08:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1620894431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kgJPQXOU6NHeyg5t7nw6JCc7Cpd8OiIZ0yXW23WKC/M=; b=uhZGK8/o6HFjF8mYeT8B06LQ6XuwE8fqdDgspYtoylU84kNfUJPkh/gtE8ZIdUHYnKfVYo TRxsxNtn08raeW0vH8BaHcwcNlfhBWYyEyAqCF9BqaehctSnnVhneO+a/k5QTAdFNOoqc8 ZSwiJRLNJG+XnD3wfyIzWQUyZGZpH5I= From: Mirela Grujic To: qemu-devel@nongnu.org Subject: [RFC PATCH 9/9] qapi: Allow some commands to be executed in machine 'initialized' phase Date: Thu, 13 May 2021 10:25:49 +0200 Message-Id: <20210513082549.114275-10-mirela.grujic@greensocs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210513082549.114275-1-mirela.grujic@greensocs.com> References: <20210513082549.114275-1-mirela.grujic@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.135.226.135; envelope-from=mirela.grujic@greensocs.com; helo=beetle.greensocs.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, edgar.iglesias@xilinx.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , mark.burton@greensocs.com, "Dr. David Alan Gilbert" , Markus Armbruster , Mirela Grujic , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The following commands are allowed to execute during the machine 'initialized' phase (enabled with 'allow-init-config' option): 1) query-machine-phase 2) next-machine-phase 3) advance-machine-phase 3) device_add Note: for device_add command in qdev.json adding the 'allow-init-config' option has no effect because the command appears to bypass QAPI (see TODO at qapi/qdev.json:61). The option is added there solely to document the intent. For the same reason, the flags have to be explicitly set in monitor_init_qmp_commands() when the device_add command is registered. Signed-off-by: Mirela Grujic --- qapi/machine.json | 7 ++++--- qapi/qdev.json | 3 ++- monitor/misc.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 31872aae72..c77ea03acb 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1327,7 +1327,7 @@ # ## { 'command': 'query-machine-phase', 'returns': 'MachineInitPhaseStatus', - 'allow-preconfig': true } + 'allow-preconfig': true, 'allow-init-config': true } =20 ## # @next-machine-phase: @@ -1351,7 +1351,8 @@ # <- { "return": {} } # ## -{ 'command': 'next-machine-phase', 'allow-preconfig': true } +{ 'command': 'next-machine-phase', 'allow-preconfig': true, + 'allow-init-config': true } =20 ## # @advance-machine-phase: @@ -1377,4 +1378,4 @@ # ## { 'command': 'advance-machine-phase', 'data' : {'phase': 'MachineInitPhase= '}, - 'allow-preconfig': true } + 'allow-preconfig': true, 'allow-init-config': true } diff --git a/qapi/qdev.json b/qapi/qdev.json index b83178220b..2706ef3efa 100644 --- a/qapi/qdev.json +++ b/qapi/qdev.json @@ -67,7 +67,8 @@ ## { 'command': 'device_add', 'data': {'driver': 'str', '*bus': 'str', '*id': 'str'}, - 'gen': false } # so we can get the additional arguments + 'gen': false, # so we can get the additional arguments + 'allow-init-config': true } =20 ## # @device_del: diff --git a/monitor/misc.c b/monitor/misc.c index 55f3744053..88a0edff0a 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -232,7 +232,7 @@ static void monitor_init_qmp_commands(void) qmp_init_marshal(&qmp_commands); =20 qmp_register_command(&qmp_commands, "device_add", qmp_device_add, - QCO_NO_OPTIONS); + QCO_ALLOW_INIT_CONFIG); =20 QTAILQ_INIT(&qmp_cap_negotiation_commands); qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities", --=20 2.25.1