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] [xen-unstable] Add a function for creating a domain from

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Add a function for creating a domain from an existing XendConfig, and use that
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Dec 2006 13:35:08 -0800
Delivery-date: Thu, 21 Dec 2006 13:35:42 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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 Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1166722772 0
# Node ID 63bd462b1f457354459c6865a0d1659b53904e95
# Parent  2ae2204bbef30d05d62ea33a8febc3a25139659b
Add a function for creating a domain from an existing XendConfig, and use that
on reboot, rather than writing out sxp and reparsing.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendDomain.py     |   20 ++++++++++++++++++
 tools/python/xen/xend/XendDomainInfo.py |   34 +++++++++++++++++++++++---------
 2 files changed, 45 insertions(+), 9 deletions(-)

diff -r 2ae2204bbef3 -r 63bd462b1f45 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Thu Dec 21 17:38:02 2006 +0000
+++ b/tools/python/xen/xend/XendDomain.py       Thu Dec 21 17:39:32 2006 +0000
@@ -869,6 +869,26 @@ class XendDomain:
             self.domains_lock.release()
 
 
+    def domain_create_from_dict(self, config_dict):
+        """Create a domain from a configuration dictionary.
+
+        @param config_dict: configuration
+        @rtype: XendDomainInfo
+        """
+        self.domains_lock.acquire()
+        try:
+            self._refresh()
+
+            dominfo = XendDomainInfo.create_from_dict(config_dict)
+            self._add_domain(dominfo)
+            self.domain_sched_credit_set(dominfo.getDomid(),
+                                         dominfo.getWeight(),
+                                         dominfo.getCap())
+            return dominfo
+        finally:
+            self.domains_lock.release()
+
+
     def domain_new(self, config):
         """Create a domain from a configuration but do not start it.
         
diff -r 2ae2204bbef3 -r 63bd462b1f45 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Dec 21 17:38:02 2006 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Dec 21 17:39:32 2006 +0000
@@ -81,18 +81,39 @@ log = logging.getLogger("xend.XendDomain
 
 def create(config):
     """Creates and start a VM using the supplied configuration. 
-    (called from XMLRPCServer directly)
 
     @param config: A configuration object involving lists of tuples.
     @type  config: list of lists, eg ['vm', ['image', 'xen.gz']]
 
     @rtype:  XendDomainInfo
-    @return: A up and running XendDomainInfo instance
+    @return: An up and running XendDomainInfo instance
     @raise VmError: Invalid configuration or failure to start.
     """
 
     log.debug("XendDomainInfo.create(%s)", scrub_password(config))
     vm = XendDomainInfo(XendConfig.XendConfig(sxp_obj = config))
+    try:
+        vm.start()
+    except:
+        log.exception('Domain construction failed')
+        vm.destroy()
+        raise
+
+    return vm
+
+def create_from_dict(config_dict):
+    """Creates and start a VM using the supplied configuration. 
+
+    @param config_dict: An configuration dictionary.
+
+    @rtype:  XendDomainInfo
+    @return: An up and running XendDomainInfo instance
+    @raise VmError: Invalid configuration or failure to start.
+    """
+
+    log.debug("XendDomainInfo.create_from_dict(%s)",
+              scrub_password(config_dict))
+    vm = XendDomainInfo(XendConfig.XendConfig(xapi = config_dict))
     try:
         vm.start()
     except:
@@ -1051,12 +1072,6 @@ class XendDomainInfo:
         """
         from xen.xend import XendDomain
         
-        config = self.sxpr()
-
-        if self._infoIsSet('cpus') and len(self.info['cpus']) != 0:
-            config.append(['cpus', reduce(lambda x, y: str(x) + "," + str(y),
-                                          self.info['cpus'])])
-
         if self._readVm(RESTART_IN_PROGRESS):
             log.error('Xend failed during restart of domain %s.  '
                       'Refusing to restart to avoid loops.',
@@ -1097,7 +1112,8 @@ class XendDomainInfo:
 
             new_dom = None
             try:
-                new_dom = XendDomain.instance().domain_create(config)
+                new_dom = XendDomain.instance().domain_create_from_dict(
+                    self.info)
                 new_dom.unpause()
                 rst_cnt = self._readVm('xend/restart_count')
                 rst_cnt = int(rst_cnt) + 1

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Add a function for creating a domain from an existing XendConfig, and use that, Xen patchbot-unstable <=