All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Liu, Jinsong" <jinsong.liu@intel.com>
To: Keir Fraser <keir.fraser@eu.citrix.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Cc: "Jiang, Yunhong" <yunhong.jiang@intel.com>, "Li, Xin" <xin.li@intel.com>
Subject: [PATCH] Fix hvm vcpu hotplug bug
Date: Sun, 8 Aug 2010 01:39:26 +0800	[thread overview]
Message-ID: <BC00F5384FCFC9499AF06F92E8B78A9E0B0007FD20@shsmsx502.ccr.corp.intel.com> (raw)

[-- 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

             reply	other threads:[~2010-08-07 17:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-07 17:39 Liu, Jinsong [this message]
2010-08-11 13:54 ` [PATCH] Fix hvm vcpu hotplug bug 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BC00F5384FCFC9499AF06F92E8B78A9E0B0007FD20@shsmsx502.ccr.corp.intel.com \
    --to=jinsong.liu@intel.com \
    --cc=keir.fraser@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    --cc=xin.li@intel.com \
    --cc=yunhong.jiang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.