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

Re: [Xen-devel] [PATCH] [XEND] tweak XendDomainInfo to allow architectur

To: Alastair Tse <atse@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] [XEND] tweak XendDomainInfo to allow architectures to subclass
From: Hollis Blanchard <hollisb@xxxxxxxxxx>
Date: Mon, 25 Sep 2006 08:53:42 -0500
Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Mon, 25 Sep 2006 06:54:02 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <24601FF9-3590-40F9-9F80-26383BD981F1@xxxxxxxxxxxxx>
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>
Organization: IBM Linux Technology Center
References: <b46d3d47063ac5134384.1158780224@xxxxxxxxxxxxxxxxxxxxx> <1158955352.4586.18.camel@xxxxxxxxxxxxxxxxxxxxx> <24601FF9-3590-40F9-9F80-26383BD981F1@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Sat, 2006-09-23 at 10:29 +0100, Alastair Tse wrote:
> The patch looks OK and the impact is pretty low since the impact is  
> only contained within XendDomainInfo.py. domainTypes should probably  
> be renamed to _domainTypes just to make it explicit it is not to be  
> accessed outside of this module. Also, type is a built-in python  
> function, better to rename that to something else, just in case.

Sounds good; here is the update.

[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 3499b3271e5f tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Fri Sep 22 17:46:32 2006 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Mon Sep 25 08:52:14 2006 -0500
@@ -189,7 +189,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 +239,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 +264,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()
@@ -1339,8 +1339,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()
 
@@ -1361,6 +1360,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:
@@ -1771,6 +1773,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():
+    archname = arch.type
+    try:
+        return _domainTypes[archname]
+    except KeyError:
+        raise VmError("Unsupported architecture: " + archname)
 
 #============================================================================
 # Register device controllers and their device config types.


-- 
Hollis Blanchard
IBM Linux Technology Center


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

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