All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix hvm vcpu hotplug bug
@ 2010-08-07 17:39 Liu, Jinsong
  2010-08-11 13:54 ` Ian Jackson
  0 siblings, 1 reply; 11+ messages in thread
From: Liu, Jinsong @ 2010-08-07 17:39 UTC (permalink / raw)
  To: Keir Fraser, xen-devel; +Cc: Jiang, Yunhong, Li, Xin

[-- Attachment #1: Type: text/plain, Size: 342 bytes --]

When hotplug hvm vcpu by 'xm vcpu-set' command, if it add/remove
many vcpus by 1 'xm vcpu-set' command, it has a bug that it cannot
add/remove all vcpus that want to be added/removed.
This patch is to fix the bug. It delays trigger sci until all xenstore
cpu node status are watched.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>

[-- Attachment #2: fix-qemu-vcpu-hotplug.patch --]
[-- Type: application/octet-stream, Size: 3334 bytes --]

From a596641aed36f06dabde97155e60f9266d8f7bfb Mon Sep 17 00:00:00 2001
From: Liu Jinsong <jinsong.liu@intel.com>
Date: Sun, 8 Aug 2010 01:12:11 +0800
Subject: [PATCH] Fix hvm vcpu hotplug bug

When hotplug hvm vcpu by 'xm vcpu-set' command, if it add/remove
many vcpus by 1 'xm vcpu-set' command, it has a bug that it cannot
add/remove all vcpus that want to be added/removed.
This patch is to fix the bug. It delays trigger sci until all xenstore
cpu node status are watched.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
---
 hw/piix4acpi.c |   31 +++++++++++++++++++------------
 sysemu.h       |    2 ++
 xenstore.c     |   10 ++++++++--
 3 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/hw/piix4acpi.c b/hw/piix4acpi.c
index 1efa77d..8698bbd 100644
--- a/hw/piix4acpi.c
+++ b/hw/piix4acpi.c
@@ -747,6 +747,22 @@ static int disable_processor(GPEState *g, int cpu)
     return 1;
 }
 
+int qemu_cpu_state(int cpu, int state)
+{
+    if (state)
+        return enable_processor(&gpe_state, cpu);
+    else
+        return disable_processor(&gpe_state, cpu);
+}
+
+void qemu_cpu_sci(void)
+{
+    if (gpe_state.gpe0_en[0] & 4) {
+        qemu_set_irq(sci_irq, 1);
+        qemu_set_irq(sci_irq, 0);
+    }
+}
+
 void qemu_cpu_add_remove(int cpu, int state)
 {
     if ((cpu <0) || (cpu >= vcpus)) {
@@ -754,17 +770,8 @@ void qemu_cpu_add_remove(int cpu, int state)
         return;
     }
 
-    if (state) {
-        if (!enable_processor(&gpe_state, cpu))
-            return;
-    } else {
-        if (!disable_processor(&gpe_state, cpu))
-            return;
-    }
-    fprintf(logfile, "%s vcpu %d\n", state ? "Add" : "Remove", cpu);
+    if (!qemu_cpu_state(cpu, state))
+        return;
 
-    if (gpe_state.gpe0_en[0] & 4) {
-        qemu_set_irq(sci_irq, 1);
-        qemu_set_irq(sci_irq, 0);
-    }
+    qemu_cpu_sci();
 }
diff --git a/sysemu.h b/sysemu.h
index 87b278b..7a9f989 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -173,6 +173,8 @@ 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_sci(void);
+int qemu_cpu_state(int cpu, int state);
 void 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);
diff --git a/xenstore.c b/xenstore.c
index 4a35f55..2b3c3f2 100644
--- a/xenstore.c
+++ b/xenstore.c
@@ -972,6 +972,7 @@ static void xenstore_process_vcpu_set_event(char **vec)
     char *act = NULL;
     char *vcpustr, *node = vec[XS_WATCH_PATH];
     unsigned int vcpu, len;
+    static int done = 0;
 
     vcpustr = strstr(node, "cpu/");
     if (!vcpustr) {
@@ -987,12 +988,17 @@ static void xenstore_process_vcpu_set_event(char **vec)
     }
 
     if (!strncmp(act, "online", len))
-        qemu_cpu_add_remove(vcpu, 1);
+        qemu_cpu_state(vcpu, 1);
     else if (!strncmp(act, "offline", len))
-        qemu_cpu_add_remove(vcpu, 0);
+        qemu_cpu_state(vcpu, 0);
     else
         fprintf(stderr, "vcpu-set: command error.\n");
 
+    if ((++done) == vcpus) {
+        done = 0;
+        qemu_cpu_sci();
+    }
+
     free(act);
     return;
 }
-- 
1.5.6.4


[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-08-25  4:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-07 17:39 [PATCH] Fix hvm vcpu hotplug bug Liu, Jinsong
2010-08-11 13:54 ` Ian Jackson
2010-08-18  4:57   ` Liu, Jinsong
2010-08-18 13:53     ` Ian Jackson
2010-08-19  2:20       ` Liu, Jinsong
2010-08-19 14:42         ` Ian Jackson
2010-08-20  3:29           ` Liu, Jinsong
2010-08-20 13:23             ` Ian Jackson
2010-08-22  5:00               ` Liu, Jinsong
2010-08-24 14:19                 ` Ian Jackson
2010-08-25  4:53                   ` Liu, Jinsong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.