]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
xen: Implement hot_add_cpu hook.
authorAnthony PERARD <anthony.perard@citrix.com>
Mon, 10 Jun 2013 14:29:31 +0000 (15:29 +0100)
committerAnthony PERARD <anthony.perard@citrix.com>
Mon, 17 Jun 2013 11:35:38 +0000 (12:35 +0100)
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
hw/acpi_piix4.c
hw/pc_piix.c
sysemu.h

index 56d7c2c72716ab48cdc6770da0fcef19737e22d1..059b64fdc4bc205070226c9ddce721476db9b4a3 100644 (file)
@@ -662,6 +662,26 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, int64_t cpu_id,
     pm_update_sci(s);
 }
 
+static PIIX4PMState *piix4pm_state;
+void piix4_cpu_hotplug_add(const int64_t cpu_id, Error **errp)
+{
+    CPUStatus *g = &piix4pm_state->gpe_cpu;
+
+    if (cpu_id >= max_cpus) {
+        error_setg(errp, "Unable to add CPU: %" PRIi64
+                   ", max allowed: %d", cpu_id, max_cpus - 1);
+        return;
+    }
+    if (g->sts[cpu_id / 8] & (1 << (cpu_id % 8))) {
+        /* Already requested to be hotplug. */
+        error_setg(errp, "Unable to add CPU: %" PRIi64
+                   ", it already exists", cpu_id);
+        return;
+    }
+
+    piix4_cpu_hotplug_req(piix4pm_state, cpu_id, PLUG);
+}
+
 static void piix4_init_cpu_status(CPUState *cpu, void *data)
 {
     CPUStatus *g = (CPUStatus *)data;
@@ -697,6 +717,7 @@ static void piix4_acpi_system_hot_add_init(PCIBus *bus, PIIX4PMState *s)
                           PIIX4_PROC_LEN);
     memory_region_add_subregion(pci_address_space_io(&s->dev),
                                 PIIX4_PROC_BASE, &s->io_cpu);
+    piix4pm_state = s;
 }
 
 static void enable_device(PIIX4PMState *s, int slot)
index aa3e7f40dcc27139ff399e8c9020dbe7952c8039..7e12f5d284efc55a44c874819a9ad8a154bbd840 100644 (file)
@@ -621,6 +621,7 @@ static QEMUMachine xenfv_machine = {
     .init = pc_xen_hvm_init,
     .max_cpus = HVM_MAX_VCPUS,
     .default_machine_opts = "accel=xen",
+    .hot_add_cpu = piix4_cpu_hotplug_add,
 };
 #endif
 
index f5ac6640677ee421d64986524e637ebaad84e0c2..b71f244eda5b02488274eeb89c7b18f34068e104 100644 (file)
--- a/sysemu.h
+++ b/sysemu.h
@@ -183,4 +183,6 @@ char *get_boot_devices_list(uint32_t *size);
 
 bool usb_enabled(bool default_usb);
 
+void piix4_cpu_hotplug_add(const int64_t cpu_id, Error **errp);
+
 #endif