From patchwork Tue Oct 30 12:35:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Chamarthy X-Patchwork-Id: 10660855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D58CE1932 for ; Tue, 30 Oct 2018 12:37:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8958293A5 for ; Tue, 30 Oct 2018 12:37:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACBCA29663; Tue, 30 Oct 2018 12:37:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B20C293A5 for ; Tue, 30 Oct 2018 12:37:14 +0000 (UTC) Received: from localhost ([::1]:52958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHTGj-0007Ju-Qo for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 08:37:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHTFK-00060O-Tv for qemu-devel@nongnu.org; Tue, 30 Oct 2018 08:35:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHTFI-0002lh-Ok for qemu-devel@nongnu.org; Tue, 30 Oct 2018 08:35:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53802) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHTFG-0002ZC-EW for qemu-devel@nongnu.org; Tue, 30 Oct 2018 08:35:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60DBF65871 for ; Tue, 30 Oct 2018 12:35:38 +0000 (UTC) Received: from paraplu.localdomain (ovpn-112-33.ams2.redhat.com [10.36.112.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 071046046B; Tue, 30 Oct 2018 12:35:33 +0000 (UTC) From: Kashyap Chamarthy To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 13:35:24 +0100 Message-Id: <20181030123526.26415-2-kchamart@redhat.com> In-Reply-To: <20181030123526.26415-1-kchamart@redhat.com> References: <20181030123526.26415-1-kchamart@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 30 Oct 2018 12:35:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 1/3] Deprecate QMP `cpu-add` X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, ehabkost@redhat.com, Kashyap Chamarthy , armbru@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The intended functionality of QMP `cpu-add` is replaced with `device_add` (and `query-hotpluggable-cpus`). So let's deprecate `cpu-add`. A complete example of vCPU hotplug with the recommended way (using `device_add`) is provided as part of a seperate docs patch. Suggested-by: Eduardo Habkost Reviewed-by: Thomas Huth --- --- qapi/misc.json | 8 +++++++- qemu-deprecated.texi | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/qapi/misc.json b/qapi/misc.json index d450cfef21..fbee1e6d34 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -1104,7 +1104,7 @@ ## # @cpu-add: # -# Adds CPU with specified ID +# Adds CPU with specified ID. # # @id: ID of CPU to be created, valid values [0..max_cpus) # @@ -1112,6 +1112,10 @@ # # Since: 1.5 # +# Note: This command is deprecated. The `device_add` command should be +# used instead. See the `query-hotpluggable-cpus` command for +# details. +# # Example: # # -> { "execute": "cpu-add", "arguments": { "id": 2 } } @@ -3213,6 +3217,8 @@ ## # @query-hotpluggable-cpus: # +# TODO: Better documentation; currently there is none. +# # Returns: a list of HotpluggableCPU objects. # # Since: 2.7 diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 1b9c007f12..c86924ad9a 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -155,6 +155,11 @@ The ``query-cpus'' command is replaced by the ``query-cpus-fast'' command. The ``arch'' output member of the ``query-cpus-fast'' command is replaced by the ``target'' output member. +@subsection cpu-add (since 3.1) + +Use ``device_add'' for hotplugging vCPUs instead of ``cpu-add''. See +documentation of ``query-hotpluggable-cpus'' for additional details. + @section System emulator devices @subsection ivshmem (since 2.6.0) From patchwork Tue Oct 30 12:35:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Chamarthy X-Patchwork-Id: 10660857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3EF81932 for ; Tue, 30 Oct 2018 12:39:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBFA72A321 for ; Tue, 30 Oct 2018 12:39:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA1AD2A400; Tue, 30 Oct 2018 12:39:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 72A152A321 for ; Tue, 30 Oct 2018 12:39:34 +0000 (UTC) Received: from localhost ([::1]:52968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHTIz-0001ws-EZ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 08:39:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHTFS-0006Cw-AO for qemu-devel@nongnu.org; Tue, 30 Oct 2018 08:35:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHTFJ-0002o1-7g for qemu-devel@nongnu.org; Tue, 30 Oct 2018 08:35:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54848) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHTFI-0002k0-Sy for qemu-devel@nongnu.org; Tue, 30 Oct 2018 08:35:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0CF530AAD8A for ; Tue, 30 Oct 2018 12:35:43 +0000 (UTC) Received: from paraplu.localdomain (ovpn-112-33.ams2.redhat.com [10.36.112.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id F27C06046B; Tue, 30 Oct 2018 12:35:39 +0000 (UTC) From: Kashyap Chamarthy To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 13:35:25 +0100 Message-Id: <20181030123526.26415-3-kchamart@redhat.com> In-Reply-To: <20181030123526.26415-1-kchamart@redhat.com> References: <20181030123526.26415-1-kchamart@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 30 Oct 2018 12:35:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 2/3] Deprecate HMP `cpu-add` X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, ehabkost@redhat.com, Kashyap Chamarthy , armbru@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since we're deprecating the QMP `cpu-add`, let's deprecate its HMP equivalent, too. Suggested-by: Thomas Huth Signed-off-by: Kashyap Chamarthy --- hmp-commands.hx | 6 ++++-- hmp.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index db0c681f74..ba71558c25 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1849,14 +1849,16 @@ ETEXI .name = "cpu-add", .args_type = "id:i", .params = "id", - .help = "add cpu", + .help = "add cpu (deprecated, use device_add instead)", .cmd = hmp_cpu_add, }, STEXI @item cpu-add @var{id} @findex cpu-add -Add CPU with id @var{id} +Add CPU with id @var{id}. This command is deprecated, please ++use @code{device_add} instead. For details, refer to +'docs/cpu-hotplug.rst'. ETEXI { diff --git a/hmp.c b/hmp.c index 4975fa56b0..c3f3db7795 100644 --- a/hmp.c +++ b/hmp.c @@ -2353,6 +2353,8 @@ void hmp_cpu_add(Monitor *mon, const QDict *qdict) int cpuid; Error *err = NULL; + error_report("cpu_add is deprecated, please use device_add instead"); + cpuid = qdict_get_int(qdict, "id"); qmp_cpu_add(cpuid, &err); hmp_handle_error(mon, &err); From patchwork Tue Oct 30 12:35:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Chamarthy X-Patchwork-Id: 10660859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D52313BF for ; Tue, 30 Oct 2018 12:41:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 579EE2A47C for ; Tue, 30 Oct 2018 12:41:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55B102A475; Tue, 30 Oct 2018 12:41:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D83CA2A4AC for ; Tue, 30 Oct 2018 12:41:34 +0000 (UTC) Received: from localhost ([::1]:52981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHTKw-0003LF-9o for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 08:41:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHTGQ-00075H-FC for qemu-devel@nongnu.org; Tue, 30 Oct 2018 08:36:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHTGM-0003rY-6m for qemu-devel@nongnu.org; Tue, 30 Oct 2018 08:36:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51640) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHTGL-0003Wa-SA for qemu-devel@nongnu.org; Tue, 30 Oct 2018 08:36:50 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CB05305B886 for ; Tue, 30 Oct 2018 12:36:25 +0000 (UTC) Received: from paraplu.localdomain (ovpn-112-33.ams2.redhat.com [10.36.112.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09DC050C50; Tue, 30 Oct 2018 12:35:46 +0000 (UTC) From: Kashyap Chamarthy To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 13:35:26 +0100 Message-Id: <20181030123526.26415-4-kchamart@redhat.com> In-Reply-To: <20181030123526.26415-1-kchamart@redhat.com> References: <20181030123526.26415-1-kchamart@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 30 Oct 2018 12:36:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 3/3] docs: Document vCPU hotplug procedure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, ehabkost@redhat.com, Kashyap Chamarthy , armbru@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Kashyap Chamarthy --- docs/cpu-hotplug.rst | 142 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 docs/cpu-hotplug.rst diff --git a/docs/cpu-hotplug.rst b/docs/cpu-hotplug.rst new file mode 100644 index 0000000000..1c268e00b4 --- /dev/null +++ b/docs/cpu-hotplug.rst @@ -0,0 +1,142 @@ +=================== +Virtual CPU hotplug +=================== + +A complete example of vCPU hotplug (and hot-unplug) using QMP +``device_add`` and ``device_del``. + +vCPU hotplug +------------ + +(1) Launch QEMU as follows (note that the "maxcpus" is mandatory to + allow vCPU hotplug):: + + $ qemu-system-x86_64 -display none -no-user-config -m 2048 \ + -nodefaults -monitor stdio -machine pc,accel=kvm,usb=off \ + -smp 1,maxcpus=2 -cpu IvyBridge-IBRS \ + -qmp unix:/tmp/qmp-sock,server,nowait + +(2) Run 'qmp-shell' (located in the source tree, under: "scripts/qmp/) + to connect to the just-launched QEMU:: + + $> ./qmp-shell -p -v /tmp/qmp-sock + [...] + (QEMU) + +(3) Find out which CPU types could be plugged, and into which sockets:: + + (QEMU) query-hotpluggable-cpus + { + "execute": "query-hotpluggable-cpus", + "arguments": {} + } + { + "return": [ + { + "type": "IvyBridge-IBRS-x86_64-cpu", + "vcpus-count": 1, + "props": { + "socket-id": 1, + "core-id": 0, + "thread-id": 0 + } + }, + { + "qom-path": "/machine/unattached/device[0]", + "type": "IvyBridge-IBRS-x86_64-cpu", + "vcpus-count": 1, + "props": { + "socket-id": 0, + "core-id": 0, + "thread-id": 0 + } + } + ] + } + (QEMU) + +(4) The ``query-hotpluggable-cpus`` command returns an object for CPUs + that are present (containing a "qom-path" member) or which may be + hot-plugged (no "qom-path" member). From its output in step (3), we + can see that ``IvyBridge-IBRS-x86_64-cpu`` is present in socket 0, + while hot-plugging a CPU into socket 1 requires passing the listed + properties to QMP ``device_add``: + + (QEMU) device_add id=cpu-2 driver=IvyBridge-IBRS-x86_64-cpu socket-id=1 core-id=0 thread-id=0 + { + "execute": "device_add", + "arguments": { + "socket-id": 1, + "driver": "IvyBridge-IBRS-x86_64-cpu", + "id": "cpu-2", + "core-id": 0, + "thread-id": 0 + } + } + { + "return": {} + } + (QEMU) + +(5) Optionally, run QMP `query-cpus-fast` for some details about the + vCPUs:: + + (QEMU) query-cpus-fast + { + "execute": "query-cpus-fast", + "arguments": {} + } + { + "return": [ + { + "qom-path": "/machine/unattached/device[0]", + "target": "x86_64", + "thread-id": 11534, + "cpu-index": 0, + "props": { + "socket-id": 0, + "core-id": 0, + "thread-id": 0 + }, + "arch": "x86" + }, + { + "qom-path": "/machine/peripheral/cpu-2", + "target": "x86_64", + "thread-id": 12106, + "cpu-index": 1, + "props": { + "socket-id": 1, + "core-id": 0, + "thread-id": 0 + }, + "arch": "x86" + } + ] + } + (QEMU) + +vCPU hot-unplug +--------------- + +From the 'qmp-shell', invoke the QMP ``device_del`` command:: + + (QEMU) device_del id=cpu-2 + { + "execute": "device_del", + "arguments": { + "id": "cpu-2" + } + } + { + "return": {} + } + (QEMU) + +.. note:: + vCPU hot-unplug requires guest cooperation; so the ``device_del`` + command above does not guarantee vCPU removal -- it's a "request to + unplug". At this point, the guest will get a System Control + Interupt (SCI) and calls the ACPI handler for the affected vCPU + device. Then the guest kernel will bring the vCPU offline and tell + QEMU to unplug it.