[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 7/7] xen: Implement hot_add_cpu hook.



On Mon, 17 Jun 2013, Anthony PERARD wrote:
> Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> ---
>  hw/acpi_piix4.c | 21 +++++++++++++++++++++
>  hw/pc_piix.c    |  1 +
>  sysemu.h        |  2 ++
>  3 files changed, 24 insertions(+)
> 
> diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
> index 56d7c2c..059b64f 100644
> --- a/hw/acpi_piix4.c
> +++ b/hw/acpi_piix4.c
> @@ -662,6 +662,26 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, 
> int64_t cpu_id,
>      pm_update_sci(s);
>  }
>  
> +static PIIX4PMState *piix4pm_state;

I really dislike this static variable. Isn't there a way to retrieve the
PIIX4PMState from the cpu_id?


> +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)
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index aa3e7f4..7e12f5d 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -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
>  
> diff --git a/sysemu.h b/sysemu.h
> index f5ac664..b71f244 100644
> --- 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
> -- 
> Anthony PERARD
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.