From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbl1o-0001vu-B1 for qemu-devel@nongnu.org; Mon, 22 Aug 2016 04:56:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bbl1j-0008EY-BI for qemu-devel@nongnu.org; Mon, 22 Aug 2016 04:56:19 -0400 Received: from mailpro.odiso.net ([89.248.211.110]:48550) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbl1j-0008DU-1V for qemu-devel@nongnu.org; Mon, 22 Aug 2016 04:56:15 -0400 Date: Mon, 22 Aug 2016 10:56:05 +0200 (CEST) From: Alexandre DERUMIER Message-ID: <218747645.338872.1471856165532.JavaMail.zimbra@oxygem.tv> In-Reply-To: <1471485050-26747-1-git-send-email-douly.fnst@cn.fujitsu.com> References: <1471485050-26747-1-git-send-email-douly.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v7] docs: add cpu-hotplug.txt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dou Liyang Cc: qemu-devel , drjones@redhat.com, ehabkost , Markus Armbruster , bharata@linux.vnet.ibm.com, Fam Zheng , Igor Mammedov , david@gibson.dropbear.id.au Hello, I'm looking to implement cpu hotplug, and I have a question about cpu flags currently I have something like -cpu qemu64,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,enforce -smp 4,sockets=3D2,cores=3D2,maxcpus=3D4 Does I need to define flags like: -smp 2,sockets=3D2,cores=3D2,maxcpus=3D4 -device qemu64-x86_64-cpu,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,enforce,= id=3Dcpu1,socket-id=3D1,core-id=3D1,thread-id=3D0=20 ...=20 ? Another question, is -smp mandatory ? (if I want coldplug all cpus) -smp sockets=3D2,cores=3D2,maxcpus=3D4 -device qemu64-x86_64-cpu,id=3Dcpu1,socket-id=3D1,core-id=3D1,thread-id=3D0= =20 -device qemu64-x86_64-cpu,id=3Dcpu1,socket-id=3D1,core-id=3D2,thread-id=3D0= =20 -device qemu64-x86_64-cpu,id=3Dcpu3,socket-id=3D2,core-id=3D1,thread-id=3D0= =20 -device qemu64-x86_64-cpu,id=3Dcpu4,socket-id=3D2,core-id=3D2,thread-id=3D0= =20 or does I need minimum 1 non unplugable cpu -smp 1,sockets=3D2,cores=3D2,maxcpus=3D4 -device qemu64-x86_64-cpu,id=3Dcpu1,socket-id=3D1,core-id=3D2,thread-id=3D0= =20 -device qemu64-x86_64-cpu,id=3Dcpu3,socket-id=3D2,core-id=3D1,thread-id=3D0= =20 -device qemu64-x86_64-cpu,id=3Dcpu4,socket-id=3D2,core-id=3D2,thread-id=3D0= =20 Regards, Alexandre ----- Mail original ----- De: "Dou Liyang" =C3=80: "qemu-devel" Cc: "Dou Liyang" , drjones@redhat.com, "ehabkost= " , "Markus Armbruster" , bharata@l= inux.vnet.ibm.com, "Fam Zheng" , "Igor Mammedov" , david@gibson.dropbear.id.au Envoy=C3=A9: Jeudi 18 Ao=C3=BBt 2016 03:50:50 Objet: [Qemu-devel] [PATCH v7] docs: add cpu-hotplug.txt This document describes how to use cpu hotplug in QEMU.=20 Signed-off-by: Dou Liyang =20 Reviewed-by: Andrew Jones =20 ---=20 Change log v6 -> v7=20 >>From Bharata's advice=20 1. add "qom_path" property explanation for=20 "info hotpluggable-cpus" command=20 >>From drew's advice=20 1. Fix some spelling mistake=20 Change log v5 -> v6=20 >>From drew's advice=20 1. Fix some spelling and grammar mistakes=20 Change log v4 -> v5=20 1. add an example for sPAPR=20 >>From Bharata's advice=20 1. Fix the examples=20 Change log v3 -> v4=20 >>From David's advice=20 1. add spapr examples=20 2. Fix some comment=20 >>From drew's advice=20 1. Fix some syntax=20 Change log v2 -> v3:=20 >>From drew's advice:=20 1. modify the examples.=20 2. Fix some syntax.=20 Change log v1 -> v2:=20 >>From Fam's advice:=20 1. Fix some comment.=20 Change log v1:=20 >>From Igor's advice:=20 1. Remove any mentioning of apic-id from the document.=20 2. Remove the "device_del qom_path" from the CPU hot-unplug.=20 3. Fix some comment.=20 docs/cpu-hotplug.txt | 156 ++++++++++++++++++++++++++++++++++++++++++++++++= +++=20 1 file changed, 156 insertions(+)=20 create mode 100644 docs/cpu-hotplug.txt=20 diff --git a/docs/cpu-hotplug.txt b/docs/cpu-hotplug.txt=20 new file mode 100644=20 index 0000000..3667641=20 --- /dev/null=20 +++ b/docs/cpu-hotplug.txt=20 @@ -0,0 +1,156 @@=20 +QEMU CPU hotplug=20 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20 +=20 +This document explains how to use the CPU hotplug feature in QEMU,=20 +which regards the CPU as a device, using -device/device_add and=20 +device_del.=20 +=20 +QEMU support was merged for 2.7.=20 +=20 +Guest support is required for CPU hotplug to work.=20 +=20 +CPU hot-plug=20 +------------=20 +=20 +In order to be able to hotplug CPUs, QEMU has to be told the maximum=20 +number of CPUs which the guest can have. This is done at startup time=20 +by means of the -smp command-line option, which has the following=20 +format:=20 +=20 + -smp [cpus=3D]n[,maxcpus=3Dcpus][,cores=3Dcores][,threads=3Dthreads]=20 + [,sockets=3Dsockets]=20 +=20 +where,=20 +=20 + - "cpus" sets the number of CPUs to 'n' [default=3D1].=20 + - "maxcpus" sets the maximum number of CPUs, including offline VCPUs=20 + for hotplug.=20 + - "sockets" sets the number of discrete sockets in the system.=20 + - "cores" sets the number of CPU cores on one socket.=20 + - "threads" sets the number of threads on one CPU core.=20 +=20 +For example, the following command-line:=20 +=20 + qemu [...] -smp 4,maxcpus=3D8,sockets=3D2,cores=3D2,threads=3D2=20 +=20 +creates a guest with 4 VCPUs and supports up to 8 VCPUs. The CPU topology= =20 +is sockets (2) * cores (2) * threads (2) and should compute a number of=20 +slots exactly equal to maxcpus. A computed number of slots greater than=20 +maxcpus will result in error. When the guest finishes loading, the guest= =20 +will see 4 VCPUs. More of this below.=20 +=20 +Query available CPU objects=20 +---------------------------=20 +=20 +To add a VCPU, it must be identified by socket-id, core-id, and/or=20 +thread-id parameters.=20 +=20 +Before adding the VCPU, we should know the topology parameters, so=20 +that we can find the available location (socket,core,thread) for a=20 +new VCPU.=20 +=20 +Use the HMP command "info hotpluggable-cpus" to obtain them, for example:= =20 +=20 + (qemu) info hotpluggable-cpus=20 +=20 +lists all CPUs including the present and possible hot-pluggable CPUs.=20 +Such as this:=20 +=20 + ...=20 + type: "qemu64-x86_64-cpu"=20 + vcpus_count: "1"=20 + CPUInstance Properties:=20 + socket-id: "1"=20 + core-id: "0"=20 + thread-id: "0"=20 + type: "qemu64-x86_64-cpu"=20 + vcpus_count: "1"=20 + qom_path: "/machine/unattached/device[4]"=20 + CPUInstance Properties:=20 + socket-id: "0"=20 + core-id: "1"=20 + thread-id: "1"=20 + ...=20 +=20 +or=20 +=20 + ...=20 + type: "POWER7_v2.3-spapr-cpu-core"=20 + vcpus_count: "1"=20 + CPUInstance Properties:=20 + core-id: "2"=20 + type: "POWER7_v2.3-spapr-cpu-core"=20 + vcpus_count: "1"=20 + qom_path: "/machine/unattached/device[2]"=20 + CPUInstance Properties:=20 + core-id: "1"=20 + ...=20 +=20 +The property called "qom_path" indicates that the listed CPU is already=20 +present or plugged-in.=20 +=20 +Different platforms may have different "CPUInstance Properties", which=20 +will be used in hot-plugging below.=20 +=20 +Hotplug CPUs=20 +------------=20 +=20 +A monitor command may be used to hotplug CPUs:=20 +=20 + - "device_add": creates a CPU device and inserts it into the=20 + specific location.=20 +=20 +For example, the following command adds a VCPU, which has the id cpu1,=20 +to a specific location in the topology (socket=3D1,core=3D0,thread=3D0):= =20 +=20 + (qemu) device_add qemu64-x86_64-cpu,id=3Dcpu1,socket-id=3D1,core-id=3D0,t= hread-id=3D0=20 +=20 +where,=20 +=20 + - "qemu64-x86_64-cpu" is the CPU model.=20 + - "id" is the unique identifier in the device set.=20 + - "socket-id/core-id/thread-id" represent the designated location,=20 + which is obtained from the above possible list of CPUs.=20 +=20 +It's also possible to start a guest with a CPU cold-plugged into a=20 +specific location (socket,core,thread).=20 +=20 +In the following command line example, a guest which has 4 VCPUs is=20 +created:=20 +=20 + qemu [...] -smp 2,maxcpus=3D8,sockets=3D2,cores=3D2,threads=3D2 \=20 + -device qemu64-x86_64-cpu,id=3Dcpu1,socket-id=3D1,\=20 + core-id=3D1,thread-id=3D0 \=20 + -device qemu64-x86_64-cpu,id=3Dcpu2,socket-id=3D1,\=20 + core-id=3D1,thread-id=3D1 \=20 +=20 +Two VCPUs are cold-plugged by the "-device" parameter, which are in=20 +the same socket and core, but with different thread-ids. After that,=20 +the guest has an additional four VCPUs available for hot-plug when=20 +needed.=20 +=20 +The above example is for an x86 machine type. The topology parameters=20 +and resulting number of online VCPUs may not be suitable for other=20 +platforms. The "CPUInstance Properties" output described above lists=20 +the valid topology parameters.=20 +=20 +For example, the following command adds a VCPU in an sPAPR hardware=20 +system:=20 +=20 + (qemu) device_add POWER7_v2.3-spapr-cpu-core,id=3Dcpu1,core-id=3D2=20 +=20 +CPU hot-unplug=20 +--------------=20 +=20 +In order to be able to hot unplug a CPU device, QEMU removes the=20 +device by using the id which was assigned when hotplugging it.=20 +=20 +A monitor command may be used to hot unplug CPUs:=20 +=20 + - "device_del": deletes a CPU device=20 +=20 +For example, assuming that the CPU device with id "cpu1" exists,=20 +then the following command tries to remove it.=20 +=20 + (qemu) device_del cpu1=20 +=20 --=20 2.5.5=20