From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: pkrempa@redhat.com, ehabkost@redhat.com, mst@redhat.com,
eduardo.otubo@profitbricks.com, Bandan Das <bdas@redhat.com>
Subject: [Qemu-devel] [PATCH v4 07/16] pc: implement query-hotpluggable-cpus callback
Date: Thu, 14 Jul 2016 18:54:36 +0200 [thread overview]
Message-ID: <1468515285-173356-8-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1468515285-173356-1-git-send-email-imammedo@redhat.com>
it returns a list of present/possible to hotplug CPU
objects with a list of properties to use with
device_add.
in PC case returned list would looks like:
-> { "execute": "query-hotpluggable-cpus" }
<- {"return": [
{
"type": "qemu64-x86_64-cpu", "vcpus-count": 1,
"props": {"core-id": 0, "socket-id": 1, "thread-id": 0}
},
{
"qom-path": "/machine/unattached/device[0]",
"type": "qemu64-x86_64-cpu", "vcpus-count": 1,
"props": {"core-id": 0, "socket-id": 0, "thread-id": 0}
}
]}
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
---
v2:
- add -id suffix to socket/core/thread properties to match fixed schema
---
hw/i386/pc.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
qmp-commands.hx | 15 +++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 75a92d0..feb71f9 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -2184,6 +2184,50 @@ static CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *machine)
return list;
}
+static HotpluggableCPUList *pc_query_hotpluggable_cpus(MachineState *machine)
+{
+ int i;
+ CPUState *cpu;
+ HotpluggableCPUList *head = NULL;
+ PCMachineState *pcms = PC_MACHINE(machine);
+ const char *cpu_type;
+
+ cpu = pcms->possible_cpus->cpus[0].cpu;
+ assert(cpu); /* BSP is always present */
+ cpu_type = object_class_get_name(OBJECT_CLASS(CPU_GET_CLASS(cpu)));
+
+ for (i = 0; i < pcms->possible_cpus->len; i++) {
+ X86CPUTopoInfo topo;
+ 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);
+ const uint32_t apic_id = pcms->possible_cpus->cpus[i].arch_id;
+
+ x86_topo_ids_from_apicid(apic_id, smp_cores, smp_threads, &topo);
+
+ cpu_item->type = g_strdup(cpu_type);
+ cpu_item->vcpus_count = 1;
+ cpu_props->has_socket_id = true;
+ cpu_props->socket_id = topo.pkg_id;
+ cpu_props->has_core_id = true;
+ cpu_props->core_id = topo.core_id;
+ cpu_props->has_thread_id = true;
+ cpu_props->thread_id = topo.smt_id;
+ cpu_item->props = cpu_props;
+
+ cpu = pcms->possible_cpus->cpus[i].cpu;
+ if (cpu) {
+ cpu_item->has_qom_path = true;
+ cpu_item->qom_path = object_get_canonical_path(OBJECT(cpu));
+ }
+
+ list_item->value = cpu_item;
+ list_item->next = head;
+ head = list_item;
+ }
+ return head;
+}
+
static void x86_nmi(NMIState *n, int cpu_index, Error **errp)
{
/* cpu index isn't used */
@@ -2224,6 +2268,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
mc->get_hotplug_handler = pc_get_hotpug_handler;
mc->cpu_index_to_socket_id = pc_cpu_index_to_socket_id;
mc->possible_cpu_arch_ids = pc_possible_cpu_arch_ids;
+ mc->query_hotpluggable_cpus = pc_query_hotpluggable_cpus;
mc->default_boot_order = "cad";
mc->hot_add_cpu = pc_hot_add_cpu;
mc->max_cpus = 255;
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 6937e83..3afe066 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -4983,3 +4983,18 @@ Example for pseries machine type started with
{ "props": { "core-id": 0 }, "type": "POWER8-spapr-cpu-core",
"vcpus-count": 1, "qom-path": "/machine/unattached/device[0]"}
]}'
+
+Example for pc machine type started with
+-smp 1,maxcpus=2:
+ -> { "execute": "query-hotpluggable-cpus" }
+ <- {"return": [
+ {
+ "type": "qemu64-x86_64-cpu", "vcpus-count": 1,
+ "props": {"core-id": 0, "socket-id": 1, "thread-id": 0}
+ },
+ {
+ "qom-path": "/machine/unattached/device[0]",
+ "type": "qemu64-x86_64-cpu", "vcpus-count": 1,
+ "props": {"core-id": 0, "socket-id": 0, "thread-id": 0}
+ }
+ ]}
--
2.7.4
next prev parent reply other threads:[~2016-07-14 16:55 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-14 16:54 [Qemu-devel] [PATCH v4 00/16] pc: add CPU hot-add/hot-remove with device_add/device_del Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 01/16] pc: set APIC ID based on socket/core/thread ids if it's not been set yet Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 02/16] pc: delay setting number of boot CPUs to machine_done time Igor Mammedov
2016-07-14 17:37 ` Eduardo Habkost
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 03/16] pc: register created initial and hotpluged CPUs in one place pc_cpu_plug() Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 04/16] pc: forbid BSP removal Igor Mammedov
2016-07-14 17:49 ` Bandan Das
2016-07-14 17:54 ` Eduardo Habkost
2016-07-14 18:16 ` Bandan Das
2016-07-14 20:55 ` Eduardo Habkost
2016-07-14 21:02 ` Bandan Das
2016-07-15 9:25 ` Igor Mammedov
2016-07-18 8:31 ` [Qemu-devel] [PATCH v5 " Igor Mammedov
2016-07-19 12:55 ` Eduardo Habkost
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 05/16] pc: enforce adding CPUs contiguously and removing them in opposit order Igor Mammedov
2016-07-14 18:10 ` Bandan Das
2016-07-15 9:33 ` Igor Mammedov
2016-07-15 15:57 ` Bandan Das
2016-07-18 8:32 ` [Qemu-devel] [PATCH v5 " Igor Mammedov
2016-07-18 21:05 ` [Qemu-devel] [PATCH v4 " Eric Blake
2016-07-19 12:25 ` Igor Mammedov
2016-07-19 12:30 ` Eduardo Habkost
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 06/16] pc: cpu: allow device_add to be used with x86 cpu Igor Mammedov
2016-07-14 16:54 ` Igor Mammedov [this message]
2016-07-18 20:46 ` [Qemu-devel] [PATCH v4 07/16] pc: implement query-hotpluggable-cpus callback Michael S. Tsirkin
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 08/16] apic: move MAX_APICS check to 'apic' class Igor Mammedov
2016-07-18 16:35 ` Radim Krčmář
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 09/16] apic: drop APICCommonState.idx and use APIC ID as index in local_apics[] Igor Mammedov
2016-07-18 16:58 ` Radim Krčmář
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 10/16] apic: kvm-apic: fix crash due to access to freed memory region Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 11/16] (kvm)apic: add unrealize callbacks Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 12/16] apic: use apic_id as apic's migration instance_id Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 13/16] target-i386: cpu: do not ignore error and fix apic parent Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 14/16] target-i386: fix apic object leak when CPU is deleted Igor Mammedov
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 15/16] target-i386: add x86_cpu_unrealizefn() Igor Mammedov
2016-07-19 17:05 ` Eduardo Habkost
2016-07-14 16:54 ` [Qemu-devel] [PATCH v4 16/16] pc: make device_del CPU work for x86 CPUs Igor Mammedov
2016-07-18 21:59 ` [Qemu-devel] [PATCH v4 00/16] pc: add CPU hot-add/hot-remove with device_add/device_del Michael S. Tsirkin
2016-08-10 13:56 ` Eduardo Otubo
2016-08-10 14:07 ` Igor Mammedov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1468515285-173356-8-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=bdas@redhat.com \
--cc=eduardo.otubo@profitbricks.com \
--cc=ehabkost@redhat.com \
--cc=mst@redhat.com \
--cc=pkrempa@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).