[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Restore configurability of vif bring up script and passing arguments to the script.



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID edd1616cf8cb6f0d7ab32600a27d3a98ac8414b2
# Parent  af78c9d526e0b3502629fb0ef09064920157c0c5
Restore configurability of vif bring up script and passing arguments to the 
script.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r af78c9d526e0 -r edd1616cf8cb 
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Thu Sep  1 10:45:50 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Fri Sep  2 14:15:49 2005
@@ -160,9 +160,47 @@
                }
 #endif
 
+               kobject_hotplug(&dev->dev.kobj, KOBJ_ONLINE);
+
                /* Pass in NULL node to skip exist test. */
                frontend_changed(&be->watch, NULL);
        }
+}
+
+static int netback_hotplug(struct xenbus_device *xdev, char **envp,
+                          int num_envp, char *buffer, int buffer_size)
+{
+       struct backend_info *be;
+       netif_t *netif;
+       char **key, *val;
+       int i = 0, length = 0;
+       static char *env_vars[] = { "script", "domain", "mac", "bridge", "ip",
+                                   NULL };
+
+       be = xdev->data;
+       netif = be->netif;
+
+       add_hotplug_env_var(envp, num_envp, &i,
+                           buffer, buffer_size, &length,
+                           "vif=%s", netif->dev->name);
+
+       key = env_vars;
+       while (*key != NULL) {
+               val = xenbus_read(xdev->nodename, *key, NULL);
+               if (!IS_ERR(val)) {
+                       char buf[strlen(*key) + 4];
+                       sprintf(buf, "%s=%%s", *key);
+                       add_hotplug_env_var(envp, num_envp, &i,
+                                           buffer, buffer_size, &length,
+                                           buf, val);
+                       kfree(val);
+               }
+               key++;
+       }
+
+       envp[i] = NULL;
+
+       return 0;
 }
 
 static int netback_probe(struct xenbus_device *dev,
@@ -249,6 +287,7 @@
        .ids = netback_ids,
        .probe = netback_probe,
        .remove = netback_remove,
+       .hotplug = netback_hotplug,
 };
 
 void netif_xenbus_init(void)
diff -r af78c9d526e0 -r edd1616cf8cb 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Thu Sep  1 
10:45:50 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Fri Sep  2 
14:15:49 2005
@@ -147,6 +147,39 @@
        return 0;
 }
 
+static int xenbus_hotplug_backend(struct device *dev, char **envp,
+                                 int num_envp, char *buffer, int buffer_size)
+{
+       struct xenbus_device *xdev;
+       int i = 0;
+       int length = 0;
+
+       if (dev == NULL)
+               return -ENODEV;
+
+       xdev = to_xenbus_device(dev);
+       if (xdev == NULL)
+               return -ENODEV;
+
+       /* stuff we want to pass to /sbin/hotplug */
+       add_hotplug_env_var(envp, num_envp, &i,
+                           buffer, buffer_size, &length,
+                           "XENBUS_TYPE=%s", xdev->devicetype);
+
+       /* terminate, set to next free slot, shrink available space */
+       envp[i] = NULL;
+       envp = &envp[i];
+       num_envp -= i;
+       buffer = &buffer[length];
+       buffer_size -= length;
+
+       if (dev->driver && to_xenbus_driver(dev->driver)->hotplug)
+               return to_xenbus_driver(dev->driver)->hotplug
+                       (xdev, envp, num_envp, buffer, buffer_size);
+
+       return 0;
+}
+
 static int xenbus_probe_backend(const char *type, const char *uuid);
 static struct xen_bus_type xenbus_backend = {
        .root = "backend",
@@ -156,6 +189,7 @@
        .bus = {
                .name  = "xen-backend",
                .match = xenbus_match,
+               .hotplug = xenbus_hotplug_backend,
        },
        .dev = {
                .bus_id = "xen-backend",
diff -r af78c9d526e0 -r edd1616cf8cb 
linux-2.6-xen-sparse/include/asm-xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h     Thu Sep  1 10:45:50 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h     Fri Sep  2 14:15:49 2005
@@ -64,6 +64,7 @@
        int (*remove)(struct xenbus_device *dev);
        int (*suspend)(struct xenbus_device *dev);
        int (*resume)(struct xenbus_device *dev);
+       int (*hotplug)(struct xenbus_device *, char **, int, char *, int);
        struct device_driver driver;
 };
 
diff -r af78c9d526e0 -r edd1616cf8cb tools/examples/xen-backend.agent
--- a/tools/examples/xen-backend.agent  Thu Sep  1 10:45:50 2005
+++ b/tools/examples/xen-backend.agent  Fri Sep  2 14:15:49 2005
@@ -1,21 +1,25 @@
 #! /bin/sh
 
+#ACTION=add
 #DEVPATH=/devices/xen-backend/vif-1-0
-#ACTION=add
+#PHYSDEVDRIVER=vif
+#XENBUS_TYPE=vif
 
 PATH=/etc/xen/scripts:$PATH
 
-DEV=$(basename "$DEVPATH")
 case "$ACTION" in
   add)
-    case "$DEV" in
-      vif-*)
-        vif=$(echo "$DEV" | sed 's/-\([0-9]*\)-\([0-9]*\)/\1.\2/')
-        vif-bridge up domain=unknown vif="$vif" mac=fe:ff:ff:ff:ff:ff 
bridge=xen-br0 >/dev/null 2>&1
+    ;;
+  remove)
+    ;;
+  online)
+    case "$PHYSDEVDRIVER" in
+      vif)
+        [ -n "$script" ] && $script up
         ;;
     esac
     ;;
-  remove)
+  offline)
     ;;
 esac
 
diff -r af78c9d526e0 -r edd1616cf8cb tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Sep  1 10:45:50 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py   Fri Sep  2 14:15:49 2005
@@ -430,6 +430,15 @@
             return
 
         if type == 'vif':
+            from xen.xend import XendRoot
+            xroot = XendRoot.instance()
+
+            def _get_config_ipaddr(config):
+                val = []
+                for ipaddr in sxp.children(config, elt='ip'):
+                    val.append(sxp.child0(ipaddr))
+                return val
+
             backdom = domain_exists(sxp.child_value(devconfig, 'backend', '0'))
 
             log.error(devconfig)
@@ -437,6 +446,14 @@
             devnum = self.netif_idx
             self.netif_idx += 1
 
+            script = sxp.child_value(devconfig, 'script',
+                                     xroot.get_vif_script())
+            script = os.path.join(xroot.network_script_dir, script)
+            bridge = sxp.child_value(devconfig, 'bridge',
+                                     xroot.get_vif_bridge())
+            mac = sxp.child_value(devconfig, 'mac')
+            ipaddr = _get_config_ipaddr(devconfig)
+
             # create backend db
             backdb = backdom.db.addChild("/backend/%s/%s/%d" %
                                          (type, self.uuid, devnum))
@@ -444,6 +461,12 @@
             # create frontend db
             db = self.db.addChild("/device/%s/%d" % (type, devnum))
             
+            backdb['script'] = script
+            backdb['domain'] = self.name
+            backdb['mac'] = mac
+            backdb['bridge'] = bridge
+            if ipaddr:
+                backdb['ip'] = ' '.join(ipaddr)
             backdb['frontend'] = db.getPath()
             backdb['frontend-id'] = "%i" % self.id
             backdb['handle'] = "%i" % devnum
@@ -452,8 +475,7 @@
             db['backend'] = backdb.getPath()
             db['backend-id'] = "%i" % backdom.id
             db['handle'] = "%i" % devnum
-            log.error(sxp.child_value(devconfig, 'mac'))
-            db['mac'] = sxp.child_value(devconfig, 'mac')
+            db['mac'] = mac
 
             db.saveDB(save=True)
 

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.