* [Qemu-devel] [PATCH v7] docs: add cpu-hotplug.txt
@ 2016-08-18 1:50 Dou Liyang
2016-08-22 8:56 ` Alexandre DERUMIER
0 siblings, 1 reply; 6+ messages in thread
From: Dou Liyang @ 2016-08-18 1:50 UTC (permalink / raw)
To: qemu-devel
Cc: imammedo, david, bharata, ehabkost, berrange, armbru, famz,
drjones, Dou Liyang
This document describes how to use cpu hotplug in QEMU.
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
---
Change log v6 -> v7
From Bharata's advice
1. add "qom_path" property explanation for
"info hotpluggable-cpus" command
From drew's advice
1. Fix some spelling mistake
Change log v5 -> v6
From drew's advice
1. Fix some spelling and grammar mistakes
Change log v4 -> v5
1. add an example for sPAPR
From Bharata's advice
1. Fix the examples
Change log v3 -> v4
From David's advice
1. add spapr examples
2. Fix some comment
From drew's advice
1. Fix some syntax
Change log v2 -> v3:
From drew's advice:
1. modify the examples.
2. Fix some syntax.
Change log v1 -> v2:
From Fam's advice:
1. Fix some comment.
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.
docs/cpu-hotplug.txt | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 156 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..3667641
--- /dev/null
+++ b/docs/cpu-hotplug.txt
@@ -0,0 +1,156 @@
+QEMU CPU hotplug
+================
+
+This document explains how to use the CPU hotplug feature in QEMU,
+which regards the CPU as a device, using -device/device_add and
+device_del.
+
+QEMU support was merged for 2.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 the maximum
+number of CPUs which the guest can have. 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" sets the number of CPUs to 'n' [default=1].
+ - "maxcpus" sets the maximum number of CPUs, including offline VCPUs
+ for hotplug.
+ - "sockets" sets the number of discrete sockets in the system.
+ - "cores" sets the number of CPU cores on one socket.
+ - "threads" sets the number of threads on one CPU core.
+
+For example, the following command-line:
+
+ qemu [...] -smp 4,maxcpus=8,sockets=2,cores=2,threads=2
+
+creates a guest with 4 VCPUs and supports up to 8 VCPUs. The CPU topology
+is sockets (2) * cores (2) * threads (2) and should compute a number of
+slots exactly equal to maxcpus. A computed number of slots greater than
+maxcpus will result in error. When the guest finishes loading, the guest
+will see 4 VCPUs. More of this below.
+
+Query available CPU objects
+---------------------------
+
+To add a VCPU, it must be identified by socket-id, core-id, and/or
+thread-id parameters.
+
+Before adding the VCPU, we should know the topology parameters, so
+that we can find the available location (socket,core,thread) for a
+new VCPU.
+
+Use the HMP command "info hotpluggable-cpus" to obtain them, for example:
+
+ (qemu) info hotpluggable-cpus
+
+lists all CPUs including the present and possible hot-pluggable CPUs.
+Such as this:
+
+ ...
+ type: "qemu64-x86_64-cpu"
+ vcpus_count: "1"
+ CPUInstance Properties:
+ socket-id: "1"
+ core-id: "0"
+ thread-id: "0"
+ type: "qemu64-x86_64-cpu"
+ vcpus_count: "1"
+ qom_path: "/machine/unattached/device[4]"
+ CPUInstance Properties:
+ socket-id: "0"
+ core-id: "1"
+ thread-id: "1"
+ ...
+
+or
+
+ ...
+ type: "POWER7_v2.3-spapr-cpu-core"
+ vcpus_count: "1"
+ CPUInstance Properties:
+ core-id: "2"
+ type: "POWER7_v2.3-spapr-cpu-core"
+ vcpus_count: "1"
+ qom_path: "/machine/unattached/device[2]"
+ CPUInstance Properties:
+ core-id: "1"
+ ...
+
+The property called "qom_path" indicates that the listed CPU is already
+present or plugged-in.
+
+Different platforms may have different "CPUInstance Properties", which
+will be used in hot-plugging below.
+
+Hotplug CPUs
+------------
+
+A monitor command may be used to hotplug CPUs:
+
+ - "device_add": creates a CPU device and inserts it into the
+ specific location.
+
+For example, the following command adds a VCPU, which has the id cpu1,
+to a specific location in the topology (socket=1,core=0,thread=0):
+
+ (qemu) device_add qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=0,thread-id=0
+
+where,
+
+ - "qemu64-x86_64-cpu" is the CPU model.
+ - "id" is the unique identifier in the device set.
+ - "socket-id/core-id/thread-id" represent the designated location,
+ which is obtained from the above possible list of CPUs.
+
+It's also possible to start a guest with a CPU cold-plugged into a
+specific location (socket,core,thread).
+
+In the following command line example, a guest which has 4 VCPUs is
+created:
+
+ qemu [...] -smp 2,maxcpus=8,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 the "-device" parameter, which are in
+the same socket and core, but with different thread-ids. After that,
+the guest has an additional four VCPUs available for hot-plug when
+needed.
+
+The above example is for an x86 machine type. The topology parameters
+and resulting number of online VCPUs may not be suitable for other
+platforms. The "CPUInstance Properties" output described above lists
+the valid topology parameters.
+
+For example, the following command adds a VCPU in an sPAPR hardware
+system:
+
+ (qemu) device_add POWER7_v2.3-spapr-cpu-core,id=cpu1,core-id=2
+
+CPU hot-unplug
+--------------
+
+In order to be able to hot unplug a CPU device, QEMU removes the
+device by using the id which was assigned when hotplugging it.
+
+A monitor command may be used to hot unplug CPUs:
+
+ - "device_del": deletes a CPU device
+
+For example, assuming that the CPU device with id "cpu1" exists,
+then the following command tries to remove it.
+
+ (qemu) device_del cpu1
+
--
2.5.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v7] docs: add cpu-hotplug.txt
2016-08-18 1:50 [Qemu-devel] [PATCH v7] docs: add cpu-hotplug.txt Dou Liyang
@ 2016-08-22 8:56 ` Alexandre DERUMIER
2016-08-23 5:17 ` Dou Liyang
0 siblings, 1 reply; 6+ messages in thread
From: Alexandre DERUMIER @ 2016-08-22 8:56 UTC (permalink / raw)
To: Dou Liyang
Cc: qemu-devel, drjones, ehabkost, Markus Armbruster, bharata,
Fam Zheng, Igor Mammedov, david
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=2,cores=2,maxcpus=4
Does I need to define flags like:
-smp 2,sockets=2,cores=2,maxcpus=4
-device qemu64-x86_64-cpu,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,enforce,id=cpu1,socket-id=1,core-id=1,thread-id=0
...
?
Another question,
is -smp mandatory ? (if I want coldplug all cpus)
-smp sockets=2,cores=2,maxcpus=4
-device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=1,thread-id=0
-device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=2,thread-id=0
-device qemu64-x86_64-cpu,id=cpu3,socket-id=2,core-id=1,thread-id=0
-device qemu64-x86_64-cpu,id=cpu4,socket-id=2,core-id=2,thread-id=0
or does I need minimum 1 non unplugable cpu
-smp 1,sockets=2,cores=2,maxcpus=4
-device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=2,thread-id=0
-device qemu64-x86_64-cpu,id=cpu3,socket-id=2,core-id=1,thread-id=0
-device qemu64-x86_64-cpu,id=cpu4,socket-id=2,core-id=2,thread-id=0
Regards,
Alexandre
----- Mail original -----
De: "Dou Liyang" <douly.fnst@cn.fujitsu.com>
À: "qemu-devel" <qemu-devel@nongnu.org>
Cc: "Dou Liyang" <douly.fnst@cn.fujitsu.com>, drjones@redhat.com, "ehabkost" <ehabkost@redhat.com>, "Markus Armbruster" <armbru@redhat.com>, bharata@linux.vnet.ibm.com, "Fam Zheng" <famz@redhat.com>, "Igor Mammedov" <imammedo@redhat.com>, david@gibson.dropbear.id.au
Envoyé: Jeudi 18 Août 2016 03:50:50
Objet: [Qemu-devel] [PATCH v7] docs: add cpu-hotplug.txt
This document describes how to use cpu hotplug in QEMU.
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
---
Change log v6 -> v7
>From Bharata's advice
1. add "qom_path" property explanation for
"info hotpluggable-cpus" command
>From drew's advice
1. Fix some spelling mistake
Change log v5 -> v6
>From drew's advice
1. Fix some spelling and grammar mistakes
Change log v4 -> v5
1. add an example for sPAPR
>From Bharata's advice
1. Fix the examples
Change log v3 -> v4
>From David's advice
1. add spapr examples
2. Fix some comment
>From drew's advice
1. Fix some syntax
Change log v2 -> v3:
>From drew's advice:
1. modify the examples.
2. Fix some syntax.
Change log v1 -> v2:
>From Fam's advice:
1. Fix some comment.
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.
docs/cpu-hotplug.txt | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 156 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..3667641
--- /dev/null
+++ b/docs/cpu-hotplug.txt
@@ -0,0 +1,156 @@
+QEMU CPU hotplug
+================
+
+This document explains how to use the CPU hotplug feature in QEMU,
+which regards the CPU as a device, using -device/device_add and
+device_del.
+
+QEMU support was merged for 2.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 the maximum
+number of CPUs which the guest can have. 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" sets the number of CPUs to 'n' [default=1].
+ - "maxcpus" sets the maximum number of CPUs, including offline VCPUs
+ for hotplug.
+ - "sockets" sets the number of discrete sockets in the system.
+ - "cores" sets the number of CPU cores on one socket.
+ - "threads" sets the number of threads on one CPU core.
+
+For example, the following command-line:
+
+ qemu [...] -smp 4,maxcpus=8,sockets=2,cores=2,threads=2
+
+creates a guest with 4 VCPUs and supports up to 8 VCPUs. The CPU topology
+is sockets (2) * cores (2) * threads (2) and should compute a number of
+slots exactly equal to maxcpus. A computed number of slots greater than
+maxcpus will result in error. When the guest finishes loading, the guest
+will see 4 VCPUs. More of this below.
+
+Query available CPU objects
+---------------------------
+
+To add a VCPU, it must be identified by socket-id, core-id, and/or
+thread-id parameters.
+
+Before adding the VCPU, we should know the topology parameters, so
+that we can find the available location (socket,core,thread) for a
+new VCPU.
+
+Use the HMP command "info hotpluggable-cpus" to obtain them, for example:
+
+ (qemu) info hotpluggable-cpus
+
+lists all CPUs including the present and possible hot-pluggable CPUs.
+Such as this:
+
+ ...
+ type: "qemu64-x86_64-cpu"
+ vcpus_count: "1"
+ CPUInstance Properties:
+ socket-id: "1"
+ core-id: "0"
+ thread-id: "0"
+ type: "qemu64-x86_64-cpu"
+ vcpus_count: "1"
+ qom_path: "/machine/unattached/device[4]"
+ CPUInstance Properties:
+ socket-id: "0"
+ core-id: "1"
+ thread-id: "1"
+ ...
+
+or
+
+ ...
+ type: "POWER7_v2.3-spapr-cpu-core"
+ vcpus_count: "1"
+ CPUInstance Properties:
+ core-id: "2"
+ type: "POWER7_v2.3-spapr-cpu-core"
+ vcpus_count: "1"
+ qom_path: "/machine/unattached/device[2]"
+ CPUInstance Properties:
+ core-id: "1"
+ ...
+
+The property called "qom_path" indicates that the listed CPU is already
+present or plugged-in.
+
+Different platforms may have different "CPUInstance Properties", which
+will be used in hot-plugging below.
+
+Hotplug CPUs
+------------
+
+A monitor command may be used to hotplug CPUs:
+
+ - "device_add": creates a CPU device and inserts it into the
+ specific location.
+
+For example, the following command adds a VCPU, which has the id cpu1,
+to a specific location in the topology (socket=1,core=0,thread=0):
+
+ (qemu) device_add qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=0,thread-id=0
+
+where,
+
+ - "qemu64-x86_64-cpu" is the CPU model.
+ - "id" is the unique identifier in the device set.
+ - "socket-id/core-id/thread-id" represent the designated location,
+ which is obtained from the above possible list of CPUs.
+
+It's also possible to start a guest with a CPU cold-plugged into a
+specific location (socket,core,thread).
+
+In the following command line example, a guest which has 4 VCPUs is
+created:
+
+ qemu [...] -smp 2,maxcpus=8,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 the "-device" parameter, which are in
+the same socket and core, but with different thread-ids. After that,
+the guest has an additional four VCPUs available for hot-plug when
+needed.
+
+The above example is for an x86 machine type. The topology parameters
+and resulting number of online VCPUs may not be suitable for other
+platforms. The "CPUInstance Properties" output described above lists
+the valid topology parameters.
+
+For example, the following command adds a VCPU in an sPAPR hardware
+system:
+
+ (qemu) device_add POWER7_v2.3-spapr-cpu-core,id=cpu1,core-id=2
+
+CPU hot-unplug
+--------------
+
+In order to be able to hot unplug a CPU device, QEMU removes the
+device by using the id which was assigned when hotplugging it.
+
+A monitor command may be used to hot unplug CPUs:
+
+ - "device_del": deletes a CPU device
+
+For example, assuming that the CPU device with id "cpu1" exists,
+then the following command tries to remove it.
+
+ (qemu) device_del cpu1
+
--
2.5.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v7] docs: add cpu-hotplug.txt
2016-08-22 8:56 ` Alexandre DERUMIER
@ 2016-08-23 5:17 ` Dou Liyang
2016-09-06 20:05 ` Eduardo Habkost
0 siblings, 1 reply; 6+ messages in thread
From: Dou Liyang @ 2016-08-23 5:17 UTC (permalink / raw)
To: Alexandre DERUMIER
Cc: qemu-devel, drjones, ehabkost, Markus Armbruster, bharata,
Fam Zheng, Igor Mammedov, david
Hi Alexandre,
At 08/22/2016 04:56 PM, Alexandre DERUMIER wrote:
> 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=2,cores=2,maxcpus=4
>
>
> Does I need to define flags like:
>
> -smp 2,sockets=2,cores=2,maxcpus=4
> -device qemu64-x86_64-cpu,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,enforce,id=cpu1,socket-id=1,core-id=1,thread-id=0
I think we don't need to do that.
In my option, just like this:
-device qemu64-x86_64-cpu,id=cpu1,socket-id=1,..
Because QEMU sets the "-cpu" options in MachineState:
current_machine->cpu_model = cpu_model;
when you add a CPU, QEMU can get the flag from the MachineState.
> ...
>
> ?
>
>
> Another question,
> is -smp mandatory ? (if I want coldplug all cpus)
it's not mandatory. such as this:
./x86_64-softmmu/qemu-system-x86_64 -m 1G /image/fedora.img
-enable-kvm -monitor stdio
(qemu) info cpus
* CPU #0: pc=0xffffffff81060586 (halted) thread_id=4032
the default number of CPUs is 1.
>
> -smp sockets=2,cores=2,maxcpus=4
> -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=1,thread-id=0
> -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=2,thread-id=0
> -device qemu64-x86_64-cpu,id=cpu3,socket-id=2,core-id=1,thread-id=0
> -device qemu64-x86_64-cpu,id=cpu4,socket-id=2,core-id=2,thread-id=0
>
> or does I need minimum 1 non unplugable cpu
>
> -smp 1,sockets=2,cores=2,maxcpus=4
> -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=2,thread-id=0
> -device qemu64-x86_64-cpu,id=cpu3,socket-id=2,core-id=1,thread-id=0
> -device qemu64-x86_64-cpu,id=cpu4,socket-id=2,core-id=2,thread-id=0
>
I think that is better, and the socket-id/core-id/thread-id starts at
index 0
I am new to the community. Please don't mind, and take with a grain of
salt.
Thanks,
Dou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v7] docs: add cpu-hotplug.txt
2016-08-23 5:17 ` Dou Liyang
@ 2016-09-06 20:05 ` Eduardo Habkost
2016-09-07 1:52 ` Dou Liyang
0 siblings, 1 reply; 6+ messages in thread
From: Eduardo Habkost @ 2016-09-06 20:05 UTC (permalink / raw)
To: Dou Liyang
Cc: Alexandre DERUMIER, qemu-devel, drjones, Markus Armbruster,
bharata, Fam Zheng, Igor Mammedov, david
On Tue, Aug 23, 2016 at 01:17:01PM +0800, Dou Liyang wrote:
> Hi Alexandre,
>
> At 08/22/2016 04:56 PM, Alexandre DERUMIER wrote:
> > 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=2,cores=2,maxcpus=4
> >
> >
> > Does I need to define flags like:
> >
> > -smp 2,sockets=2,cores=2,maxcpus=4
> > -device qemu64-x86_64-cpu,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,enforce,id=cpu1,socket-id=1,core-id=1,thread-id=0
>
> I think we don't need to do that.
> In my option, just like this:
>
> -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,..
>
> Because QEMU sets the "-cpu" options in MachineState:
>
> current_machine->cpu_model = cpu_model;
>
> when you add a CPU, QEMU can get the flag from the MachineState.
You don't need to repeat the flags, but that's not because of
MachineState::cpu_model, but because of the semantics of -smp:
The option:
-smp MODEL,+FOO,+BAR
is internally translated to:
-global MODEL.FOO=on
-global MODEL.BAR=on
in addition to setting the CPU model for creating initial CPUs to
MODEL.
>
> > ...
> >
> > ?
> >
> >
> > Another question,
> > is -smp mandatory ? (if I want coldplug all cpus)
>
> it's not mandatory. such as this:
>
> ./x86_64-softmmu/qemu-system-x86_64 -m 1G /image/fedora.img
> -enable-kvm -monitor stdio
>
> (qemu) info cpus
> * CPU #0: pc=0xffffffff81060586 (halted) thread_id=4032
>
> the default number of CPUs is 1.
>
> >
> > -smp sockets=2,cores=2,maxcpus=4
>
> > -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=1,thread-id=0
> > -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=2,thread-id=0
> > -device qemu64-x86_64-cpu,id=cpu3,socket-id=2,core-id=1,thread-id=0
> > -device qemu64-x86_64-cpu,id=cpu4,socket-id=2,core-id=2,thread-id=0
> >
> > or does I need minimum 1 non unplugable cpu
As mentioned above, the default number of CPUs is 1, so "-smp
sockets=2" is the same as "-smp 1,sockets=2".
I assume you mean something like "-smp 0", but that doesn't work
today. I would like to eventually allow all CPUs to be created
using -device, but that's not possible yet.
> >
> > -smp 1,sockets=2,cores=2,maxcpus=4
> > -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=2,thread-id=0
> > -device qemu64-x86_64-cpu,id=cpu3,socket-id=2,core-id=1,thread-id=0
> > -device qemu64-x86_64-cpu,id=cpu4,socket-id=2,core-id=2,thread-id=0
> >
>
> I think that is better, and the socket-id/core-id/thread-id starts at
> index 0
>
> I am new to the community. Please don't mind, and take with a grain of
> salt.
>
> Thanks,
> Dou
>
>
--
Eduardo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v7] docs: add cpu-hotplug.txt
2016-09-06 20:05 ` Eduardo Habkost
@ 2016-09-07 1:52 ` Dou Liyang
2016-09-09 19:20 ` Eduardo Habkost
0 siblings, 1 reply; 6+ messages in thread
From: Dou Liyang @ 2016-09-07 1:52 UTC (permalink / raw)
To: Eduardo Habkost
Cc: Alexandre DERUMIER, qemu-devel, drjones, Markus Armbruster,
bharata, Fam Zheng, Igor Mammedov, david
Hi, Eduardo
At 09/07/2016 04:05 AM, Eduardo Habkost wrote:
> On Tue, Aug 23, 2016 at 01:17:01PM +0800, Dou Liyang wrote:
>> Hi Alexandre,
>>
>> At 08/22/2016 04:56 PM, Alexandre DERUMIER wrote:
>>> 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=2,cores=2,maxcpus=4
>>>
>>>
>>> Does I need to define flags like:
>>>
>>> -smp 2,sockets=2,cores=2,maxcpus=4
>>> -device qemu64-x86_64-cpu,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,enforce,id=cpu1,socket-id=1,core-id=1,thread-id=0
>>
>> I think we don't need to do that.
>> In my option, just like this:
>>
>> -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,..
>>
>> Because QEMU sets the "-cpu" options in MachineState:
>>
>> current_machine->cpu_model = cpu_model;
>>
>> when you add a CPU, QEMU can get the flag from the MachineState.
>
> You don't need to repeat the flags, but that's not because of
> MachineState::cpu_model, but because of the semantics of -smp:
Sorry for the reply.
>
> The option:
> -smp MODEL,+FOO,+BAR
I guess you may mean "-cpu", not "-smp"
> is internally translated to:
> -global MODEL.FOO=on
> -global MODEL.BAR=on
> in addition to setting the CPU model for creating initial CPUs to
> MODEL.
>
I see.
>>
>>> ...
>>>
>>> ?
>>>
>>>
>>> Another question,
>>> is -smp mandatory ? (if I want coldplug all cpus)
>>
>> it's not mandatory. such as this:
>>
>> ./x86_64-softmmu/qemu-system-x86_64 -m 1G /image/fedora.img
>> -enable-kvm -monitor stdio
>>
>> (qemu) info cpus
>> * CPU #0: pc=0xffffffff81060586 (halted) thread_id=4032
>>
>> the default number of CPUs is 1.
>>
>>>
>>> -smp sockets=2,cores=2,maxcpus=4
>>
>>> -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=1,thread-id=0
>>> -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=2,thread-id=0
>>> -device qemu64-x86_64-cpu,id=cpu3,socket-id=2,core-id=1,thread-id=0
>>> -device qemu64-x86_64-cpu,id=cpu4,socket-id=2,core-id=2,thread-id=0
>>>
>>> or does I need minimum 1 non unplugable cpu
>
> As mentioned above, the default number of CPUs is 1, so "-smp
> sockets=2" is the same as "-smp 1,sockets=2".
>
> I assume you mean something like "-smp 0", but that doesn't work
> today. I would like to eventually allow all CPUs to be created
> using -device, but that's not possible yet.
I am interested in what is the benefit, if we can create all CPUs using
-device. :)
Thanks,
Dou
>
>>>
>>> -smp 1,sockets=2,cores=2,maxcpus=4
>>> -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=2,thread-id=0
>>> -device qemu64-x86_64-cpu,id=cpu3,socket-id=2,core-id=1,thread-id=0
>>> -device qemu64-x86_64-cpu,id=cpu4,socket-id=2,core-id=2,thread-id=0
>>>
>>
>> I think that is better, and the socket-id/core-id/thread-id starts at
>> index 0
>>
>> I am new to the community. Please don't mind, and take with a grain of
>> salt.
>>
>> Thanks,
>> Dou
>>
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v7] docs: add cpu-hotplug.txt
2016-09-07 1:52 ` Dou Liyang
@ 2016-09-09 19:20 ` Eduardo Habkost
0 siblings, 0 replies; 6+ messages in thread
From: Eduardo Habkost @ 2016-09-09 19:20 UTC (permalink / raw)
To: Dou Liyang
Cc: Alexandre DERUMIER, qemu-devel, drjones, Markus Armbruster,
bharata, Fam Zheng, Igor Mammedov, david
On Wed, Sep 07, 2016 at 09:52:59AM +0800, Dou Liyang wrote:
[...]
> >
> > The option:
> > -smp MODEL,+FOO,+BAR
>
> I guess you may mean "-cpu", not "-smp"
Oops, yes. Thanks. :)
>
> > is internally translated to:
> > -global MODEL.FOO=on
> > -global MODEL.BAR=on
> > in addition to setting the CPU model for creating initial CPUs to
> > MODEL.
> >
>
> I see.
>
[...]
> > > >
> > > > -smp sockets=2,cores=2,maxcpus=4
> > >
> > > > -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=1,thread-id=0
> > > > -device qemu64-x86_64-cpu,id=cpu1,socket-id=1,core-id=2,thread-id=0
> > > > -device qemu64-x86_64-cpu,id=cpu3,socket-id=2,core-id=1,thread-id=0
> > > > -device qemu64-x86_64-cpu,id=cpu4,socket-id=2,core-id=2,thread-id=0
> > > >
> > > > or does I need minimum 1 non unplugable cpu
> >
> > As mentioned above, the default number of CPUs is 1, so "-smp
> > sockets=2" is the same as "-smp 1,sockets=2".
> >
> > I assume you mean something like "-smp 0", but that doesn't work
> > today. I would like to eventually allow all CPUs to be created
> > using -device, but that's not possible yet.
>
> I am interested in what is the benefit, if we can create all CPUs using
> -device. :)
Do you mean the benefit of not allowing "-smp 0", or the benefit
of using -device?
The benefit of not allowing "-smp 0" is none, except that we
probably have existing code that would break if we allow that,
and that code needs to be fixed first.
About -device: the benefit is having an uniform interface to
create every kind of device, and using the same interface and
options for hotplugged CPUs and non-hotplug CPUs.
(But one problem with -device today is that management software
needs to know what are the valid socket/core/thread arguments for
the machine but can't run a 'query-hotpluggable-cpus' command
before launching QEMU [unless it launches QEMU twice]).
--
Eduardo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-09-09 19:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-18 1:50 [Qemu-devel] [PATCH v7] docs: add cpu-hotplug.txt Dou Liyang
2016-08-22 8:56 ` Alexandre DERUMIER
2016-08-23 5:17 ` Dou Liyang
2016-09-06 20:05 ` Eduardo Habkost
2016-09-07 1:52 ` Dou Liyang
2016-09-09 19:20 ` Eduardo Habkost
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.