]> xenbits.xensource.com Git - qemu-xen-traditional.git/commitdiff
piix4acpi, xen, vcpu hotplug: Split the notification from the changes.
authorKonrad Rzeszutek Wilk <konrad@kernel.org>
Tue, 14 May 2013 17:48:47 +0000 (18:48 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 21 May 2013 10:48:44 +0000 (11:48 +0100)
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@oracle.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com> (for 4.3 release)
hw/piix4acpi.c
monitor.c
sysemu.h
xenstore.c

index fb1e5c356777291dc3677974b7bc73676bc712e1..54d566bb0b73d91488aa85c068a50b19f9cfeb31 100644 (file)
@@ -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);
index 8915a6ed67d0d5297d4a6d0327f65e45891c4971..fa89c883fc37390bf1c456f0a9f6e4d542a2b827 100644 (file)
--- 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 */
index 66b8ab2b5da656239c413e0ae7d02c80caa2e505..968258a8411c8bf514ffd235f84339c69e588f5d 100644 (file)
--- 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 */
 
index d3a4588baa68869bfec58b0413db50757dada171..c861d368d93c8e1d5f26c556f1ffe7a6d21e088e 100644 (file)
@@ -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;
 }