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

Re: [Xen-devel] [PATCH 1/3] piix4acpi, xen, vcpu hotplug: Split the notification from the changes.



On Mon, 13 May 2013, Konrad Rzeszutek Wilk wrote:
> This is a prepatory patch that splits the notification
> of an vCPU change from the actual changes to the vCPU array.
> 
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>

Acked-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>


>  hw/piix4acpi.c | 12 ++++++++----
>  monitor.c      |  4 ++--
>  sysemu.h       |  4 +++-
>  xenstore.c     |  7 +++++--
>  4 files changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/piix4acpi.c b/hw/piix4acpi.c
> index fb1e5c3..54d566b 100644
> --- a/hw/piix4acpi.c
> +++ b/hw/piix4acpi.c
> @@ -814,22 +814,26 @@ static int disable_processor(GPEState *g, int cpu)
>      return 1;
>  }
>  
> -void qemu_cpu_add_remove(int cpu, int state)
> +int qemu_cpu_add_remove(int cpu, int state)
>  {
>      if ((cpu <0) || (cpu >= vcpus)) {
>          fprintf(stderr, "vcpu out of range, should be [0~%d]\n", vcpus - 1);
> -        return;
> +        return -EINVAL;
>      }
>  
>      if (state) {
>          if (!enable_processor(&gpe_state, cpu))
> -            return;
> +            return 0;
>      } else {
>          if (!disable_processor(&gpe_state, cpu))
> -            return;
> +            return 0;
>      }
>      fprintf(logfile, "%s vcpu %d\n", state ? "Add" : "Remove", cpu);
>  
> +    return 1;
> +}
> +void qemu_cpu_notify(void)
> +{
>      if (gpe_state.gpe0_en[0] & 4) {
>          qemu_set_irq(sci_irq, 1);
>          qemu_set_irq(sci_irq, 0);
> diff --git a/monitor.c b/monitor.c
> index 8915a6e..fa89c88 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1485,8 +1485,8 @@ static void do_cpu_set_nr(int value, const char *status)
>          term_printf("invalid status: %s\n", status);
>          return;
>      }
> -
> -    qemu_cpu_add_remove(value, state);
> +    if (qemu_cpu_add_remove(value, state))
> +        qemu_cpu_notify();
>  }
>  
>  /* Please update qemu-doc.texi when adding or changing commands */
> diff --git a/sysemu.h b/sysemu.h
> index 66b8ab2..968258a 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -173,9 +173,11 @@ extern int drive_add(const char *file, const char *fmt, 
> ...);
>  extern int drive_init(struct drive_opt *arg, int snapshot, void *machine);
>  
>  /* acpi */
> -void qemu_cpu_add_remove(int cpu, int state);
> +/* Returns 0 if nothing changed, 1 if added or removed and < 0 for errors. */
> +int qemu_cpu_add_remove(int cpu, int state);
>  void qemu_system_hot_add_init(void);
>  void qemu_system_device_hot_add(int pcibus, int slot, int state);
> +void qemu_cpu_notify(void);
>  
>  /* device-hotplug */
>  
> diff --git a/xenstore.c b/xenstore.c
> index d3a4588..c861d36 100644
> --- a/xenstore.c
> +++ b/xenstore.c
> @@ -1005,6 +1005,7 @@ static void xenstore_process_vcpu_set_event(char **vec)
>      char *act = NULL;
>      char *vcpustr, *node = vec[XS_WATCH_PATH];
>      unsigned int vcpu, len;
> +    int changed = -EINVAL;
>  
>      vcpustr = strstr(node, "cpu/");
>      if (!vcpustr) {
> @@ -1020,13 +1021,15 @@ static void xenstore_process_vcpu_set_event(char 
> **vec)
>      }
>  
>      if (!strncmp(act, "online", len))
> -        qemu_cpu_add_remove(vcpu, 1);
> +        changed = qemu_cpu_add_remove(vcpu, 1);
>      else if (!strncmp(act, "offline", len))
> -        qemu_cpu_add_remove(vcpu, 0);
> +        changed = qemu_cpu_add_remove(vcpu, 0);
>      else
>          fprintf(stderr, "vcpu-set: command error.\n");
>  
>      free(act);
> +    if (changed > 0)
> +        qemu_cpu_notify();
>      return;
>  }
>  
> -- 
> 1.8.1.4
> 

_______________________________________________
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®.