From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BFD0C433EF for ; Wed, 22 Sep 2021 17:36:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CEFC4610A0 for ; Wed, 22 Sep 2021 17:36:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CEFC4610A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=greensocs.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:39824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mT6Aw-0002G0-Iu for qemu-devel@archiver.kernel.org; Wed, 22 Sep 2021 13:36:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mT4v4-0003M6-8P; Wed, 22 Sep 2021 12:16:27 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:39278) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mT4v1-0005S5-AB; Wed, 22 Sep 2021 12:16:26 -0400 Received: from crumble.bar.greensocs.com (unknown [172.17.10.6]) by beetle.greensocs.com (Postfix) with ESMTPS id 879E321ED3; Wed, 22 Sep 2021 16:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1632327361; 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=Lg6JGGOuMKgOK9bkuvAzYukD8OqEWtmOgbk2hQPItz8=; b=ND0iqKFzTzDcZ27ooxhDOEEEV8AccARG7AJHhC9a02u1e9KnwGeBRww88INrFwYdnUiGLU iWgot6Scekg2EdCjx5zulK0cCIpl/uZhww0kpehf4I9kg6qVmrIhlxI6IZCWAofixBVreB IFn8x3hm1X67NsswL2KN8XfRLNp4fgc= From: Damien Hedde To: qemu-devel@nongnu.org Subject: [RFC PATCH v2 14/16] docs/system: add doc about the initialized machine phase and an example Date: Wed, 22 Sep 2021 18:14:03 +0200 Message-Id: <20210922161405.140018-15-damien.hedde@greensocs.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210922161405.140018-1-damien.hedde@greensocs.com> References: <20210922161405.140018-1-damien.hedde@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam: Yes Received-SPF: pass client-ip=5.135.226.135; envelope-from=damien.hedde@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: Peter Maydell , "Michael S. Tsirkin" , David Hildenbrand , Peter Xu , mirela.grujic@greensocs.com, Alistair Francis , Gerd Hoffmann , Ani Sinha , Eric Blake , Stefano Stabellini , xen-devel@lists.xenproject.org, Paul Durrant , Markus Armbruster , Anthony Perard , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Eduardo Habkost , "Dr. David Alan Gilbert" , Eric Auger , Paolo Bonzini , qemu-riscv@nongnu.org, Damien Hedde , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , mark.burton@greensocs.com, edgari@xilinx.com, Igor Mammedov Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Damien Hedde --- docs/system/managed-startup.rst | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/docs/system/managed-startup.rst b/docs/system/managed-startup.rst index 9bcf98ea79..af12a10d27 100644 --- a/docs/system/managed-startup.rst +++ b/docs/system/managed-startup.rst @@ -32,4 +32,81 @@ machine, including but not limited to: - ``query-qmp-schema`` - ``query-commands`` - ``query-status`` +- ``x-machine-init`` - ``x-exit-preconfig`` + +In particular these commands allow to advance and stop qemu at different +phases of the VM creation and finally to leave the "preconfig" state. The +accessible phases are: + +- ``accel-created`` +- ``initialized`` +- ``ready`` + +The order of the phases is enforced. It is not possible to go backwards. +Note that other early phases exist, but they are not attainable with +``--preconfig``. Depending on the phase, QMP commands can be issued to modify +some part of the VM creation. + +accel-created phase +------------------- + +Initial phase entered with ``--preconfig``. + +initialized phase +----------------- + +``x-machine-init`` advances to ``initialized`` phase. During this phase, the +machine is initialized and populated with buses and devices. The following QMP +commands are available to manually populate or modify the machine: + +- ``device_add`` +- ``x-sysbus-mmio-map`` +- ``qom-set`` + +ready phase +----------- + +``x-exit-preconfig`` advances to the final phase. When entering this phase, +the VM creation finishes. "preconfig" state is then done and QEMU goes to +normal execution. + +Machine creation example +------------------------ + +The following is an example that shows how to add some devices with qmp +commands, memory map them, and add interrupts:: + + x-machine-init + + device_add driver=sysbus-memory id=rom size=0x4000 readonly=true + x-sysbus-mmio-map device=rom addr=32768 + + device_add driver=sysbus-memory id=flash size=0x80000 readonly=true + x-sysbus-mmio-map device=flash addr=536870912 + + device_add driver=sysbus-memory id=ram size=0x10000 + x-sysbus-mmio-map device=ram addr=268435456 + + device_add driver=ibex-plic id=plic + x-sysbus-mmio-map device=plic addr=1090584576 + + device_add driver=ibex-uart id=uart chardev=serial0 + x-sysbus-mmio-map device=uart addr=1073741824 + qom-set path=uart property=sysbus-irq[0] value=plic/unnamed-gpio-in[1] + qom-set path=uart property=sysbus-irq[1] value=plic/unnamed-gpio-in[2] + qom-set path=uart property=sysbus-irq[2] value=plic/unnamed-gpio-in[3] + qom-set path=uart property=sysbus-irq[3] value=plic/unnamed-gpio-in[4] + + x-exit-preconfig + +These commands reproduce a subset of the riscv32 opentitan (hw/riscv/opentitan) +machine. We can start qemu using:: + + qemu-sytem-riscv32 -preconfig -qmp unix:./qmp-sock,server \ + -machine none -cpu lowriscv-ibex -serial mon:stdio ... + +Then we just have to issue the commands, for example using `qmp-shell`. If the +previous commands were in a file named `machine.qmp`, we could do:: + + qmp-shell ./qmp-sock < machine.qmp -- 2.33.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DCC6C433F5 for ; Wed, 22 Sep 2021 18:41:59 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C66446109E for ; Wed, 22 Sep 2021 18:41:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C66446109E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=greensocs.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.193028.343820 (Exim 4.92) (envelope-from ) id 1mT7Bd-0000QG-Ht; Wed, 22 Sep 2021 18:41:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 193028.343820; Wed, 22 Sep 2021 18:41:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mT7Bd-0000Q9-E3; Wed, 22 Sep 2021 18:41:41 +0000 Received: by outflank-mailman (input) for mailman id 193028; Wed, 22 Sep 2021 18:41:40 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mT7Bb-0000Q3-7Y for xen-devel@lists.xenproject.org; Wed, 22 Sep 2021 18:41:39 +0000 Received: from beetle.greensocs.com (unknown [5.135.226.135]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b77be324-1bd4-11ec-b9cc-12813bfff9fa; Wed, 22 Sep 2021 18:41:37 +0000 (UTC) Received: from crumble.bar.greensocs.com (unknown [172.17.10.6]) by beetle.greensocs.com (Postfix) with ESMTPS id 879E321ED3; Wed, 22 Sep 2021 16:16:00 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b77be324-1bd4-11ec-b9cc-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1632327361; 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=Lg6JGGOuMKgOK9bkuvAzYukD8OqEWtmOgbk2hQPItz8=; b=ND0iqKFzTzDcZ27ooxhDOEEEV8AccARG7AJHhC9a02u1e9KnwGeBRww88INrFwYdnUiGLU iWgot6Scekg2EdCjx5zulK0cCIpl/uZhww0kpehf4I9kg6qVmrIhlxI6IZCWAofixBVreB IFn8x3hm1X67NsswL2KN8XfRLNp4fgc= From: Damien Hedde To: qemu-devel@nongnu.org Cc: Damien Hedde , Alistair Francis , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Igor Mammedov , Ani Sinha , Gerd Hoffmann , Eric Auger , Stefano Stabellini , Anthony Perard , Paul Durrant , Peter Xu , David Hildenbrand , "Dr. David Alan Gilbert" , Markus Armbruster , Eric Blake , qemu-riscv@nongnu.org, xen-devel@lists.xenproject.org, mark.burton@greensocs.com, mirela.grujic@greensocs.com, edgari@xilinx.com, Peter Maydell Subject: [RFC PATCH v2 14/16] docs/system: add doc about the initialized machine phase and an example Date: Wed, 22 Sep 2021 18:14:03 +0200 Message-Id: <20210922161405.140018-15-damien.hedde@greensocs.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210922161405.140018-1-damien.hedde@greensocs.com> References: <20210922161405.140018-1-damien.hedde@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam: Yes Signed-off-by: Damien Hedde --- docs/system/managed-startup.rst | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/docs/system/managed-startup.rst b/docs/system/managed-startup.rst index 9bcf98ea79..af12a10d27 100644 --- a/docs/system/managed-startup.rst +++ b/docs/system/managed-startup.rst @@ -32,4 +32,81 @@ machine, including but not limited to: - ``query-qmp-schema`` - ``query-commands`` - ``query-status`` +- ``x-machine-init`` - ``x-exit-preconfig`` + +In particular these commands allow to advance and stop qemu at different +phases of the VM creation and finally to leave the "preconfig" state. The +accessible phases are: + +- ``accel-created`` +- ``initialized`` +- ``ready`` + +The order of the phases is enforced. It is not possible to go backwards. +Note that other early phases exist, but they are not attainable with +``--preconfig``. Depending on the phase, QMP commands can be issued to modify +some part of the VM creation. + +accel-created phase +------------------- + +Initial phase entered with ``--preconfig``. + +initialized phase +----------------- + +``x-machine-init`` advances to ``initialized`` phase. During this phase, the +machine is initialized and populated with buses and devices. The following QMP +commands are available to manually populate or modify the machine: + +- ``device_add`` +- ``x-sysbus-mmio-map`` +- ``qom-set`` + +ready phase +----------- + +``x-exit-preconfig`` advances to the final phase. When entering this phase, +the VM creation finishes. "preconfig" state is then done and QEMU goes to +normal execution. + +Machine creation example +------------------------ + +The following is an example that shows how to add some devices with qmp +commands, memory map them, and add interrupts:: + + x-machine-init + + device_add driver=sysbus-memory id=rom size=0x4000 readonly=true + x-sysbus-mmio-map device=rom addr=32768 + + device_add driver=sysbus-memory id=flash size=0x80000 readonly=true + x-sysbus-mmio-map device=flash addr=536870912 + + device_add driver=sysbus-memory id=ram size=0x10000 + x-sysbus-mmio-map device=ram addr=268435456 + + device_add driver=ibex-plic id=plic + x-sysbus-mmio-map device=plic addr=1090584576 + + device_add driver=ibex-uart id=uart chardev=serial0 + x-sysbus-mmio-map device=uart addr=1073741824 + qom-set path=uart property=sysbus-irq[0] value=plic/unnamed-gpio-in[1] + qom-set path=uart property=sysbus-irq[1] value=plic/unnamed-gpio-in[2] + qom-set path=uart property=sysbus-irq[2] value=plic/unnamed-gpio-in[3] + qom-set path=uart property=sysbus-irq[3] value=plic/unnamed-gpio-in[4] + + x-exit-preconfig + +These commands reproduce a subset of the riscv32 opentitan (hw/riscv/opentitan) +machine. We can start qemu using:: + + qemu-sytem-riscv32 -preconfig -qmp unix:./qmp-sock,server \ + -machine none -cpu lowriscv-ibex -serial mon:stdio ... + +Then we just have to issue the commands, for example using `qmp-shell`. If the +previous commands were in a file named `machine.qmp`, we could do:: + + qmp-shell ./qmp-sock < machine.qmp -- 2.33.0