WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] qemu-xen: fix cpu hotplug

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] qemu-xen: fix cpu hotplug
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Thu, 2 Sep 2010 14:17:20 +0100
Delivery-date: Thu, 02 Sep 2010 06:18:21 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
qemu-xen: fix cpu hotplug

The current xenstore watch path for a vcpu-set event is wrong and is
also wrong the code to parse it.
This patch fixes both of them: a xenstore vcpu hotplug command is of the
following form:

path: /local/domain/DOMID/cpu/VCPU_NUMBER/availability
values: "online" or "offline"

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

diff --git a/xenstore.c b/xenstore.c
index 6d24613..2c325ad 100644
--- a/xenstore.c
+++ b/xenstore.c
@@ -680,9 +680,12 @@ void xenstore_parse_domain_config(int hvm_domid)
     }
 
     /* Set a watch for vcpu-set */
-    if (pasprintf(&buf, "/local/domain/%u/cpu", domid) != -1) {
-        xs_watch(xsh, buf, "vcpu-set");
-        fprintf(logfile, "Watching %s\n", buf);
+    for (i = 0; i < vcpus; i++) {
+        if (pasprintf(&buf, "/local/domain/%u/cpu/%u/availability",
+                    domid, i) != -1) {
+            xs_watch(xsh, buf, "vcpu-set");
+            fprintf(logfile, "Watching %s\n", buf);
+        }
     }
 
     /* no need for ifdef CONFIG_STUBDOM, since in the qemu case
@@ -970,15 +973,14 @@ void xenstore_record_dm_state(const char *state)
 static void xenstore_process_vcpu_set_event(char **vec)
 {
     char *act = NULL;
-    char *vcpustr, *node = vec[XS_WATCH_PATH];
-    unsigned int vcpu, len;
+    char *node = vec[XS_WATCH_PATH];
+    unsigned int vcpu, len, domid;
 
-    vcpustr = strstr(node, "cpu/");
-    if (!vcpustr) {
-        fprintf(stderr, "vcpu-set: watch node error.\n");
+    if (sscanf(node, "/local/domain/%u/cpu/%u/availability",
+                &domid, &vcpu) <= 0) {
+        fprintf(stderr, "vcpu-set: watch node error, path=%s\n", node);
         return;
     }
-    sscanf(vcpustr, "cpu/%u", &vcpu);
 
     act = xs_read(xsh, XBT_NULL, node, &len);
     if (!act) {

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