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

[Xen-changelog] Added DevController.configuration and configurations met

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Added DevController.configuration and configurations methods. These parse the
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 30 Sep 2005 10:02:10 +0000
Delivery-date: Fri, 30 Sep 2005 09:59:43 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User emellor@ewan
# Node ID 82e8a1d7230fbbbd3128880e0914aef11658a432
# Parent  b9e5573785bb3ceca1f72fcc8a6e9704677cd926
Added DevController.configuration and configurations methods.  These parse the
store for the current device configuration, and convert it back into the
s-expression used in the config files and the save files.  This means that we
can bring the devices up properly on restore.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r b9e5573785bb -r 82e8a1d7230f 
tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py     Thu Sep 29 15:57:23 2005
+++ b/tools/python/xen/xend/server/DevController.py     Fri Sep 30 09:48:49 2005
@@ -75,10 +75,26 @@
         """
 
         frontpath = self.frontendPath(devid)
-        backpath = xstransact.Read("%s/backend" % frontpath)
+        backpath = xstransact.Read(frontpath, "backend")
 
         xstransact.Remove(frontpath)
         xstransact.Remove(backpath)
+
+
+    def configurations(self):
+        return map(lambda x: self.configuration(int(x)),
+                   xstransact.List(self.frontendRoot()))
+
+
+    def configuration(self, devid):
+        """@return an s-expression giving the current configuration of the
+        specified device.  This would be suitable for giving to {@link
+        #createDevice} in order to recreate that device."""
+
+        backdomid = int(xstransact.Read(self.frontendPath(devid),
+                                        "backend-id"))
+
+        return [self.deviceClass, ['backend', backdomid]]
 
 
     def sxprs(self):
@@ -150,6 +166,12 @@
                 raise
 
 
+    def readBackend(self, devid, *args):
+        frontpath = self.frontendPath(devid)
+        backpath = xstransact.Read(frontpath, "backend")
+        return xstransact.Read(backpath, *args)
+
+
     ## private:
 
     def writeDetails(self, config, devid, backDetails, frontDetails):
@@ -211,4 +233,5 @@
 
 
     def frontendMiscPath(self):
-        return "%s/device-misc/%s" % (self.vm.getPath(), self.deviceClass)
+        return "%s/device-misc/%s" % (self.vm.getPath(),
+                                      self.deviceClass)
diff -r b9e5573785bb -r 82e8a1d7230f tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py     Thu Sep 29 15:57:23 2005
+++ b/tools/python/xen/xend/server/blkif.py     Fri Sep 30 09:48:49 2005
@@ -40,14 +40,15 @@
     def getDeviceDetails(self, config):
         """@see DevController.getDeviceDetails"""
         
-        typedev = sxp.child_value(config, 'dev')
-        if re.match('^ioemu:', typedev):
+        dev = sxp.child_value(config, 'dev')
+        if re.match('^ioemu:', dev):
             return (0,{},{})
 
-        devid = blkif.blkdev_name_to_number(sxp.child_value(config, 'dev'))
+        devid = blkif.blkdev_name_to_number(dev)
 
         (typ, params) = string.split(sxp.child_value(config, 'uname'), ':', 1)
-        back = { 'type' : typ,
+        back = { 'dev' : dev,
+                 'type' : typ,
                  'params' : params
                  }
 
@@ -57,3 +58,22 @@
         front = { 'virtual-device' : "%i" % devid }
 
         return (devid, back, front)
+
+
+    def configuration(self, devid):
+        """@see DevController.configuration"""
+
+        result = DevController.configuration(self, devid)
+
+        (dev, typ, params, ro) = self.readBackend(devid,
+                                                  'dev', 'type', 'params',
+                                                  'read-only')
+
+        result.append(['dev', dev])
+        result.append(['uname', typ + ":" + params])
+        if ro:
+            result.append(['mode', 'r'])
+        else:
+            result.append(['mode', 'w'])
+
+        return result
diff -r b9e5573785bb -r 82e8a1d7230f tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py     Thu Sep 29 15:57:23 2005
+++ b/tools/python/xen/xend/server/netif.py     Fri Sep 30 09:48:49 2005
@@ -23,8 +23,12 @@
 import os
 
 from xen.xend import sxp
+from xen.xend import XendRoot
 
 from xen.xend.server.DevController import DevController
+
+
+xroot = XendRoot.instance()
 
 
 class NetifController(DevController):
@@ -37,9 +41,6 @@
 
     def getDeviceDetails(self, config):
         """@see DevController.getDeviceDetails"""
-
-        from xen.xend import XendRoot
-        xroot = XendRoot.instance()
 
         def _get_config_ipaddr(config):
             val = []
@@ -68,3 +69,22 @@
                   'mac' : mac }
 
         return (devid, back, front)
+
+
+    def configuration(self, devid):
+        """@see DevController.configuration"""
+
+        result = DevController.configuration(self, devid)
+
+        (script, ip, bridge, mac) = self.readBackend(devid,
+                                                     'script', 'ip', 'bridge',
+                                                     'mac')
+
+        result.append(['script',
+                       script.replace(xroot.network_script_dir + os.sep, "")])
+        if ip:
+            result.append(['ip', ip.split(" ")])
+        result.append(['bridge', bridge])
+        result.append(['mac', mac])
+
+        return result

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Added DevController.configuration and configurations methods. These parse the, Xen patchbot -unstable <=