Skip to contentSkip to conversation

Allow domains to be created as managed domains

PATCH Applied Stefan Berger 2 participants 2 messages Dec 29, 2006 – Jan 9, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow domains to be created as managed domains

This simple patch allows domains created in the xm-test suite to be created as managed domains using either a parameter to the XenTestDomain() constructor or by setting the environment variable XM_MANAGED_DOMAINS and running the tests with it.

All managed domains created within a test are tracked and destroyed at the end using an 'atexit' handler (which I want to also use for domains built with the raw xen-api).

This patch in combination with the configuration file for xm should give some coverage for the Xen-API usage of xm.

The following errors are shown now in the xm-test suite beyond those that are 'expected' at the moment. They are all related to 'xm domid' being called on a managed domain.

FAIL: 01_restore_basic_pos.test
FAIL: 01_save_basic_pos.test
FAIL: 01_shutdown_basic_pos.test

I would have a look at these later.

xen-unstable.hg/tools/xm-test/lib/XmTestLib/XenDomain.py +24 -4
Index: root/xen-unstable.hg/tools/xm-test/lib/XmTestLib/XenDomain.py
===================================================================
@@ -29,6 +29,7 @@ from Test import *
 from config import *
 from Console import *
 from XenDevice import *
+from DomainTracking import *
 from acm import *
 
 
@@ -147,7 +148,7 @@ class DomainError(Exception):
 
 class XenDomain:
 
-    def __init__(self, name=None, config=None):
+    def __init__(self, name=None, config=None, isManaged=False):
         """Create a domain object.
         @param config: String filename of config file
         """
@@ -162,6 +163,10 @@ class XenDomain:
         self.devices = {}
         self.netEnv = "bridge"
 
+        if os.getenv("XM_MANAGED_DOMAINS"):
+            isManaged = True
+        self.isManaged = isManaged
+
         # Set domain type, either PV for ParaVirt domU or HVM for
         # FullVirt domain
         if ENABLE_HVM_SUPPORT:
@@ -171,7 +176,17 @@ class XenDomain:
 
     def start(self, noConsole=False):
 
-        ret, output = traceCommand("xm create %s" % self.config)
+        if not self.isManaged:
+            ret, output = traceCommand("xm create %s" % self.config)
+        else:
+            ret, output = traceCommand("xm new %s" % self.config)
+            if ret != 0:
+                _ret, output = traceCommand("xm delete " +
+                                            self.config.getOpt("name"))
+            else:
+                ret, output = traceCommand("xm start " +
+                                           self.config.getOpt("name"))
+                addManagedDomain(self.config.getOpt("name"))
 
         if ret != 0:
             raise DomainError("Failed to create domain",
@@ -218,6 +233,10 @@ class XenDomain:
             self.closeConsole()
 
         ret, output = traceCommand(prog + cmd + self.config.getOpt("name"))
+        if self.isManaged:
+            ret, output = traceCommand(prog + " delete " +
+                                       self.config.getOpt("name"))
+            delManagedDomain(self.config.getOpt("name"))
 
         return ret
 
@@ -296,7 +315,7 @@ class XenDomain:
 class XmTestDomain(XenDomain):
 
     def __init__(self, name=None, extraConfig=None,
-                 baseConfig=arch.configDefaults):
+                 baseConfig=arch.configDefaults, isManaged=False):
         """Create a new xm-test domain
         @param name: The requested domain name
         @param extraConfig: Additional configuration options
@@ -312,7 +331,8 @@ class XmTestDomain(XenDomain):
         elif not config.getOpt("name"):
             config.setOpt("name", getUniqueName())
 
-        XenDomain.__init__(self, config.getOpt("name"), config=config)
+        XenDomain.__init__(self, config.getOpt("name"), config=config,
+                           isManaged=isManaged)
 
     def minSafeMem(self):
         return arch.minSafeMem
xen-unstable.hg/tools/xm-test/lib/XmTestLib/DomainTracking.py new file +43 -0

43 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Applied
#1 lore raw
Quoted 16 lines · Stefan Berger

This simple patch allows domains created in the xm-test suite to be created as managed domains using either a parameter to the XenTestDomain() constructor or by setting the environment variable XM_MANAGED_DOMAINS and running the tests with it.

All managed domains created within a test are tracked and destroyed at the end using an 'atexit' handler (which I want to also use for domains built with the raw xen-api).

This patch in combination with the configuration file for xm should give some coverage for the Xen-API usage of xm.

The following errors are shown now in the xm-test suite beyond those that are 'expected' at the moment. They are all related to 'xm domid' being called on a managed domain.

Quoted 7 lines

FAIL: 01_restore_basic_pos.test
FAIL: 01_save_basic_pos.test
FAIL: 01_shutdown_basic_pos.test

I would have a look at these later.

Applied, thanks.

Ewan.