From patchwork Tue Aug 9 06:48:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dou Liyang X-Patchwork-Id: 657120 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s7lJ14FvZz9t0k for ; Tue, 9 Aug 2016 16:49:20 +1000 (AEST) Received: from localhost ([::1]:33759 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bX0qj-0005dI-Lm for incoming@patchwork.ozlabs.org; Tue, 09 Aug 2016 02:49:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bX0q4-0005Mn-5d for qemu-devel@nongnu.org; Tue, 09 Aug 2016 02:48:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bX0py-00037v-Hl for qemu-devel@nongnu.org; Tue, 09 Aug 2016 02:48:35 -0400 Received: from [59.151.112.132] (port=41632 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bX0px-00036f-5y for qemu-devel@nongnu.org; Tue, 09 Aug 2016 02:48:30 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="9710514" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Aug 2016 14:48:11 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id E8E0942C8CB6; Tue, 9 Aug 2016 14:48:09 +0800 (CST) Received: from localhost.localdomain.localdomain (10.167.226.106) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.279.2; Tue, 9 Aug 2016 14:48:09 +0800 From: Dou Liyang To: Date: Tue, 9 Aug 2016 14:48:07 +0800 Message-ID: <1470725287-28599-1-git-send-email-douly.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.5.5 MIME-Version: 1.0 X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: E8E0942C8CB6.A3458 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH v1] docs: add cpu-hotplug.txt 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: Dou Liyang , ehabkost@redhat.com, armbru@redhat.com, bharata@linux.vnet.ibm.com, imammedo@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This document describes how to use cpu hotplug in QEMU. Change log v1: From Igor's advice: 1. Remove any mentioning of apic-id from the document. 2. Remove the "device_del qom_path" from the CPU hot-unplug. 3. Fix some comment. Signed-off-by: Dou Liyang --- docs/cpu-hotplug.txt | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 docs/cpu-hotplug.txt diff --git a/docs/cpu-hotplug.txt b/docs/cpu-hotplug.txt new file mode 100644 index 0000000..2c51e27 --- /dev/null +++ b/docs/cpu-hotplug.txt @@ -0,0 +1,124 @@ +QEMU CPU hotplug +=================== + +This document explains how to use the CPU hotplug feature in QEMU, +which is present since v2.7. + +Guest support is required for CPU hotplug to work. + +CPU hot-plug +------------------- + +In order to be able to hotplug CPUs, QEMU has to be told what is the +maximum amount of CPUs the guest can grow. This is done at startup +time by means of the -smp command-line option, which has the following +format: + + -smp [cpus=]n[,maxcpus=cpus][,cores=cores][,threads=threads] + [,sockets=sockets] + +Where, + + - "cpus" set the number of CPUs to 'n' [default=1] + - "maxcpus" maximum number of CPUs, including offline VCPUs for + hotplug, etc + - "cores" number of CPU cores on one socket + - "threads= number of threads on one CPU core + - "sockets= number of discrete sockets in the system(on sPAPR, + sockets have no real meaning, it has no real effect on the + guest.) + + +For example, the following command-line: + + qemu [...] -smp 3,maxcpus=10,sockets=2,cores=2,threads=2 + +Creates a guest with 3 VCPUs and it support up to 10 VCPUs. The CPU +topology is sockets (2) * cores (2) * threads (2) and can't greater +than maxcpus. When the guest is just booted, the guest will see 3 +VCPUs. + +There are seven VCPUs can be hotplugged by socket/core/thread-ids +which should be obtained from the properties advertised by QEMU via +the QMP command query-hotpluggable-cpus or the corresponding HMP +command "info hotpluggable-cpus". + +Query possible available CPU objects +-------------------------------------- + +Before add the VCPUs, we should know the topology properties of the +possible available CPUs objects, so that we can find out the available +place (socket,core,thread) for a new VCPU. + +A monitor commands are used to list the possible CPU objects: + + (qemu) info hotpluggable-cpus + +Select the hotpluggable CPUs including "CPUInstance Properties" for +hotpluging. Such as this: + + ... + type: "qemu64-x86_64-cpu" + vcpus_count: "1" + CPUInstance Properties: + socket-id: "0" + core-id: "1" + thread-id: "0" + ... + +Hotplug CPUs +---------------------- + +A monitor commands are used to hotplug CPUs: + + - "device_add": creates a VCPU device and inserts it into the + specific place as a device + +For example, the following commands add a VCPU which id is cpu1 in +the last position of the guest's CPU sockets which was discussed +earlier by using the socket/core/thread-ids: + + (qemu) device_add qemu64-x86_64-cpu,id=cpu9,socket-id=2,core-id=0, + thread-id=1 + +Where, + + - "qemu64-x86_64-cpu" is the CPU modle. + - "id" is the unique identifier in the device sets. there must have + it. + - "socket-id/core-id/thread-id" is represented the designated position + which are gained form the above possible list of CPUs. + +It's also possible to start a guest with cpu cold-plugged into the +specific place (socket,core,thread). + +In the following command-lines example, a guest which has 3 VCPUs is +created: + + qemu [...] -smp 1,maxcpus=10,sockets=2,cores=2,threads=2 \ + -device qemu64-x86_64-cpu,id=cpu1,socket-id=1, \ + core-id=1,thread-id=0 \ + -device qemu64-x86_64-cpu,id=cpu2,socket-id=1, \ + core-id=1,thread-id=1 \ + +Two VCPUs are cold-plugged by "-device" parameter. They are in the +same socket and core with different thread-id. After that, the guest +has additional seven VCPUs to be hot-plugged when needed. + +CPU hot-unplug +------------------------ + +In order to be able to hot unplug cpu device, QEMU has the way +to remove cpu device. + + Using the ids which were assigned when you hot plugged cpus. + +A monitor commands are used to hot unplug cpus: + + - "device_del": deletes a cpu device + +For example, assuming that the cpu device with id "cpu1" exists, +the following commands tries to remove it. + + (qemu) device_del cpu1 +