Received: from eggs.gnu.org ([2001:4830:134:3::10]:40858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWviV-0003R0-MN for qemu-devel@nongnu.org; Mon, 08 Aug 2016 21:20:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWviS-00059o-Uo for qemu-devel@nongnu.org; Mon, 08 Aug 2016 21:20:26 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:39326) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWviS-00059H-10 for qemu-devel@nongnu.org; Mon, 08 Aug 2016 21:20:24 -0400 Date: Tue, 9 Aug 2016 10:15:14 +1000 From: David Gibson Message-ID: <20160809001514.GB9057@voom.fritz.box> References: <1470623282-3837-1-git-send-email-douly.fnst@cn.fujitsu.com> <20160808141805.779580d9@nial.brq.redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="neYutvxvOLaeuPCA" Content-Disposition: inline In-Reply-To: <20160808141805.779580d9@nial.brq.redhat.com> Subject: Re: [Qemu-devel] [PATCH] docs: add cpu-hotplug.txt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: Dou Liyang , qemu-devel@nongnu.org, bharata@linux.vnet.ibm.com, ehabkost@redhat.com, berrange@redhat.com, armbru@redhat.com --neYutvxvOLaeuPCA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 08, 2016 at 02:18:05PM +0200, Igor Mammedov wrote: > On Mon, 8 Aug 2016 10:28:02 +0800 > Dou Liyang wrote: >=20 > > This document describes how to use cpu hotplug in QEMU. > >=20 > > Signed-off-by: Dou Liyang > > --- > > docs/cpu-hotplug.txt | 110 +++++++++++++++++++++++++++++++++++++++++++= ++++++++ > > 1 file changed, 110 insertions(+) > > create mode 100644 docs/cpu-hotplug.txt > >=20 > > diff --git a/docs/cpu-hotplug.txt b/docs/cpu-hotplug.txt > > new file mode 100644 > > index 0000000..d62638e > > --- /dev/null > > +++ b/docs/cpu-hotplug.txt > > @@ -0,0 +1,110 @@ > > +QEMU CPU hotplug > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > +This document explains how to use the cpu hotplug feature in QEMU, > > +which is present since v2.6.0. >=20 > -device/device_add based CPUs are merged since 2.7 >=20 > > + > > +Guest support is required for cpu hotplug to work. > > + > > +CPU hotplug > > +------------------- > > + > > +In order to be able to hotplug cpu, 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=3D]n[,maxcpus=3Dcpus][,cores=3Dcores][,threads=3Dthreads] > > + [,sockets=3Dsockets] > > + > > +Where, > > + > > + - "cpus" set the number of CPUs to 'n' [default=3D1] > > + - "maxcpus" maximum number of total cpus, including offlineCPUs for > > + hotplug, etc > s/total// > s/offlineCPUs/offline VCPUs/ or threads >=20 > > + - "cores" number of CPU cores on one socket > > + - "threads=3D number of threads on one CPU core > > + - "sockets=3D number of discrete sockets in the system > Above needs additional meaning clarification for SPAPR, > CCing David Sockets have no real meaning on sPAPR. You can decide how many cores go into each "socket", but it has no real effect on the guest. >=20 > > + > > + > > +For example, the following command-line: > > + > > + qemu [...] -smp 3,maxcpus=3D10,sockets=3D2,cores=3D2,threads=3D2 > > + > > +Creates a guest with 3 cpus and it support up to 10 cpus. 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 > > +cpus. so there are seven cpus can be hotplugged by using any > > +combination of the available sockets,cores and threads topology or > > +using apic-id. > s/cpus/vcpus/ >=20 > drop any mentioning of apic-id, it's not supposed to be used > by user and socket/core/thread-ids should be used i.e. > properties advertised by QEMU via QMP command query-hotpluggable-cpus > or corresponding HMP command 'info hotpluggable-cpus' >=20 > PS: > Eduardo should we drop apic-id property before 2.7 is released? > So people won't even try to use it, it wan never a public > property before as cpus weren't available with -device/device_add. >=20 >=20 > > +cpu hot-plug > > +----------------------- > > + > > +A monitor commands are used to hotplug cpu: > > + > > + - "device_add": creates a cpu device and inserts it into the > > + specific topology as a device > > + > > +For example, the following commands add a cpu which id is cpu1 to > > +the guest discussed earlier: > > + > > + (qemu) device_add qemu64-x86_64-cpu,id=3Dcpu1,apic-id=3D3 > likewise remove any mentioning of apic-id from document >=20 > I'd add as the first section here commands that query possible > available cpus including topology properties.=20 >=20 > > + > > + - "qemu64-x86_64-cpu" is the cpu modle. > > + - "id" is the unique identifier in the device sets. > > + - "apic-id" is the hotpluged cpu's physical identification. > > + > > +Another command uses the cpu topology to add the additional cpu in > > +the designated position. > > + > > +For example, the following commands add a cpu in the last position > > +of the guest cpu topology discussed earlier. > > + > > + (qemu) device_add qemu64-x86_64-cpu,id=3Dcpu1,socket-id=3D2,core-id= =3D1, > > + thread-id=3D1 > > + > > +It's also possible to start a guest with cpu cold-plugged into the > > +hotpluggable cpu topology. > s/hotpluggable cpu topology/specific place (socket,core,thread)/ >=20 > > + > > +In the following command-line example, a guest which has 3 cpus is > > +created where one of the cpus comes from the "apic-id", and another > > +one comes from "socket-id...". After that, the guest has additional > > +seven cpus to be hot-plug when needed: > > + > > + qemu [...] -smp 1,maxcpus=3D10,sockets=3D2,cores=3D2,threads=3D2 > > + -device qemu64-x86_64-cpu,id=3Dcpu1,apic-id=3D1 > > + -device qemu64-x86_64-cpu,socket-id=3D2,core-id=3D1,thread-id=3D0 > > + > > +cpu hot-unplug > > +------------------------ > > + > > +In order to be able to hot unplug cpu device, QEMU has two ways > > +to remove cpu device. > > + 1. Using the ids which were assigned when you hot plugged cpus. > > + 2. Using qom_path where the cpu is located in the guest. > I wouldn't advertise #2 as it's possible to unplug CPUs created with > -smp X with its help and then have broken migration >=20 > device_del qom_path should even be able to remove a device without ID, > it should allow removal of devices below /machine/peripheral only > instead of current anywhere. >=20 > Daniel, > is it a bug in current device_del impl.? > i.e. device_del /machine/unattached/device[2] > is currently allowed while I think it shouldn't. >=20 > > + > > +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 > > + > > +If you don't set the ids when you hot plugged cpus. > > + >=20 >=20 > > +First, you may need to obtain the cpu's qom_path. The following > > +commands list all hotplugable-cpus, you can get the qom_path > > +through the cpu topology. > > + > > + (qemu) info hotpluggable-cpus > > + > > +Then you can remove it by the qom_path. > > + > > +For example, assuming that the cpu device with qom_path "/machine > > +/unattached/device[0]" exists, the following commands tries to > > +remove it. > > + > > + (qemu) device_del /machine/unattached/device[0] > I'd remove qom-path related parts and leave only ID based one. >=20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --neYutvxvOLaeuPCA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXqSCRAAoJEGw4ysog2bOSjRQP/1WsKFvtTNYZlNCiio3lB0Vz obnpr6bgtI1nG3uIxJQpqKisONXn9+AoZr+BqyRxCsIC2SYPtdozFw/dGPYa0z+h YS6v+5d6lGSBvqcwjYq6GpwtIg3CWxYsBzwUPyjYJ5voeNYbwC854z0z5Mj+u5hX BPmJetTLQJBrnYb7YdB2hv+e0f5uA7x+E3H+/YxkaKH3Q5qk09WRAv9OoYtfkNhk demRSHwZQ/uLwXglvv528Prlr+JwVpTPr+D2OXE1nPOw+GoZhXy7nMXAOTbtngCz fHbJNzXysm3kf99lBRvCNwEtd+nDbR+e+EUep4zyVmmnHtwV1/YkPYsdQGkJUGiE 0pWnmWlGeke41B2HSZDC5HxjbmVA2qFR8+qPfeBuSoYvLW1tkErS0vlTnVV0gCvv cwdJSRYiaBF3XOyrMxMv8Jqlclj5Vs2EIONnyckS/U1muE9hysCIsEFIRR6HyAf+ 95UTauLK6XtuQwoZ4S3gGfFawsVDnzHpPNwUofU3XE6664gSGn1Sma1DyiuMolsF itgd6LqOkQubHFGssccWM5+CAsrGooD7jHkeRmanJzyxO5Nrtgih2etM1UzLFEeB TSe4IP0amfVE1uxEsC24i+sJANqjmN38vg6K2LplajCqZ4Jh9wlVzjcSN54V2Lq3 gG14gkS2yjHAvMOpe1HS =oZe/ -----END PGP SIGNATURE----- --neYutvxvOLaeuPCA--