pc: Forbid BSP removal
authorIgor Mammedov <imammedo@redhat.com>
Mon, 18 Jul 2016 08:31:22 +0000 (10:31 +0200)
committerEduardo Habkost <ehabkost@redhat.com>
Wed, 20 Jul 2016 15:02:19 +0000 (12:02 -0300)
Boot CPU is assumed to always present in QEMU code, so
untile that assumptions are gone, deny removal request,
In another words QEMU won't support BSP hot-unplug.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
hw/i386/pc.c

index f4c6a27508712f8105a5b8422d97ceda05ed0b8d..dd5661a72d82d2e78ba290ab18917c0fe17900eb 100644 (file)
@@ -1803,10 +1803,18 @@ out:
 static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
                                      DeviceState *dev, Error **errp)
 {
+    int idx = -1;
     HotplugHandlerClass *hhc;
     Error *local_err = NULL;
     PCMachineState *pcms = PC_MACHINE(hotplug_dev);
 
+    pc_find_cpu_slot(pcms, CPU(dev), &idx);
+    assert(idx != -1);
+    if (idx == 0) {
+        error_setg(&local_err, "Boot CPU is unpluggable");
+        goto out;
+    }
+
     hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
     hhc->unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);