spapr: QMP: add query-hotpluggable-cpus
PATCH v4 1/2 QMP: add query-hotpluggable-cpus
In reply to Igor Mammedovit will allow mgmt to query present and hotpluggable CPU objects, it is required from a target platform that wish to support command to implement and set
MachineClass.query_hotpluggable_cpus
callback, which will return a list of possible CPU objects with options that would be needed for hotplugging possible CPU objects.
There are:
'type': 'str' - QOM CPU object type for usage with device_add 'vcpus-count': 'int' - number of logical VCPU threads per
CPU object (mgmt needs to know)
and a set of optional fields that are to used for hotplugging a CPU objects and would allows mgmt tools to know what/where it could be hotplugged; [node],[socket],[core],[thread]
For present CPUs there is a 'qom-path' field which would allow mgmt to inspect whatever object/abstraction the target platform considers as CPU object.
---
v4:
- add MachineClass method to get CPU object list
v3:
- add 'vcpus-count' field, [email protected]
- s/CpuInstanceProps/CpuInstanceProperties/
- use '#optional' marker
- make "props" as always present even if it's empty
- fix JSON examples
- fix minor typos
--- include/hw/boards.h | 5 +++++ monitor.c | 13 +++++++++++++ qapi-schema.json | 41 +++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+)
include/hw/boards.h +5 -0
@@ -82,6 +82,10 @@ typedef struct {* Returns an array of @CPUArchId architecture-dependent CPU IDs * which includes CPU IDs for present and possible to hotplug CPUs. * Caller is responsible for freeing returned list. +* @query_hotpluggable_cpus: +* Returns a @HotpluggableCPUList, which describes CPUs objects which +* could be added with -device/device_add. +* Caller is responsible for freeing returned list. */ struct MachineClass {/*< private >*/
@@ -124,6 +128,7 @@ struct MachineClass { DeviceState *dev);unsigned (*cpu_index_to_socket_id)(unsigned cpu_index); CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); + HotpluggableCPUList *(*query_hotpluggable_cpus)(MachineState *machine); };/**
monitor.c +13 -0
@@ -4257,4 +4257,17 @@ void qmp_dump_skeys(const char *filename, Error **errp) {error_setg (errp,QERR_FEATURE_DISABLED ,"dump-skeys" ); } + +HotpluggableCPUList *qmp_query_hotpluggable_cpus (Error **errp) +{ +MachineState *ms =MACHINE (qdev_get_machine ()); +MachineClass *mc =MACHINE_GET_CLASS (ms); + +if (!mc->query_hotpluggable_cpus) { +error_setg (errp,QERR_FEATURE_DISABLED ,"query-hotpluggable-cpus" ); +return NULL ; + } + +return mc->query_hotpluggable_cpus (ms); +}#endif
qapi-schema.json +41 -0
44 lines not on this page · raw message
qmp-commands.hx +43 -0
46 lines not on this page · raw message
Signature · 1 line
1.8.3.1
v4 cover spapr: QMP: add query-hotpluggable-cpus
Changes since v3:
- replace qmp_query_hotpluggable_cpus with MachineClass->query_hotpluggable_cpus callback. (Eduardo Habkost <[email protected]>)
- fix cover letter to explain why new command is needed.
(Markus Armbruster <[email protected]>)
Changes since v2:
- rebase on top of hte lates spapr cpu hotpug series
- add 'vcpus-count' field, [email protected]
- s/CpuInstanceProps/CpuInstanceProperties/
- use '#optional' marker
- make "props" as always present even if it's empty
- fix JSON examples
- fix minor typos
- drop pre_plug spapr impl out of series as not related to QMP command
- drop generic pre hotplug callback as not related to QMP command
Changes since RFC:
- drop arch_id
- move CPU properties into separate structure
- target implements its own qmp callback version
- rebased on top of [RFC PATCH v1 00/10] Core based CPU hotplug for PowerPC sPAPR
https://www.mail-archive.com/[email protected]/msg357567.html
- convert slot name to core id hack
- drop links
- add generic pre hotplug callback
- implement query-hotpluggable-cpus
Series adds query-hotpluggable-cpus QMP command to allow mgmt query board specific configuration of possible CPU objects with their properties, which is target specific and also depends on CLI options (like -smp/-cpu/-numa).
Returned information includes QOM type of CPU objects and a set of properties that are necessary for hotplugging them. Information will be used with device_add/-device when hotplugging a CPU and migrating QEMU instance with hotplugged CPUs.
PS:
The first patch (QMP API) in this series could go in first allowing individual targets to post their hotplug implementation independently on top of it.
PS2:
Summary on QMP vs QOM interface discussion:
a QMP command is
1. a single / atomic command
2. well documented
3. fixed at compile time/staic so it's easy for mgmt to discover it.
while a considered alternative QOM interface via qom-get(path) is
1. not atomic, i.e. requires a lot of qom-get requests over the wire to traverse QOM tree and fetch information
2. not documented
3. dynamically generated and would require more complicated coding even to create a simplistic interface similar to proposed QMP command (for example: possible_cpu QOM objects with a related properties)
Igor Mammedov (2):
QMP: add query-hotpluggable-cpus
spapr: implement query-hotpluggable-cpus callback
hw/ppc/spapr.c | 33 +++++++++++++++++++++++++++++++++ include/hw/boards.h | 5 +++++ monitor.c | 13 +++++++++++++ qapi-schema.json | 41 +++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 43 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+)
Signature · 1 line
1.8.3.1
RFC v4 2/2 spapr: implement query-hotpluggable-cpus callback
it returns a list of present/possible to hotplug CPU objects with a list of properties to use with device_add.
in spapr case returned list would looks like:
-> { "execute": "query-hotpluggable-cpus" }
<- {"return": [
{ "props": { "core": 1 }, "type": "spapr-cpu-core",
"vcpus-count": 2 },
{ "props": { "core": 0 }, "type": "spapr-cpu-core",
"vcpus-count": 2,
"qom-path": "/machine/unattached/device[0]"}]}'
TODO:
add 'node' property for core <-> numa node mapping
---
it's only compile tested
v2:
- s/qmp_query_hotpluggable_cpus/MachineClass->query_hotpluggable_cpus/ callback
--- hw/ppc/spapr.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
hw/ppc/spapr.c +33 -0
@@ -65,6 +65,7 @@#include "hw/compat.h" #include "qemu-common.h" #include "hw/ppc/spapr_cpu_core.h" +#include "qmp-commands.h" #include <libfdt.h>
@@ -2389,6 +2390,37 @@ static unsigned spapr_cpu_index_to_socket_id(unsigned cpu_index)return cpu_index / smp_threads / smp_cores; } +static HotpluggableCPUList *spapr_query_hotpluggable_cpus (MachineState *machine) +{ +int i; +HotpluggableCPUList *head =NULL ; +sPAPRMachineState *spapr =SPAPR_MACHINE (machine); +int spapr_max_cores = max_cpus / smp_threads; + +for (i =0 ; i < spapr_max_cores; i++) { +HotpluggableCPUList *list_item =g_new0 (typeof (*list_item),1 ); +HotpluggableCPU *cpu_item =g_new0 (typeof (*cpu_item),1 ); +CpuInstanceProperties *cpu_props =g_new0 (typeof (*cpu_props),1 ); + + cpu_item->type =g_strdup (TYPE_SPAPR_CPU_CORE ); + cpu_item->vcpus_count = smp_threads; + cpu_props->has_core = true; + cpu_props->core = i; +/* TODO: add 'has_node/node' here to describe +to which node core belongs */ + + cpu_item->props = cpu_props; +if (spapr->cores[i]) { + cpu_item->has_qom_path = true; + cpu_item->qom_path =object_get_canonical_path (spapr->cores[i]); + } + list_item->value = cpu_item; + list_item->next = head; + head = list_item; + } +return head; +} +static void spapr_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -2418,6 +2450,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) hc->plug = spapr_machine_device_plug; hc->unplug = spapr_machine_device_unplug; mc->cpu_index_to_socket_id = spapr_cpu_index_to_socket_id; + mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus; smc->dr_lmb_enabled = true; smc->dr_cpu_enabled = true;
Signature · 1 line
1.8.3.1
PATCH v5 1/2 QMP: add query-hotpluggable-cpus
In reply to Igor Mammedovit will allow mgmt to query present and hotpluggable CPU objects, it is required from a target platform that wish to support command to implement and set
MachineClass.query_hotpluggable_cpus
callback, which will return a list of possible CPU objects with options that would be needed for hotplugging possible CPU objects.
There are:
'type': 'str' - QOM CPU object type for usage with device_add 'vcpus-count': 'int' - number of logical VCPU threads per
CPU object (mgmt needs to know)
and a set of optional fields that are to used for hotplugging a CPU objects and would allows mgmt tools to know what/where it could be hotplugged; [node],[socket],[core],[thread]
For present CPUs there is a 'qom-path' field which would allow mgmt to inspect whatever object/abstraction the target platform considers as CPU object.
---
v5:
- fix s390 build failure:
undefined reference to `qmp_query_hotpluggable_cpus'
v4:
- add MachineClass method to get CPU object list
v3:
- add 'vcpus-count' field, [email protected]
- s/CpuInstanceProps/CpuInstanceProperties/
- use '#optional' marker
- make "props" as always present even if it's empty
- fix JSON examples
- fix minor typos
--- include/hw/boards.h | 5 +++++ monitor.c | 13 +++++++++++++ qapi-schema.json | 41 +++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+)
include/hw/boards.h +5 -0
@@ -82,6 +82,10 @@ typedef struct {* Returns an array of @CPUArchId architecture-dependent CPU IDs * which includes CPU IDs for present and possible to hotplug CPUs. * Caller is responsible for freeing returned list. +* @query_hotpluggable_cpus: +* Returns a @HotpluggableCPUList, which describes CPUs objects which +* could be added with -device/device_add. +* Caller is responsible for freeing returned list. */ struct MachineClass {/*< private >*/
@@ -124,6 +128,7 @@ struct MachineClass { DeviceState *dev);unsigned (*cpu_index_to_socket_id)(unsigned cpu_index); CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); + HotpluggableCPUList *(*query_hotpluggable_cpus)(MachineState *machine); };/**
monitor.c +13 -0
@@ -4258,3 +4258,16 @@ void qmp_dump_skeys(const char *filename, Error **errp) error_setg(errp, QERR_FEATURE_DISABLED, "dump-skeys"); }#endif + +HotpluggableCPUList *qmp_query_hotpluggable_cpus (Error **errp) +{ +MachineState *ms =MACHINE (qdev_get_machine ()); +MachineClass *mc =MACHINE_GET_CLASS (ms); + +if (!mc->query_hotpluggable_cpus) { +error_setg (errp,QERR_FEATURE_DISABLED ,"query-hotpluggable-cpus" ); +return NULL ; + } + +return mc->query_hotpluggable_cpus (ms); +}
qapi-schema.json +41 -0
44 lines not on this page · raw message
qmp-commands.hx +43 -0
46 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v5 1/2] QMP: add query-hotpluggable-cpus
Quoted 27 lines · Igor Mammedov
it will allow mgmt to query present and hotpluggable CPU objects, it is required from a target platform that wish to support command to implement and set
MachineClass.query_hotpluggable_cpus
callback, which will return a list of possible CPU objects with options that would be needed for hotplugging possible CPU objects.There are:
'type': 'str' - QOM CPU object type for usage withdevice_add'vcpus-count': 'int' - number of logical VCPU threads per
CPU object (mgmt needs to know)and a set of optional fields that are to used for hotplugging a CPU objects and would allows mgmt tools to know what/where it could be hotplugged; [node],[socket],[core],[thread]
For present CPUs there is a 'qom-path' field which would allow mgmt to inspect whatever object/abstraction the target platform considers as CPU object.
Signed-off-by Igor Mammedov <[email protected]>---
+++
b/qapi-schema.json
qapi-schema.json line 4133
Quoted 8 lines
qapi-schema.json +5
-0@@ -4126,3 +4126,44 @@ ## { 'enum': 'ReplayMode', 'data': [ 'none', 'record', 'play' ] } + +## +# CpuInstanceProperties +# +# @node: NUMA node ID the CPU belongs to, optional
Mark this with '#optional', like you do in the other members.
qapi-schema.json line 4139
Quoted 6 lines
qapi-schema.json +6
-0+# @socket: #optional socket number within node/board the CPU belongs to +# @core: #optional core number within socket the CPU belongs to +# @thread: #optional thread number within core the CPU belongs to +# +# Since: 2.7 +{ 'struct': 'CpuInstanceProperties',
Missing ## trailing doc marker. Doesn't matter quite yet, but will once Marc-Andre's patches for automated doc generation land.
Quoted 8 lines
qapi-schema.json +8
-0+ 'data': { '*node': 'int', + '*socket': 'int', + '*core': 'int', + '*thread': 'int' + } +} + +##
qapi-schema.json line 4157
Quoted 10 lines
qapi-schema.json +10
-0+# @HotpluggableCPU +# +# @type: CPU object type for usage with device_add command +# @props: list of properties to be used for hotplugging CPU +# @vcpus-count: number of logical VCPU threads @HotpluggableCPU provides +# @qom-path: #optional link to existing CPU object if CPU is present or +# omitted if CPU is not present. +# +# Since: 2.7 +{ 'struct': 'HotpluggableCPU',
Another missing ##
qapi-schema.json line 4169
Quoted 12 lines
qapi-schema.json +12
-0+ 'data': { 'type': 'str', + 'vcpus-count': 'int', + 'props': 'CpuInstanceProperties', + '*qom-path': 'str' + } +} + +## +# @query-hotpluggable-cpus +# +# Since: 2.7 +{ 'command': 'query-hotpluggable-cpus', 'returns': ['HotpluggableCPU'] }
Looks okay.
Quoted 9 lines
qmp-commands.hx +1
-0@@ -4853,3 +4853,46 @@ Example: {"type": 0, "out-pport": 0, "pport": 0, "vlan-id": 3840, "pop-vlan": 1, "id": 251658240} ]} +
qmp-commands.hx Example: · line 4866
Quoted 10 lines
qmp-commands.hx +10
-0+EQMP + + { + .name = "query-hotpluggable-cpus", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_query_hotpluggable_cpus, + }, + +SQMP +Show existing/possible CPUs
Why two spaces?
qmp-commands.hx Example: · line 4867
Quoted 1 line
qmp-commands.hx +1
-0+-------------------------------
Line is too long.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org