aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-01-09 17:25:28 +0000
committerEwan Mellor <ewan@xensource.com>2007-01-09 17:25:28 +0000
commit00e52488131f7190f005c65a64169752a5b9b9a8 (patch)
tree2407a9fa2e4d5667fc841b09e54c566a63654716 /tools/xm-test
parente4658203b4ce1947e81e606d72ac9b1cfd2109fc (diff)
downloadxen-00e52488131f7190f005c65a64169752a5b9b9a8.tar.gz
xen-00e52488131f7190f005c65a64169752a5b9b9a8.tar.bz2
xen-00e52488131f7190f005c65a64169752a5b9b9a8.zip
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. Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
Diffstat (limited to 'tools/xm-test')
-rw-r--r--tools/xm-test/lib/XmTestLib/DomainTracking.py43
-rw-r--r--tools/xm-test/lib/XmTestLib/XenDomain.py28
2 files changed, 67 insertions, 4 deletions
diff --git a/tools/xm-test/lib/XmTestLib/DomainTracking.py b/tools/xm-test/lib/XmTestLib/DomainTracking.py
new file mode 100644
index 0000000000..cbd25146f5
--- /dev/null
+++ b/tools/xm-test/lib/XmTestLib/DomainTracking.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+"""
+ Copyright (C) International Business Machines Corp., 2005
+ Author: Dan Smith <danms@us.ibm.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; under version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""
+
+import atexit
+import Test
+
+# Tracking of managed domains
+_managedDomains = []
+registered = 0
+
+def addManagedDomain(name):
+ global registered
+ _managedDomains.append(name)
+ if not registered:
+ atexit.register(destroyManagedDomains)
+ registered = 1
+
+def delManagedDomain(name):
+ if name in _managedDomains:
+ del _managedDomains[_managedDomains.index(name)]
+
+def destroyManagedDomains():
+ if len(_managedDomains) > 0:
+ for m in _managedDomains:
+ Test.traceCommand("xm destroy %s" % m)
+ Test.traceCommand("xm delete %s" % m)
diff --git a/tools/xm-test/lib/XmTestLib/XenDomain.py b/tools/xm-test/lib/XmTestLib/XenDomain.py
index 40aaebf9b4..3fcfcea4f1 100644
--- a/tools/xm-test/lib/XmTestLib/XenDomain.py
+++ b/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