From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: pkrempa@redhat.com, bdas@redhat.com, ehabkost@redhat.com,
eduardo.otubo@profitbricks.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH v5 05/16] pc: enforce adding CPUs contiguously and removing them in opposit order
Date: Mon, 18 Jul 2016 10:32:36 +0200 [thread overview]
Message-ID: <1468830756-38795-1-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1468515285-173356-6-git-send-email-imammedo@redhat.com>
it will still allow us to use cpu_index as migration instance_id
since when CPUs are added contiguously (from the first to the last)
and removed in opposite order, cpu_index stays stable and it's
reproducable on destination side.
While there is work in progress to support migration when there
are holes in cpu_index range resulting from out-of-order plug or
unplug, this patch is intended as an interim solution until
cpu_index usage is cleaned up.
As result of this patch it would be possible to plug/unplug CPUs,
but in limited order that doesn't break migration.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v5:
- move note from under --- to commit message itself so it won't
be discarded along the way try to improve cmmit message
Bandan Das <bsd@redhat.com>
---
hw/i386/pc.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e15fcc1..dda91da 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1769,6 +1769,23 @@ static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
goto out;
}
+ if (idx < pcms->possible_cpus->len - 1 &&
+ pcms->possible_cpus->cpus[idx + 1].cpu != NULL) {
+ X86CPU *cpu;
+
+ for (idx = pcms->possible_cpus->len - 1;
+ pcms->possible_cpus->cpus[idx].cpu == NULL; idx--) {
+ ;;
+ }
+
+ cpu = X86_CPU(pcms->possible_cpus->cpus[idx].cpu);
+ error_setg(&local_err, "CPU [socket-id: %u, core-id: %u,"
+ " thread-id: %u] should be removed first",
+ cpu->socket_id, cpu->core_id, cpu->thread_id);
+ goto out;
+
+ }
+
hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
hhc->unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
@@ -1867,6 +1884,23 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
return;
}
+ if (idx != 0 && pcms->possible_cpus->cpus[idx - 1].cpu == NULL) {
+ PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
+
+ for (idx = 1; pcms->possible_cpus->cpus[idx].cpu != NULL; idx++) {
+ ;;
+ }
+
+ x86_topo_ids_from_apicid(pcms->possible_cpus->cpus[idx].arch_id,
+ smp_cores, smp_threads, &topo);
+
+ if (!pcmc->legacy_cpu_hotplug) {
+ error_setg(errp, "CPU [socket: %u, core: %u, thread: %u] should be"
+ " added first", topo.pkg_id, topo.core_id, topo.smt_id);
+ return;
+ }
+ }
+
/* if 'address' properties socket-id/core-id/thread-id are not set, set them
* so that query_hotpluggable_cpus would show correct values
*/
--
2.7.4
next prev parent reply other threads:[~2016-07-18 8:32 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 ` Igor Mammedov [this message]
2016-07-18 21:05 ` 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 ` [Qemu-devel] [PATCH v4 07/16] pc: implement query-hotpluggable-cpus callback Igor Mammedov
2016-07-18 20:46 ` 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=1468830756-38795-1-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).