From: Konrad Rzeszutek Wilk Date: Tue, 14 May 2013 17:48:47 +0000 (+0100) Subject: piix4acpi, xen, vcpu hotplug: Split the notification from the changes. X-Git-Tag: xen-4.3.0~4 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2133c3847bd2d3e0954e85dadc2ad2606c513cf8;p=qemu-xen-4.3-testing.git piix4acpi, xen, vcpu hotplug: Split the notification from the changes. 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 Acked-by: Stefano Stabellini Acked-by: George Dunlap (for 4.3 release) --- diff --git a/hw/piix4acpi.c b/hw/piix4acpi.c index fb1e5c356..54d566bb0 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 8915a6ed6..fa89c883f 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 66b8ab2b5..968258a84 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 d3a4588ba..c861d368d 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; }