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] [XEND] tweak XendDomainInfo to allow architectures t

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] [XEND] tweak XendDomainInfo to allow architectures to subclass
From: Hollis Blanchard <hollisb@xxxxxxxxxx>
Date: Wed, 20 Sep 2006 14:23:44 -0500
Delivery-date: Wed, 20 Sep 2006 12:24:19 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Hollis Blanchard <hollisb@xxxxxxxxxx>
# Date 1158780212 18000
# Node ID b46d3d47063ac51343847ec22321276b72a5e591
# Parent  f7d90f962967a5a94fce0c04f8fcac449f36344f
[XEND] tweak XendDomainInfo to allow architectures to subclass.
- create findDomainClass(), analogous to findImageHandlerClass() in image.py.
- move initial memory allocation into an allocMem() method (for subclasses to
  override).

Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>

diff -r f7d90f962967 -r b46d3d47063a tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Wed Sep 20 14:20:52 2006 -0500
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Sep 20 14:23:32 2006 -0500
@@ -35,6 +35,7 @@ from xen.util import asserts
 from xen.util import asserts
 from xen.util.blkif import blkdev_uname_to_file
 from xen.util import security
+import arch
 import balloon
 import image
 import sxp
@@ -189,7 +190,7 @@ def create(config):
 
     log.debug("XendDomainInfo.create(%s)", config)
 
-    vm = XendDomainInfo(parseConfig(config))
+    vm = findDomainClass()(parseConfig(config))
     try:
         vm.construct()
         vm.initDomain()
@@ -239,13 +240,13 @@ def recreate(xeninfo, priv):
                 'Uuid in store does not match uuid for existing domain %d: '
                 '%s != %s' % (domid, uuid2_str, xeninfo['uuid']))
 
-        vm = XendDomainInfo(xeninfo, domid, dompath, True, priv)
+        vm = findDomainClass()(xeninfo, domid, dompath, True, priv)
 
     except Exception, exn:
         if priv:
             log.warn(str(exn))
 
-        vm = XendDomainInfo(xeninfo, domid, dompath, True, priv)
+        vm = findDomainClass()(xeninfo, domid, dompath, True, priv)
         vm.recreateDom()
         vm.removeVm()
         vm.storeVmDetails()
@@ -264,7 +265,7 @@ def restore(config):
 
     log.debug("XendDomainInfo.restore(%s)", config)
 
-    vm = XendDomainInfo(parseConfig(config), None, None, False, False, True)
+    vm = findDomainClass()(parseConfig(config), None, None, False, False, True)
     try:
         vm.construct()
         vm.storeVmDetails()
@@ -1329,8 +1330,7 @@ class XendDomainInfo:
             self.info['shadow_memory'] = shadow_cur
 
             # initial memory reservation
-            xc.domain_memory_increase_reservation(self.domid, reservation, 0,
-                                                  0)
+            self.allocMem(reservation)
 
             self.createChannels()
 
@@ -1351,6 +1351,9 @@ class XendDomainInfo:
 
         except RuntimeError, exn:
             raise VmError(str(exn))
+
+    def allocMem(self, reservation):
+        xc.domain_memory_increase_reservation(self.domid, reservation, 0, 0)
 
 
     ## public:
@@ -1761,6 +1764,17 @@ class XendDomainInfo:
     def infoIsSet(self, name):
         return name in self.info and self.info[name] is not None
 
+domainTypes = {
+    "ia64": XendDomainInfo,
+    "x86": XendDomainInfo,
+}
+
+def findDomainClass():
+    type = arch.type
+    try:
+        return domainTypes[type]
+    except KeyError:
+        raise VmError("Unsupported architecture: " + type)
 
 #============================================================================
 # Register device controllers and their device config types.

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

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