aboutsummaryrefslogtreecommitdiff
path: root/hw/ppc
diff options
context:
space:
mode:
authorBharata B Rao <bharata@linux.vnet.ibm.com>2016-07-13 12:20:20 +0530
committerDavid Gibson <david@gibson.dropbear.id.au>2016-07-18 10:40:27 +1000
commit5cbc64de25973e9129c5a7897734a06ac64b9aff (patch)
tree2bac96cf0e8ce6e2f576e1bf184c6fdaec15ff24 /hw/ppc
parent21bb3093e6accd2d7d60531a472a34e40911acd9 (diff)
downloadqemu-5cbc64de25973e9129c5a7897734a06ac64b9aff.zip
qemu-5cbc64de25973e9129c5a7897734a06ac64b9aff.tar.gz
qemu-5cbc64de25973e9129c5a7897734a06ac64b9aff.tar.bz2
spapr: Ensure CPU cores are added contiguously and removed in LIFO order
If CPU core addition or removal is allowed in random order leading to holes in the core id range (and hence in the cpu_index range), migration can fail as migration with holes in cpu_index range isn't yet handled correctly. Prevent this situation by enforcing the addition in contiguous order and removal in LIFO order so that we never end up with holes in cpu_index range. Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw/ppc')
-rw-r--r--hw/ppc/spapr_cpu_core.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index bc52b3c..4bfc96b 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -126,12 +126,23 @@ static void spapr_core_release(DeviceState *dev, void *opaque)
void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
+ sPAPRMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
CPUCore *cc = CPU_CORE(dev);
sPAPRDRConnector *drc =
spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, cc->core_id);
sPAPRDRConnectorClass *drck;
Error *local_err = NULL;
+ int smt = kvmppc_smt_threads();
+ int index = cc->core_id / smt;
+ int spapr_max_cores = max_cpus / smp_threads;
+ int i;
+ for (i = spapr_max_cores - 1; i > index; i--) {
+ if (spapr->cores[i]) {
+ error_setg(errp, "core-id %d should be removed first", i * smt);
+ return;
+ }
+ }
g_assert(drc);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
@@ -214,7 +225,7 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(OBJECT(hotplug_dev));
sPAPRMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
int spapr_max_cores = max_cpus / smp_threads;
- int index;
+ int index, i;
int smt = kvmppc_smt_threads();
Error *local_err = NULL;
CPUCore *cc = CPU_CORE(dev);
@@ -252,6 +263,14 @@ void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
goto out;
}
+ for (i = 0; i < index; i++) {
+ if (!spapr->cores[i]) {
+ error_setg(&local_err, "core-id %d should be added first",
+ i * smt);
+ goto out;
+ }
+ }
+
out:
g_free(base_core_type);
error_propagate(errp, local_err);