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

[Xen-tools] [PATCH] sparse,xend: change hotplug store entries

To: xen-tools@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-tools] [PATCH] sparse,xend: change hotplug store entries
From: Ryan Harper <ryanh@xxxxxxxxxx>
Date: Thu, 11 Aug 2005 12:02:56 -0500
Delivery-date: Thu, 11 Aug 2005 17:01:16 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-tools-request@lists.xensource.com?subject=help>
List-id: Xen control tools developers <xen-tools.lists.xensource.com>
List-post: <mailto:xen-tools@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-tools>, <mailto:xen-tools-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-tools>, <mailto:xen-tools-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-tools-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6+20040907i
This patch addresses Rustys' [1]suggestions.  Most visably:

Entries in the store:
/cpus/cpuX/online -> /cpu/X/availability

Values:
0|1 -> online|offline


1. http://lists.xensource.com/archives/html/xen-devel/2005-08/msg00296.html

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
ryanh@xxxxxxxxxx


diffstat output:
 linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c |   73 +++++++++-----------
 tools/python/xen/xend/XendDomainInfo.py             |   12 +--
 2 files changed, 40 insertions(+), 45 deletions(-)

Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>
---
diff -r 10b395bc465e linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c       Thu Aug 11 
13:07:08 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c       Thu Aug 11 
11:29:33 2005
@@ -1353,83 +1353,82 @@
                printk(KERN_ALERT "Error creating hotplug_cpu process!\n");
 }
 
-static void handle_cpus_watch(struct xenbus_watch *, const char *);
-static struct notifier_block xsn_cpus;
+static void handle_vcpu_hotplug_event(struct xenbus_watch *, const char *);
+static struct notifier_block xsn_cpu;
 
 /* xenbus watch struct */
-static struct xenbus_watch cpus_watch = {
-       .node = "cpus",
-       .callback = handle_cpus_watch,
+static struct xenbus_watch cpu_watch = {
+       .node = "cpu",
+       .callback = handle_vcpu_hotplug_event
 };
 
-static int setup_cpus_watcher(struct notifier_block *notifier,
+/* NB: Assumes xenbus_lock is held! */
+static int setup_cpu_watcher(struct notifier_block *notifier,
                              unsigned long event, void *data)
 {
        int err = 0;
 
-       down(&xenbus_lock);
-       err = register_xenbus_watch(&cpus_watch);
-       up(&xenbus_lock);
+       BUG_ON(down_trylock(&xenbus_lock) == 0);
+       err = register_xenbus_watch(&cpu_watch);
 
        if (err) {
-               printk("Failed to set cpus watcher\n");
-       }
+               printk("Failed to register watch on /cpu\n");
+       }
+
        return NOTIFY_DONE;
 }
 
-static void handle_cpus_watch(struct xenbus_watch *watch, const char *node)
+static void handle_vcpu_hotplug_event(struct xenbus_watch *watch, const char 
*node)
 {
        static DECLARE_WORK(vcpu_hotplug_work, __vcpu_hotplug_handler, NULL);
        struct vcpu_hotplug_handler_t *handler = &vcpu_hotplug_handler;
        ssize_t ret;
-       int err, cpu, state;
+       int err, cpu;
+       char state[8];
        char dir[32];
        char *cpustr;
 
-       /* get a pointer to start of cpus/cpu string */
-       if ((cpustr = strstr(node, "cpus/cpu")) != NULL) {
+       /* get a pointer to start of cpu string */
+       if ((cpustr = strstr(node, "cpu/")) != NULL) {
 
                /* find which cpu state changed, note vcpu for handler */
-               sscanf(cpustr, "cpus/cpu%d", &cpu);
+               sscanf(cpustr, "cpu/%d", &cpu);
                handler->vcpu = cpu;
 
                /* calc the dir for xenbus read */
-               sprintf(dir, "cpus/cpu%d", cpu);
-
-               /* make sure watch that was triggered is changes to the online 
key */
-               if ((strcmp(node + strlen(dir), "/online")) != 0)
+               sprintf(dir, "cpu/%d", cpu);
+
+               /* make sure watch that was triggered is changes to the correct 
key */
+               if ((strcmp(node + strlen(dir), "/availability")) != 0)
                        return;
 
                /* get the state value */
-               xenbus_transaction_start("cpus");
-               err = xenbus_scanf(dir, "online", "%d", &state);
+               xenbus_transaction_start("cpu");
+               err = xenbus_scanf(dir, "availability", "%s", state);
                xenbus_transaction_end(0);
 
                if (err != 1) {
                        printk(KERN_ERR
-                              "XENBUS: Unable to read cpu online state\n");
+                              "XENBUS: Unable to read cpu state\n");
                        return;
                }
 
                /* if we detect a state change, take action */
-               switch (state) {
+               if (strcmp(state, "online") == 0) {
                        /* offline -> online */
-               case 1:
                        if (!cpu_isset(cpu, cpu_online_map)) {
                                handler->fn = (void *)&cpu_up;
                                ret = schedule_work(&vcpu_hotplug_work);
-                       }
-                       break;
+                       } 
+               } else if (strcmp(state, "offline") == 0) {
                        /* online -> offline */
-               case 0:
                        if (cpu_isset(cpu, cpu_online_map)) {
                                handler->fn = (void *)&cpu_down;
                                ret = schedule_work(&vcpu_hotplug_work);
-                       }
-                       break;
-               default:
+                       } 
+               } else {
                        printk(KERN_ERR
-                              "XENBUS: unknown state(%d) on node(%s)\n", state,
+                              "XENBUS: unknown state(%s) on node(%s)\n", state,
                               node);
                }
        }
@@ -1438,13 +1437,9 @@
 
 static int __init setup_vcpu_hotplug_event(void)
 {
-       xsn_cpus.notifier_call = setup_cpus_watcher;
-
-       if (xen_start_info.store_evtchn) {
-               setup_cpus_watcher(&xsn_cpus, 0, NULL);
-       } else {
-               register_xenstore_notifier(&xsn_cpus);
-       }
+       xsn_cpu.notifier_call = setup_cpu_watcher;
+
+       register_xenstore_notifier(&xsn_cpu);
 
        return 0;
 }
diff -r 10b395bc465e tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Aug 11 13:07:08 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Aug 11 11:29:33 2005
@@ -557,12 +557,12 @@
 
     def exportVCPUSToDB(self, vcpus):
         for v in range(0,vcpus):
-            path = "/cpus/cpu%d"%(v)
+            path = "/cpu/%d"%(v)
             if not self.vcpusdb.has_key(path):
                 self.vcpusdb[path] = self.db.addChild(path)
             db = self.vcpusdb[path]
-            log.debug("writing key online=1 to path %s in store"%(path))
-            db['online'] = "1"
+            log.debug("writing key availability=online to path %s in 
store"%(path))
+            db['availability'] = "online"
             db.saveDB(save=True)
 
     def init_image(self):
@@ -951,16 +951,16 @@
         """
         db = ""
         try:
-            db = self.vcpusdb['/cpus/cpu%d'%(vcpu)]
+            db = self.vcpusdb['/cpu/%d'%(vcpu)]
         except:
             log.error("Invalid VCPU")
             return
 
         if self.store_channel:
             if int(state) == 0:
-                db['online'] = "0"
+                db['availability'] = "offline"
             else:
-                db['online'] = "1"
+                db['availability'] = "online"
 
         db.saveDB(save=True)
 

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

<Prev in Thread] Current Thread [Next in Thread>