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

[Xen-changelog] [xen-3.2-testing] xend: Move some backend configuration info.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1224177880 -3600
# Node ID cac3b6ed548856fe13bb120508a319dea565a696
# Parent  bde37dfe6963903e47d49161c77e173355e41eb4
xend: Move some backend configuration info.

This patch moves some dom0 variables and backend device
configuration from frontend directories to
/local/domain/<backdomid>/backend or /vm.

Also,
- /vm_path/<domid> is introduced, referencing the /vm path
- /vm_path/device/backend holds the backend device location,
  rather than storing it in the frontend directory

Signed-off-by: Pascal Bouchareine <pascal@xxxxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
xen-unstable changeset:   18562:616eea24aefa
xen-unstable date:        Wed Oct 01 13:35:39 2008 +0100

xend: Fixes after backend xenstore config changes.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
xen-unstable changeset:   18563:ab19284c5070
xen-unstable date:        Wed Oct 01 14:07:17 2008 +0100

xend: Make only selected subdirs of /local/domain/<domid> writable by
the guest.

This protects critical data like
/local/domain/<domid>/console/{tty,limit}. It also means we can trust
.../vm, and hence do not need /vm_path. Various parts of the previous
two changesets disappear.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
xen-unstable changeset:   18564:60937c4c5a67
xen-unstable date:        Thu Oct 02 10:37:28 2008 +0100

xend: Fix typo _gatherDom -> gatherDom.
Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxxxx>
xen-unstable changeset:   18579:1e37779bf884
xen-unstable date:        Thu Oct 09 10:06:50 2008 +0100

xend: Fix dev backend path construction.

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxxxx>
xen-unstable changeset:   18615:0c64c5fe261b
xen-unstable date:        Mon Oct 13 10:03:36 2008 +0100
---
 tools/python/xen/xend/XendDomainInfo.py       |   41 +++--------------
 tools/python/xen/xend/server/DevController.py |   61 +++++++++++++++++---------
 tools/python/xen/xend/server/netif.py         |   38 +---------------
 3 files changed, 52 insertions(+), 88 deletions(-)

diff -r bde37dfe6963 -r cac3b6ed5488 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Oct 16 18:17:18 2008 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Oct 16 18:24:40 2008 +0100
@@ -450,8 +450,8 @@ class XendDomainInfo:
             try:
                 self._constructDomain()
                 self._storeVmDetails()
+                self._createChannels()
                 self._createDevices()
-                self._createChannels()
                 self._storeDomDetails()
                 self._endRestore()
             except:
@@ -885,27 +885,6 @@ class XendDomainInfo:
     def storeVm(self, *args):
         return xstransact.Store(self.vmpath, *args)
 
-
-    def _readVmTxn(self, transaction,  *args):
-        paths = map(lambda x: self.vmpath + "/" + x, args)
-        return transaction.read(*paths)
-
-    def _writeVmTxn(self, transaction,  *args):
-        paths = map(lambda x: self.vmpath + "/" + x, args)
-        return transaction.write(*paths)
-
-    def _removeVmTxn(self, transaction,  *args):
-        paths = map(lambda x: self.vmpath + "/" + x, args)
-        return transaction.remove(*paths)
-
-    def _gatherVmTxn(self, transaction,  *args):
-        paths = map(lambda x: self.vmpath + "/" + x, args)
-        return transaction.gather(paths)
-
-    def storeVmTxn(self, transaction,  *args):
-        paths = map(lambda x: self.vmpath + "/" + x, args)
-        return transaction.store(*paths)
-
     #
     # Function to update xenstore /dom/*
     #
@@ -953,8 +932,11 @@ class XendDomainInfo:
     def _recreateDomFunc(self, t):
         t.remove()
         t.mkdir()
-        t.set_permissions({'dom' : self.domid})
+        t.set_permissions({'dom' : self.domid, 'read' : True})
         t.write('vm', self.vmpath)
+        for i in [ 'device', 'control', 'error' ]:
+            t.mkdir(i)
+            t.set_permissions(i, {'dom' : self.domid})
 
     def _storeDomDetails(self):
         to_store = {
@@ -1898,11 +1880,11 @@ class XendDomainInfo:
 
         paths = self._prepare_phantom_paths()
 
-        self._cleanupVm()
         if self.dompath is not None:
             self.destroyDomain()
 
         self._cleanup_phantom_devs(paths)
+        self._cleanupVm()
 
         if "transient" in self.info["other_config"] \
            and bool(self.info["other_config"]["transient"]):
@@ -2208,7 +2190,6 @@ class XendDomainInfo:
         self._writeVm(to_store)
         self._setVmPermissions()
 
-
     def _setVmPermissions(self):
         """Allow the guest domain to read its UUID.  We don't allow it to
         access any other entry, for security."""
@@ -2227,7 +2208,7 @@ class XendDomainInfo:
              log.warn("".join(traceback.format_stack()))
              return self._stateGet()
          else:
-             raise AttributeError()
+             raise AttributeError(name)
 
     def __setattr__(self, name, value):
         if name == "state":
@@ -2338,12 +2319,6 @@ class XendDomainInfo:
                                   ignore_devices = ignore_store,
                                   legacy_only = legacy_only)
 
-        #if not ignore_store and self.dompath:
-        #    vnc_port = self.readDom('console/vnc-port')
-        #    if vnc_port is not None:
-        #        result.append(['device',
-        #                       ['console', ['vnc-port', str(vnc_port)]]])
-
         return result
 
     # Xen API
@@ -2608,7 +2583,7 @@ class XendDomainInfo:
             if not config.has_key('device'):
                 devid = config.get('id')
                 if devid != None:
-                    config['device'] = 'eth%d' % devid
+                    config['device'] = 'eth%s' % devid
                 else:
                     config['device'] = ''
 
diff -r bde37dfe6963 -r cac3b6ed5488 
tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py     Thu Oct 16 18:17:18 
2008 +0100
+++ b/tools/python/xen/xend/server/DevController.py     Thu Oct 16 18:24:40 
2008 +0100
@@ -122,8 +122,11 @@ class DevController:
                     log.debug(
                       'DevController: still waiting to write device entries.')
 
+                devpath = self.devicePath(devid)
+
                 t.remove(frontpath)
                 t.remove(backpath)
+                t.remove(devpath)
 
                 t.mkdir(backpath)
                 t.set_permissions(backpath,
@@ -137,6 +140,14 @@ class DevController:
 
                 t.write2(frontpath, front)
                 t.write2(backpath,  back)
+
+                t.mkdir(devpath)
+                t.write2(devpath, {
+                    'backend' : backpath,
+                    'backend-id' : "%i" % backdom,
+                    'frontend' : frontpath,
+                    'frontend-id' : "%i" % self.vm.getDomid()
+                })
 
                 if t.commit():
                     return devid
@@ -233,11 +244,12 @@ class DevController:
 
         if force:
             frontpath = self.frontendPath(dev)
-            backpath = xstransact.Read(frontpath, "backend")
+            backpath = self.readVm(dev, "backend")
             if backpath:
                 xstransact.Remove(backpath)
             xstransact.Remove(frontpath)
 
+        # xstransact.Remove(self.devicePath()) ?? Below is the same ?
         self.vm._removeVm("device/%s/%d" % (self.deviceClass, dev))
 
     def configurations(self, transaction = None):
@@ -281,9 +293,10 @@ class DevController:
         @return: dict
         """
         if transaction is None:
-            backdomid = xstransact.Read(self.frontendPath(devid), "backend-id")
-        else:
-            backdomid = transaction.read(self.frontendPath(devid) + 
"/backend-id")
+            backdomid = xstransact.Read(self.devicePath(devid), "backend-id")
+        else:
+            backdomid = transaction.read(self.devicePath(devid) + 
"/backend-id")
+
         if backdomid is None:
             raise VmError("Device %s not connected" % devid)
 
@@ -412,17 +425,22 @@ class DevController:
         return result
 
 
+    def readVm(self, devid, *args):
+        devpath = self.devicePath(devid)
+        if devpath:
+            return xstransact.Read(devpath, *args)
+        else:
+            raise VmError("Device config %s not found" % devid)
+
     def readBackend(self, devid, *args):
-        frontpath = self.frontendPath(devid)
-        backpath = xstransact.Read(frontpath, "backend")
+        backpath = self.readVm(devid, "backend")
         if backpath:
             return xstransact.Read(backpath, *args)
         else:
             raise VmError("Device %s not connected" % devid)
 
     def readBackendTxn(self, transaction, devid, *args):
-        frontpath = self.frontendPath(devid)
-        backpath = transaction.read(frontpath + "/backend")
+        backpath = self.readVm(devid, "backend")
         if backpath:
             paths = map(lambda x: backpath + "/" + x, args)
             return transaction.read(*paths)
@@ -440,7 +458,7 @@ class DevController:
         """@return The IDs of each of the devices currently configured for
         this instance's deviceClass.
         """
-        fe = self.backendRoot()
+        fe = self.deviceRoot()
 
         if transaction:
             return map(lambda x: int(x.split('/')[-1]), transaction.list(fe))
@@ -449,8 +467,7 @@ class DevController:
 
 
     def writeBackend(self, devid, *args):
-        frontpath = self.frontendPath(devid)
-        backpath = xstransact.Read(frontpath, "backend")
+        backpath = self.readVm(devid, "backend")
 
         if backpath:
             xstransact.Write(backpath, *args)
@@ -515,9 +532,8 @@ class DevController:
 
 
     def waitForBackend(self, devid):
-
         frontpath = self.frontendPath(devid)
-        # lookup a phantom 
+        # lookup a phantom
         phantomPath = xstransact.Read(frontpath, 'phantom_vbd')
         if phantomPath is not None:
             log.debug("Waiting for %s's phantom %s.", devid, phantomPath)
@@ -530,7 +546,7 @@ class DevController:
             if result['status'] != 'Connected':
                 return (result['status'], err)
             
-        backpath = xstransact.Read(frontpath, "backend")
+        backpath = self.readVm(devid, "backend")
 
 
         if backpath:
@@ -579,17 +595,20 @@ class DevController:
     def frontendRoot(self):
         return "%s/device/%s" % (self.vm.getDomainPath(), self.deviceClass)
 
-    def backendRoot(self):
-        """Construct backend root path assuming backend is domain 0."""
-        from xen.xend.XendDomain import DOM0_ID
-        from xen.xend.xenstore.xsutil import GetDomainPath
-        return "%s/backend/%s/%s" % (GetDomainPath(DOM0_ID),
-                                     self.deviceClass, self.vm.getDomid())
-
     def frontendMiscPath(self):
         return "%s/device-misc/%s" % (self.vm.getDomainPath(),
                                       self.deviceClass)
 
+    def deviceRoot(self):
+        """Return the /vm/device. Because backendRoot assumes the
+        backend domain is 0"""
+        return "%s/device/%s" % (self.vm.vmpath, self.deviceClass)
+
+    def devicePath(self, devid):
+        """Return the /device entry of the given VM. We use it to store
+        backend/frontend locations"""
+        return "%s/device/%s/%s" % (self.vm.vmpath,
+                                    self.deviceClass, devid)
 
 def hotplugStatusCallback(statusPath, ev, result):
     log.debug("hotplugStatusCallback %s.", statusPath)
diff -r bde37dfe6963 -r cac3b6ed5488 tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py     Thu Oct 16 18:17:18 2008 +0100
+++ b/tools/python/xen/xend/server/netif.py     Thu Oct 16 18:24:40 2008 +0100
@@ -141,10 +141,6 @@ class NetifController(DevController):
         if sec_lab:
             back['security_label'] = sec_lab
 
-        config_path = "device/%s/%d/" % (self.deviceClass, devid)
-        for x in back:
-            self.vm._writeVm(config_path + x, back[x])
-
         back['handle'] = "%i" % devid
         back['script'] = os.path.join(xoptions.network_script_dir, script)
         if rate:
@@ -188,40 +184,14 @@ class NetifController(DevController):
 
         result = DevController.getDeviceConfiguration(self, devid, transaction)
 
-        config_path = "device/%s/%d/" % (self.deviceClass, devid)
-        devinfo = ()
         for x in ( 'script', 'ip', 'bridge', 'mac',
                    'type', 'vifname', 'rate', 'uuid', 'model', 'accel',
                    'security_label'):
             if transaction is None:
-                y = self.vm._readVm(config_path + x)
+                y = self.readBackend(devid, x)
             else:
-                y = self.vm._readVmTxn(transaction, config_path + x)
-            devinfo += (y,)
-        (script, ip, bridge, mac, typ, vifname, rate, uuid,
-         model, accel, security_label) = devinfo
-
-        if script:
-            result['script'] = script
-        if ip:
-            result['ip'] = ip
-        if bridge:
-            result['bridge'] = bridge
-        if mac:
-            result['mac'] = mac
-        if typ:
-            result['type'] = typ
-        if vifname:
-            result['vifname'] = vifname
-        if rate:
-            result['rate'] = rate
-        if uuid:
-            result['uuid'] = uuid
-        if model:
-            result['model'] = model
-        if accel:
-            result['accel'] = accel
-        if security_label:
-            result['security_label'] = security_label
+                y = self.readBackendTxn(transaction, devid, x)
+            if y:
+                result[x] = y
 
         return result

_______________________________________________
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®.