ia64/xen-unstable

changeset 8343:1dc393b65019

Change the way domain configuration is handled in xm-test.
This will simplify the way we differentiate between HV and PV domains,
as well as make it easier to run normal tests in either HV or PV mode.

This patch has been modified by Ewan Mellor, to match his recent changes to
remove the nics= configuration option.

Signed-off-by: Dan Smith <danms@us.ibm.com>
Signed-off-by: Dan Stekloff <dsteklof@us.ibm.com>
author emellor@leeni.uk.xensource.com
date Tue Dec 13 16:26:24 2005 +0000 (2005-12-13)
parents ef2fff896422
children 116b7c0a8534
files tools/xm-test/lib/XmTestLib/XenDomain.py tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py tools/xm-test/tests/block-create/12_block_attach_shared_domU.py tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py tools/xm-test/tests/block-list/01_block-list_pos.py tools/xm-test/tests/block-list/03_block-list_anotherbd_pos.py tools/xm-test/tests/create/01_create_basic_pos.py tools/xm-test/tests/create/06_create_mem_neg.py tools/xm-test/tests/create/07_create_mem64_pos.py tools/xm-test/tests/create/08_create_mem128_pos.py tools/xm-test/tests/create/09_create_mem256_pos.py tools/xm-test/tests/create/11_create_concurrent_pos.py tools/xm-test/tests/create/12_create_concurrent_stress_pos.py tools/xm-test/tests/create/13_create_multinic_pos.py tools/xm-test/tests/create/14_create_blockroot_pos.py tools/xm-test/tests/create/15_create_smallmem_pos.py tools/xm-test/tests/memset/03_memset_random_pos.py tools/xm-test/tests/network/02_network_local_ping_pos.py tools/xm-test/tests/network/05_network_dom0_ping_pos.py tools/xm-test/tests/network/11_network_domU_ping_pos.py tools/xm-test/tests/restore/04_restore_withdevices_pos.py tools/xm-test/tests/sedf/01_sedf_multi_pos.py tools/xm-test/tests/vcpu-disable/01_vcpu-disable_basic_pos.py
line diff
     1.1 --- a/tools/xm-test/lib/XmTestLib/XenDomain.py	Tue Dec 13 10:57:18 2005 +0000
     1.2 +++ b/tools/xm-test/lib/XmTestLib/XenDomain.py	Tue Dec 13 16:26:24 2005 +0000
     1.3 @@ -30,18 +30,140 @@ from config import *
     1.4  
     1.5  BLOCK_ROOT_DEV = "hda"
     1.6  
     1.7 -def XmTestDomain(name=None, extraOpts=None, config="/dev/null"):
     1.8 -    if ENABLE_VMX_SUPPORT:
     1.9 -        return XmTestVmxDomain(name, extraOpts, config)
    1.10 +def getDeviceModel():
    1.11 +    """Get the path to the device model based on
    1.12 +    the architecture reported in uname"""
    1.13 +    arch = os.uname()[4]
    1.14 +    if re.search("64", arch):
    1.15 +        return "/usr/lib64/xen/bin/qemu-dm"
    1.16      else:
    1.17 -        return XmTestPvDomain(name, extraOpts, config)
    1.18 +        return "/usr/lib/xen/bin/qemu-dm"
    1.19  
    1.20  def getDefaultKernel():
    1.21 +    """Get the path to the default DomU kernel"""
    1.22      dom0Ver = commands.getoutput("uname -r");
    1.23      domUVer = dom0Ver.replace("xen0", "xenU");
    1.24      
    1.25      return "/boot/vmlinuz-" + domUVer;
    1.26  
    1.27 +def getUniqueName():
    1.28 +    """Get a uniqueish name for use in a domain"""
    1.29 +    unixtime = int(time.time())
    1.30 +    test_name = sys.argv[0]
    1.31 +    test_name = re.sub("\.test", "", test_name)
    1.32 +    test_name = re.sub("[\/\.]", "", test_name)
    1.33 +    name = "%s-%i" % (test_name, unixtime)
    1.34 +    
    1.35 +    return name
    1.36 +
    1.37 +def getRdPath():
    1.38 +    rdpath = os.environ.get("RD_PATH")
    1.39 +    if not rdpath:
    1.40 +        rdpath = "../../ramdisk"
    1.41 +    rdpath = os.path.abspath(rdpath)
    1.42 +
    1.43 +    return rdpath
    1.44 +
    1.45 +ParavirtDefaults = {"memory"       : 64,
    1.46 +                    "vcpus"        : 1,
    1.47 +                    "kernel"       : getDefaultKernel(),
    1.48 +                    "root"         : "/dev/ram0",
    1.49 +                    "ramdisk"      : getRdPath() + "/initrd.img"
    1.50 +                    }
    1.51 +VmxDefaults =      {"memory"       : 64,
    1.52 +                    "vcpus"        : 1,
    1.53 +                    "nics"         : 0,
    1.54 +                    "disk"         : ["file:%s/disk.img,ioemu:%s,w" %
    1.55 +                                   (getRdPath(), BLOCK_ROOT_DEV)],
    1.56 +                    "kernel"       : "/usr/lib/xen/boot/vmxloader",
    1.57 +                    "builder"      : "vmx",
    1.58 +                    "sdl"          : 0,
    1.59 +                    "vnc"          : 0,
    1.60 +                    "vncviewer"    : 0,
    1.61 +                    "nographic"    : 1,
    1.62 +                    "serial"       : "pty",
    1.63 +                    "device_model" : getDeviceModel()
    1.64 +                    }
    1.65 +
    1.66 +if ENABLE_VMX_SUPPORT:
    1.67 +    configDefaults = VmxDefaults
    1.68 +else:
    1.69 +    configDefaults = ParavirtDefaults
    1.70 +
    1.71 +class XenConfig:
    1.72 +    """An object to help create a xen-compliant config file"""
    1.73 +    def __init__(self):
    1.74 +        self.defaultOpts = {}
    1.75 +
    1.76 +        # These options need to be lists
    1.77 +        self.defaultOpts["disk"] = []
    1.78 +        self.defaultOpts["vif"]  = []
    1.79 +
    1.80 +        self.opts = self.defaultOpts
    1.81 +
    1.82 +    def toString(self):
    1.83 +        """Convert this config to a string for writing out
    1.84 +        to a file"""
    1.85 +        string = "# Xen configuration generated by xm-test\n"
    1.86 +        for k, v in self.opts.items():
    1.87 +            if isinstance(v, int):
    1.88 +                piece = "%s = %i" % (k, v)
    1.89 +            elif isinstance(v, list) and v:
    1.90 +                piece = "%s = %s" % (k, v)
    1.91 +            elif isinstance(v, str) and v:
    1.92 +                piece = "%s = \"%s\"" % (k, v)
    1.93 +            else:
    1.94 +                piece = None
    1.95 +
    1.96 +            if piece:
    1.97 +                string += "%s\n" % piece
    1.98 +
    1.99 +        return string
   1.100 +
   1.101 +    def write(self, filename):
   1.102 +        """Write this config out to filename"""
   1.103 +        output = file(filename, "w")
   1.104 +        output.write(self.toString())
   1.105 +        output.close()
   1.106 +
   1.107 +    def __str__(self):
   1.108 +        """When used as a string, we represent ourself by a config
   1.109 +        filename, which points to a temporary config that we write
   1.110 +        out ahead of time"""
   1.111 +        filename = "/tmp/xm-test.conf"
   1.112 +        self.write(filename)
   1.113 +        return filename
   1.114 +
   1.115 +    def setOpt(self, name, value):
   1.116 +        """Set an option in the config"""
   1.117 +        if name in self.opts.keys() and isinstance(self.opts[name], list) and not isinstance(value, list):
   1.118 +                self.opts[name] = [value]
   1.119 +        else:
   1.120 +            self.opts[name] = value
   1.121 +
   1.122 +    def appOpt(self, name, value):
   1.123 +        """Append a value to a list option"""
   1.124 +        if name in self.opts.keys() and isinstance(self.opts[name], list):
   1.125 +            self.opts[name].append(value)
   1.126 +
   1.127 +    def getOpt(self, name):
   1.128 +        """Return the value of a config option"""
   1.129 +        if name in self.opts.keys():
   1.130 +            return self.opts[name]
   1.131 +        else:
   1.132 +            return None
   1.133 +
   1.134 +    def setOpts(self, opts):
   1.135 +        """Batch-set options from a dictionary"""
   1.136 +        for k, v in opts.items():
   1.137 +            self.setOpt(k, v)
   1.138 +
   1.139 +    def clearOpts(self, name=None):
   1.140 +        """Clear one or all config options"""
   1.141 +        if name:
   1.142 +            self.opts[name] = self.defaultOpts[name]
   1.143 +        else:
   1.144 +            self.opts = self.defaultOpts
   1.145  
   1.146  class DomainError(Exception):
   1.147      def __init__(self, msg, extra="", errorcode=0):
   1.148 @@ -55,62 +177,24 @@ class DomainError(Exception):
   1.149      def __str__(self):
   1.150          return str(self.msg)
   1.151  
   1.152 +
   1.153  class XenDomain:
   1.154  
   1.155 -    def __init__(self, opts={}, config="/dev/null"):
   1.156 -        """Create a domain object.  Optionally take a 
   1.157 -        dictionary of 'xm' options to use"""
   1.158 -
   1.159 -        self.domID = None;
   1.160 -        self.config = config
   1.161 -
   1.162 -        if not opts.has_key("name"):
   1.163 -            raise DomainError("Missing `name' option")
   1.164 -        if not opts.has_key("memory"):
   1.165 -            raise DomainError("Missing `memory' option")
   1.166 -        if not opts.has_key("kernel"):
   1.167 -            raise DomainError("Missing `kernel' option")
   1.168 -
   1.169 -        self.opts = opts
   1.170 -
   1.171 -        self.configVals = None
   1.172 +    def __init__(self, name=None, config=None):
   1.173 +        """Create a domain object.
   1.174 +        @param config: String filename of config file
   1.175 +        """
   1.176  
   1.177 -    def __buildCmdLine(self):
   1.178 -        c = "xm create %s" % self.config
   1.179 -
   1.180 -        for k in self.opts.keys():
   1.181 -            c += " %s=%s" % (k, self.opts[k])
   1.182 -        
   1.183 -        return c
   1.184 +        if name:
   1.185 +            self.name = name
   1.186 +        else:
   1.187 +            self.name = getUniqueName()
   1.188  
   1.189 -    def getUniqueName(self):
   1.190 -        #
   1.191 -        # We avoid multiple duplicate names
   1.192 -        # here because they stick around in xend
   1.193 -        # too long
   1.194 -        #
   1.195 -        unixtime = int(time.time())
   1.196 -        test_name = sys.argv[0]
   1.197 -        test_name = re.sub("\.test", "", test_name)
   1.198 -        test_name = re.sub("[\/\.]", "", test_name)
   1.199 -        name = "%s-%i" % (test_name, unixtime)
   1.200 -
   1.201 -        return name
   1.202 +        self.config = config
   1.203  
   1.204      def start(self):
   1.205  
   1.206 -        if self.configVals:
   1.207 -            self.__writeConfig("/tmp/xm-test.conf")
   1.208 -            self.config = "/tmp/xm-test.conf"
   1.209 -
   1.210 -        commandLine = self.__buildCmdLine()
   1.211 -
   1.212 -        ret, output = traceCommand(commandLine);
   1.213 -
   1.214 -        try:
   1.215 -            self.domID = self.getId()
   1.216 -        except:
   1.217 -            self.domID = -1;
   1.218 +        ret, output = traceCommand("xm create %s" % self.config)
   1.219  
   1.220          if ret != 0:
   1.221              raise DomainError("Failed to create domain",
   1.222 @@ -118,190 +202,79 @@ class XenDomain:
   1.223                                errorcode=ret)
   1.224  
   1.225      def stop(self):
   1.226 -        prog = "xm";
   1.227 -        cmd = " shutdown ";
   1.228 +        prog = "xm"
   1.229 +        cmd = " shutdown "
   1.230  
   1.231 -        ret, output = traceCommand(prog + cmd + self.opts["name"]);
   1.232 +        ret, output = traceCommand(prog + cmd + self.config.getOpt("name"))
   1.233  
   1.234 -        return ret;
   1.235 +        return ret
   1.236  
   1.237      def destroy(self):
   1.238 -        prog = "xm";
   1.239 -        cmd = " destroy ";
   1.240 +        prog = "xm"
   1.241 +        cmd = " destroy "
   1.242  
   1.243 -        ret, output = traceCommand(prog + cmd + self.opts["name"]);
   1.244 +        ret, output = traceCommand(prog + cmd + self.config.getOpt("name"))
   1.245  
   1.246 -        return ret;
   1.247 +        return ret
   1.248  
   1.249      def getName(self):
   1.250 -        return self.opts["name"];
   1.251 +        return self.name
   1.252  
   1.253      def getId(self):
   1.254          return domid(self.getName());
   1.255  
   1.256 -    def configSetVar(self, key, value):
   1.257 -        if not self.configVals:
   1.258 -            self.configVals = {}
   1.259  
   1.260 -        self.configVals[key] = value
   1.261 -
   1.262 -    def configAddDisk(self, pdev, vdev, acc):
   1.263 -        if not self.configVals:
   1.264 -            self.configVals = {}
   1.265 -
   1.266 -        if not self.configVals.has_key("disk"):
   1.267 -            self.configVals["disk"] = []
   1.268 -
   1.269 -        self.configVals["disk"].append("%s,%s,%s" % (pdev,vdev,acc))
   1.270 -
   1.271 -    def configAddVif(self, type, mac, bridge):
   1.272 -        if not self.configVals:
   1.273 -            self.configVals = {}
   1.274 -
   1.275 -        if not self.configVals.has_key("vif"):
   1.276 -            self.configVals["vif"] = []
   1.277 -
   1.278 -        if mac:
   1.279 -            self.configVals["vif"].append("%s,%s,%s" % (type,mac,bridge))
   1.280 -        else:
   1.281 -            self.configVals["vif"].append("%s,%s" % (type,bridge))
   1.282 -
   1.283 -    def __writeConfig(self, configFileName):
   1.284 -
   1.285 -        conf = file(configFileName, "w")
   1.286 -
   1.287 -        for k,v in self.configVals.items():
   1.288 -            print >>conf, "%s = %s" % (k, v)
   1.289 -
   1.290 -        conf.close()
   1.291 -
   1.292 -class XmTestVmxDomain(XenDomain):
   1.293 -
   1.294 -    def __prepareBlockRoot(self, rdpath):
   1.295 -        image = os.path.abspath(rdpath + "/disk.img")
   1.296 -        self.configAddDisk("file:%s" % image, "ioemu:%s" % BLOCK_ROOT_DEV, "w")
   1.297 -
   1.298 -    def __prepareVif(self):
   1.299 -        self.configAddVif("type=ioemu", None, "bridge=xenbr0")
   1.300 +class XmTestDomain(XenDomain):
   1.301  
   1.302 -    def __prepareDeviceModel(self):
   1.303 -        arch = os.uname()[4]
   1.304 -        if re.search('64', arch):
   1.305 -            self.configSetVar("device_model", "\"/usr/lib64/xen/bin/qemu-dm\"")
   1.306 -        else:
   1.307 -            self.configSetVar("device_model", "\"/usr/lib/xen/bin/qemu-dm\"")
   1.308 -
   1.309 -    def __init__(self, name=None, extraOpts=None, config="/dev/null"):
   1.310 -
   1.311 -        rdpath = os.environ.get("RD_PATH")
   1.312 -        if not rdpath:
   1.313 -            rdpath = "../../ramdisk"
   1.314 -
   1.315 -        self.opts = {}
   1.316 -        self.configVals = {}
   1.317 +    def __init__(self, name=None, extraConfig=None, baseConfig=configDefaults):
   1.318 +        """Create a new xm-test domain
   1.319 +        @param name: The requested domain name
   1.320 +        @param extraConfig: Additional configuration options
   1.321 +        @param baseConfig: The initial configuration defaults to use
   1.322 +        """
   1.323 +        config = XenConfig()
   1.324 +        config.setOpts(baseConfig)
   1.325 +        if extraConfig:
   1.326 +            config.setOpts(extraConfig)
   1.327  
   1.328 -        # Defaults
   1.329 -        self.defaults = {"memory"    : 64,
   1.330 -                         "vcpus"     : 1,
   1.331 -                         "kernel"    : "/usr/lib/xen/boot/vmxloader",
   1.332 -                         "builder"   : "\'vmx\'",
   1.333 -                         "name"      : name or self.getUniqueName()
   1.334 -                         }
   1.335 -
   1.336 -        self.domID = None;
   1.337 -        self.config = config;
   1.338 +        if name:
   1.339 +            config.setOpt("name", name)
   1.340 +        elif not config.getOpt("name"):
   1.341 +            config.setOpt("name", getUniqueName())
   1.342  
   1.343 -        self.__prepareBlockRoot(rdpath)
   1.344 -	#self.__prepareVif()
   1.345 -        self.__prepareDeviceModel()
   1.346 -        #self.configSetVar("boot","\'c\'")
   1.347 -        self.configSetVar("sdl","0")
   1.348 -        self.configSetVar("vnc","0")
   1.349 -        self.configSetVar("vncviewer","0")
   1.350 -        self.configSetVar("nographic","1")
   1.351 -        self.configSetVar("serial","\'pty\'")
   1.352 -
   1.353 -        # Copy over defaults
   1.354 -        for key in self.defaults.keys():
   1.355 -            self.opts[key] = self.defaults[key]
   1.356 -
   1.357 -        # Merge in extra options
   1.358 -        if extraOpts:
   1.359 -            for key in extraOpts.keys():
   1.360 -                self.opts[key] = extraOpts[key]
   1.361 +        XenDomain.__init__(self, config.getOpt("name"), config=config)
   1.362  
   1.363      def start(self):
   1.364 -        """We know how about how long everyone will need to wait
   1.365 -        for our disk image to come up, so we do it here as a convenience"""
   1.366 -
   1.367 -#        for i in range(0,5):
   1.368 -#            status, output = traceCommand("xm list")
   1.369 -
   1.370          XenDomain.start(self)
   1.371 -        waitForBoot()
   1.372 +        if ENABLE_VMX_SUPPORT:
   1.373 +            waitForBoot()
   1.374  
   1.375      def startNow(self):
   1.376          XenDomain.start(self)
   1.377  
   1.378 -    def getMem(self):
   1.379 -        return int(self.opts["memory"])
   1.380 -
   1.381 -    def minSafeMem(self):
   1.382 -        return 16
   1.383 -
   1.384 -class XmTestPvDomain(XenDomain):
   1.385 -
   1.386 -    def __init__(self, name=None, extraOpts=None, config="/dev/null"):
   1.387 -
   1.388 -        rdpath = os.environ.get("RD_PATH")
   1.389 -        if not rdpath:
   1.390 -            rdpath = "../../ramdisk"
   1.391 -
   1.392 -        self.opts = {}
   1.393 -        self.configVals = None
   1.394 -
   1.395 -        # Defaults
   1.396 -        self.defaults = {"memory"  : 64,
   1.397 -                         "vcpus"   : 1,
   1.398 -                         "kernel"  : getDefaultKernel(),
   1.399 -                         "root"    : "/dev/ram0",
   1.400 -                         "name"    : name or self.getUniqueName(),
   1.401 -                         "ramdisk" : rdpath + "/initrd.img"
   1.402 -                         }
   1.403 -
   1.404 -        self.domID = None;
   1.405 -        self.config = config;
   1.406 -
   1.407 -        # Copy over defaults
   1.408 -        for key in self.defaults.keys():
   1.409 -            self.opts[key] = self.defaults[key]
   1.410 -
   1.411 -        # Merge in extra options
   1.412 -        if extraOpts:
   1.413 -            for key in extraOpts.keys():
   1.414 -                self.opts[key] = extraOpts[key]
   1.415 -
   1.416 -    def start(self):
   1.417 -        """We know how about how long everyone will need to wait
   1.418 -        for our ramdisk to come up, so we do it here as a convenience"""
   1.419 -
   1.420 -#        for i in range(0,5):
   1.421 -#            status, output = traceCommand("xm list")
   1.422 -
   1.423 -        XenDomain.start(self)
   1.424 -#        waitForBoot()
   1.425 -
   1.426 -    def startNow(self):
   1.427 -        XenDomain.start(self)
   1.428 -
   1.429 -    def getMem(self):
   1.430 -        return int(self.opts["memory"])
   1.431 -
   1.432      def minSafeMem(self):
   1.433          return 16
   1.434  
   1.435  if __name__ == "__main__":
   1.436  
   1.437 -    d = XmTestDomain();
   1.438 +    c = XenConfig()
   1.439 +
   1.440 +    c.setOpt("foo", "bar")
   1.441 +    c.setOpt("foob", 1)
   1.442 +    opts = {"opt1" : 19,
   1.443 +            "opt2" : "blah"}
   1.444 +    c.setOpts(opts)
   1.445 +
   1.446 +    c.setOpt("disk", "phy:/dev/ram0,hda1,w")
   1.447 +    c.appOpt("disk", "phy:/dev/ram1,hdb1,w")
   1.448  
   1.449 -    d.start();
   1.450 +    print str(c)
   1.451 +
   1.452 +    
   1.453 +
   1.454 +#    c.write("/tmp/foo.conf")
   1.455 +
   1.456 +#    d = XmTestDomain();
   1.457 +#
   1.458 +#    d.start();
   1.459 +
     2.1 --- a/tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py	Tue Dec 13 10:57:18 2005 +0000
     2.2 +++ b/tools/xm-test/tests/block-create/11_block_attach_shared_dom0.py	Tue Dec 13 16:26:24 2005 +0000
     2.3 @@ -21,8 +21,9 @@ if s != 0:
     2.4  
     2.5  # Now try to start a DomU with write access to /dev/ram0
     2.6  
     2.7 -domain = XmTestDomain();
     2.8 -domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
     2.9 +config = {"disk":"phy:/dev/ram0,hda1,w"}
    2.10 +
    2.11 +domain = XmTestDomain(extraConfig=config);
    2.12  
    2.13  try:
    2.14      domain.start()
     3.1 --- a/tools/xm-test/tests/block-create/12_block_attach_shared_domU.py	Tue Dec 13 10:57:18 2005 +0000
     3.2 +++ b/tools/xm-test/tests/block-create/12_block_attach_shared_domU.py	Tue Dec 13 16:26:24 2005 +0000
     3.3 @@ -5,11 +5,11 @@
     3.4  
     3.5  from XmTestLib import *
     3.6  
     3.7 -dom1 = XmTestDomain()
     3.8 -dom2 = XmTestDomain(dom1.getName() + "-2")
     3.9 +config = {"disk":"phy:/dev/ram0,hda1,w"}
    3.10  
    3.11 -dom1.configAddDisk("phy:/dev/ram0", "hda1", "w")
    3.12 -dom2.configAddDisk("phy:/dev/ram0", "hda1", "w")
    3.13 +dom1 = XmTestDomain(extraConfig=config)
    3.14 +dom2 = XmTestDomain(dom1.getName() + "-2",
    3.15 +                    extraConfig=config)
    3.16  
    3.17  try:
    3.18      dom1.start()
     4.1 --- a/tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py	Tue Dec 13 10:57:18 2005 +0000
     4.2 +++ b/tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py	Tue Dec 13 16:26:24 2005 +0000
     4.3 @@ -5,9 +5,8 @@
     4.4  
     4.5  from XmTestLib import *
     4.6  
     4.7 -domain = XmTestDomain()
     4.8 -
     4.9 -domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
    4.10 +config = {"disk":"phy:/dev/ram0,hda1,w"}
    4.11 +domain = XmTestDomain(extraConfig=config)
    4.12  
    4.13  try:
    4.14      domain.start()
     5.1 --- a/tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py	Tue Dec 13 10:57:18 2005 +0000
     5.2 +++ b/tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py	Tue Dec 13 16:26:24 2005 +0000
     5.3 @@ -5,9 +5,8 @@
     5.4  
     5.5  from XmTestLib import *
     5.6  
     5.7 -domain = XmTestDomain()
     5.8 -
     5.9 -domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
    5.10 +config = {"disk":"phy:/dev/ram0,hda1,w"}
    5.11 +domain = XmTestDomain(extraConfig=config)
    5.12  
    5.13  try:
    5.14      domain.start()
     6.1 --- a/tools/xm-test/tests/block-list/01_block-list_pos.py	Tue Dec 13 10:57:18 2005 +0000
     6.2 +++ b/tools/xm-test/tests/block-list/01_block-list_pos.py	Tue Dec 13 16:26:24 2005 +0000
     6.3 @@ -8,9 +8,8 @@
     6.4  
     6.5  from XmTestLib import *
     6.6  
     6.7 -domain = XmTestDomain()
     6.8 -
     6.9 -domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
    6.10 +config = {"disk":"phy:/dev/ram0,hda1,w"}
    6.11 +domain = XmTestDomain(extraConfig=config)
    6.12  
    6.13  try:
    6.14      domain.start()
     7.1 --- a/tools/xm-test/tests/block-list/03_block-list_anotherbd_pos.py	Tue Dec 13 10:57:18 2005 +0000
     7.2 +++ b/tools/xm-test/tests/block-list/03_block-list_anotherbd_pos.py	Tue Dec 13 16:26:24 2005 +0000
     7.3 @@ -8,9 +8,8 @@
     7.4  
     7.5  from XmTestLib import *
     7.6  
     7.7 -domain = XmTestDomain()
     7.8 -
     7.9 -domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
    7.10 +config = {"disk":"phy:/dev/ram0,hda1,w"}
    7.11 +domain = XmTestDomain(extraConfig=config)
    7.12  
    7.13  try:
    7.14      domain.start()
     8.1 --- a/tools/xm-test/tests/create/01_create_basic_pos.py	Tue Dec 13 10:57:18 2005 +0000
     8.2 +++ b/tools/xm-test/tests/create/01_create_basic_pos.py	Tue Dec 13 16:26:24 2005 +0000
     8.3 @@ -12,9 +12,9 @@ from XmTestLib import *
     8.4  # Create a domain (default XmTestDomain, with our ramdisk)
     8.5  domain = XmTestDomain()
     8.6  
     8.7 -if int(getInfo("free_memory")) < domain.getMem():
     8.8 +if int(getInfo("free_memory")) < domain.config.getOpt("memory"):
     8.9      SKIP("This test needs %i MB of free memory (%i MB avail)" %
    8.10 -         (domain.getMem(), int(getInfo("free_memory"))))
    8.11 +         (domain.config.getOpt("memory"), int(getInfo("free_memory"))))
    8.12  
    8.13  # Start it
    8.14  try:
     9.1 --- a/tools/xm-test/tests/create/06_create_mem_neg.py	Tue Dec 13 10:57:18 2005 +0000
     9.2 +++ b/tools/xm-test/tests/create/06_create_mem_neg.py	Tue Dec 13 16:26:24 2005 +0000
     9.3 @@ -19,15 +19,8 @@ if not rdpath:
     9.4  	rdpath = "../ramdisk"
     9.5  
     9.6  # Test 1: create a domain with mem=0
     9.7 -opts1 =  {
     9.8 -            "name"    : "default",
     9.9 -            "memory"  : 0,
    9.10 -            "kernel"  : getDefaultKernel(),
    9.11 -            "root"    : "/dev/ram0",
    9.12 -            "ramdisk" : rdpath + "/initrd.img",
    9.13 -            }
    9.14 -
    9.15 -domain1=XenDomain(opts1)
    9.16 +config1 = {"memory": 0}
    9.17 +domain1=XmTestDomain(extraConfig=config1)
    9.18  
    9.19  try:
    9.20      domain1.start()
    9.21 @@ -43,17 +36,10 @@ if eyecatcher1 != "Fail":
    9.22  # Test 2: create a domain with mem>sys_mem
    9.23  
    9.24  mem = int(getInfo("total_memory"))
    9.25 -extreme_mem = str(mem + 100)
    9.26 +extreme_mem = mem + 100
    9.27  
    9.28 -opts2=  {
    9.29 -            "name"    : "default",
    9.30 -            "memory"  : extreme_mem,
    9.31 -            "kernel"  : getDefaultKernel(),
    9.32 -            "root"    : "/dev/ram0",
    9.33 -            "ramdisk" : rdpath + "/initrd.img",
    9.34 -            }
    9.35 -
    9.36 -domain2=XenDomain(opts2)
    9.37 +config2 = {"memory": extreme_mem}
    9.38 +domain2=XmTestDomain(extraConfig=config2)
    9.39  
    9.40  try:
    9.41      domain2.start()
    10.1 --- a/tools/xm-test/tests/create/07_create_mem64_pos.py	Tue Dec 13 10:57:18 2005 +0000
    10.2 +++ b/tools/xm-test/tests/create/07_create_mem64_pos.py	Tue Dec 13 16:26:24 2005 +0000
    10.3 @@ -23,15 +23,8 @@ if mem < 64:
    10.4  	SKIP("This test needs 64 MB of free memory (%i MB avail)" % mem)
    10.5  
    10.6  #create a domain with mem=64
    10.7 -opts =  {
    10.8 -            "name"    : "MEM64",
    10.9 -            "memory"  : 64,
   10.10 -            "kernel"  : getDefaultKernel(),
   10.11 -            "root"    : "/dev/ram0",
   10.12 -            "ramdisk" : rdpath + "/initrd.img",
   10.13 -            }
   10.14 -
   10.15 -domain_mem64=XenDomain(opts)
   10.16 +config = {"memory": 64}
   10.17 +domain_mem64=XmTestDomain(extraConfig=config)
   10.18  
   10.19  #start it
   10.20  try:
    11.1 --- a/tools/xm-test/tests/create/08_create_mem128_pos.py	Tue Dec 13 10:57:18 2005 +0000
    11.2 +++ b/tools/xm-test/tests/create/08_create_mem128_pos.py	Tue Dec 13 16:26:24 2005 +0000
    11.3 @@ -23,15 +23,8 @@ if mem < 128:
    11.4          SKIP("This test needs 128 MB of free memory (%i MB avail)" % mem)
    11.5  
    11.6  #create a domain with mem=128
    11.7 -opts =  {
    11.8 -            "name"    : "MEM128",
    11.9 -            "memory"  : 128,
   11.10 -            "kernel"  : getDefaultKernel(),
   11.11 -            "root"    : "/dev/ram0",
   11.12 -            "ramdisk" : rdpath + "/initrd.img",
   11.13 -            }
   11.14 -
   11.15 -domain_mem128=XenDomain(opts)
   11.16 +config={"memory": 128}
   11.17 +domain_mem128=XmTestDomain(extraConfig=config)
   11.18  
   11.19  #start it
   11.20  try:
    12.1 --- a/tools/xm-test/tests/create/09_create_mem256_pos.py	Tue Dec 13 10:57:18 2005 +0000
    12.2 +++ b/tools/xm-test/tests/create/09_create_mem256_pos.py	Tue Dec 13 16:26:24 2005 +0000
    12.3 @@ -23,15 +23,8 @@ if mem < 256:
    12.4          SKIP("This test needs 256 MB of free memory (%i MB avail)" % mem)
    12.5  
    12.6  #create a domain with mem=256
    12.7 -opts =  {
    12.8 -            "name"    : "MEM256",
    12.9 -            "memory"  : 256,
   12.10 -            "kernel"  : getDefaultKernel(),
   12.11 -            "root"    : "/dev/ram0",
   12.12 -            "ramdisk" : rdpath + "/initrd.img",
   12.13 -            }
   12.14 -
   12.15 -domain_mem256=XenDomain(opts)
   12.16 +config = {"memory": 256}
   12.17 +domain_mem256=XmTestDomain(extraConfig=config)
   12.18  
   12.19  #start it
   12.20  try:
    13.1 --- a/tools/xm-test/tests/create/11_create_concurrent_pos.py	Tue Dec 13 10:57:18 2005 +0000
    13.2 +++ b/tools/xm-test/tests/create/11_create_concurrent_pos.py	Tue Dec 13 16:26:24 2005 +0000
    13.3 @@ -34,7 +34,7 @@ if verbose:
    13.4  
    13.5  for d in range(0, NUM_DOMS):
    13.6      dom = XmTestDomain(name="11_create_%i" % d,
    13.7 -                       extraOpts={"memory":str(MEM_PER_DOM)})
    13.8 +                       extraConfig={"memory":MEM_PER_DOM})
    13.9  
   13.10      try:
   13.11          dom.start()
    14.1 --- a/tools/xm-test/tests/create/12_create_concurrent_stress_pos.py	Tue Dec 13 10:57:18 2005 +0000
    14.2 +++ b/tools/xm-test/tests/create/12_create_concurrent_stress_pos.py	Tue Dec 13 16:26:24 2005 +0000
    14.3 @@ -14,7 +14,7 @@ DUR=60
    14.4  domains = []
    14.5  
    14.6  for i in range(0,DOMS):
    14.7 -    dom = XmTestDomain(extraOpts={"memory" : str(MEM)})
    14.8 +    dom = XmTestDomain(extraConfig={"memory" : MEM})
    14.9  
   14.10      try:
   14.11          dom.start()
    15.1 --- a/tools/xm-test/tests/create/13_create_multinic_pos.py	Tue Dec 13 10:57:18 2005 +0000
    15.2 +++ b/tools/xm-test/tests/create/13_create_multinic_pos.py	Tue Dec 13 16:26:24 2005 +0000
    15.3 @@ -6,8 +6,8 @@
    15.4  from XmTestLib import *
    15.5  
    15.6  for i in range(0,10):
    15.7 -    domain = XmTestDomain()
    15.8 -    domain.configSetVar('vif', str(['' for _ in range(0, i)]))
    15.9 +    config = {"vif": ['' for _ in range(0, i)]}
   15.10 +    domain = XmTestDomain(extraConfig=config)
   15.11  
   15.12      try:
   15.13          domain.start()
    16.1 --- a/tools/xm-test/tests/create/14_create_blockroot_pos.py	Tue Dec 13 10:57:18 2005 +0000
    16.2 +++ b/tools/xm-test/tests/create/14_create_blockroot_pos.py	Tue Dec 13 16:26:24 2005 +0000
    16.3 @@ -6,10 +6,9 @@
    16.4  from XmTestLib import *
    16.5  
    16.6  import os
    16.7 +import time
    16.8  
    16.9 -CONF_FILE = "/tmp/14_create_blockroot_pos.conf"
   16.10 -
   16.11 -rdpath = os.path.abspath(os.environ.get("RD_PATH"))
   16.12 +rdpath = getRdPath()
   16.13  
   16.14  # status, output = traceCommand("losetup -f %s" % rdpath)
   16.15  # if status != 0:
   16.16 @@ -17,22 +16,26 @@ rdpath = os.path.abspath(os.environ.get(
   16.17  # 
   16.18  # if verbose:
   16.19  #     print "Using %s" % output
   16.20 - 
   16.21 -opts = {"memory" : "64",
   16.22 -        "root"   : "/dev/hda1",
   16.23 -        "name"   : "14_create_blockroot",
   16.24 -        "kernel" : getDefaultKernel() }
   16.25  
   16.26 -domain = XenDomain(opts=opts)
   16.27 -
   16.28 -domain.configAddDisk("file:%s/initrd.img" % rdpath, "hda1", "w")
   16.29 +if ENABLE_VMX_SUPPORT:
   16.30 +    domain = XmTestDomain(name="14_create_blockroot")
   16.31 +else:
   16.32 +    config = {"memory" : "64",
   16.33 +              "root"   : "/dev/hda1",
   16.34 +              "name"   : "14_create_blockroot",
   16.35 +              "kernel" : getDefaultKernel(),
   16.36 +              "disk"   : "file:%s/initrd.img,hda1,w" % rdpath
   16.37 +              }
   16.38 +    domConfig = XenConfig()
   16.39 +    domConfig.setOpts(config)
   16.40 +    domain = XenDomain(name=domConfig.getOpt("name"), config=domConfig)
   16.41  
   16.42  try:
   16.43      domain.start()
   16.44  except DomainError, e:
   16.45        FAIL(str(e))
   16.46  
   16.47 -waitForBoot()
   16.48 +#waitForBoot()
   16.49  
   16.50  try:
   16.51      console = XmConsole(domain.getName(), historySaveCmds=True)
    17.1 --- a/tools/xm-test/tests/create/15_create_smallmem_pos.py	Tue Dec 13 10:57:18 2005 +0000
    17.2 +++ b/tools/xm-test/tests/create/15_create_smallmem_pos.py	Tue Dec 13 16:26:24 2005 +0000
    17.3 @@ -7,8 +7,8 @@ from XmTestLib import *
    17.4  
    17.5  MEM = 16
    17.6  
    17.7 -domain = XmTestDomain(extraOpts={"memory":"%i" % MEM,
    17.8 -                                 "extra" :"mem=%iM" % MEM})
    17.9 +domain = XmTestDomain(extraConfig={"memory": MEM,
   17.10 +                                   "extra" :"mem=%iM" % MEM})
   17.11  
   17.12  try:
   17.13      domain.start()
    18.1 --- a/tools/xm-test/tests/memset/03_memset_random_pos.py	Tue Dec 13 10:57:18 2005 +0000
    18.2 +++ b/tools/xm-test/tests/memset/03_memset_random_pos.py	Tue Dec 13 16:26:24 2005 +0000
    18.3 @@ -20,8 +20,8 @@ except DomainError, e:
    18.4      FAIL(str(e))
    18.5  
    18.6  times = random.randint(10,50)
    18.7 -origmem = domain.getMem()
    18.8 -currmem = domain.getMem()
    18.9 +origmem = domain.config.getOpt("memory")
   18.10 +currmem = domain.config.getOpt("memory")
   18.11  
   18.12  try:
   18.13      console = XmConsole(domain.getName())
    19.1 --- a/tools/xm-test/tests/network/02_network_local_ping_pos.py	Tue Dec 13 10:57:18 2005 +0000
    19.2 +++ b/tools/xm-test/tests/network/02_network_local_ping_pos.py	Tue Dec 13 16:26:24 2005 +0000
    19.3 @@ -28,9 +28,9 @@ ip   = Net.ip("dom1", "eth0")
    19.4  mask = Net.mask("dom1", "eth0")
    19.5  
    19.6  # Fire up a guest domain w/1 nic
    19.7 -domain = XmTestDomain()
    19.8 +config = {"vif" : ['ip=%s' % ip]}
    19.9 +domain = XmTestDomain(extraConfig=config)
   19.10  try:
   19.11 -    domain.configSetVar('vif', " [ 'ip=" + ip + "' ]")
   19.12      domain.start()
   19.13  except DomainError, e:
   19.14      if verbose:
    20.1 --- a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py	Tue Dec 13 10:57:18 2005 +0000
    20.2 +++ b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py	Tue Dec 13 16:26:24 2005 +0000
    20.3 @@ -31,9 +31,9 @@ except NetworkError, e:
    20.4          FAIL(str(e))
    20.5  
    20.6  # Fire up a guest domain w/1 nic
    20.7 -domain = XmTestDomain()
    20.8 +config = {"vif"  : ["ip=%s" % ip]}
    20.9 +domain = XmTestDomain(extraConfig=config)
   20.10  try:
   20.11 -    domain.configSetVar('vif', " [ 'ip=" + ip + "' ]")
   20.12      domain.start()
   20.13  except DomainError, e:
   20.14      if verbose:
    21.1 --- a/tools/xm-test/tests/network/11_network_domU_ping_pos.py	Tue Dec 13 10:57:18 2005 +0000
    21.2 +++ b/tools/xm-test/tests/network/11_network_domU_ping_pos.py	Tue Dec 13 16:26:24 2005 +0000
    21.3 @@ -15,15 +15,12 @@
    21.4  pingsizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192, 
    21.5                32767, 65507 ]
    21.6  
    21.7 -
    21.8 -
    21.9  from XmTestLib import *
   21.10  
   21.11 -
   21.12  def netDomain(ip):
   21.13 -    dom = XmTestDomain()
   21.14 +    config = {"vif"  : ["ip=%s" % ip]}
   21.15 +    domain = XmTestDomain(extraConfig=config)
   21.16      try:
   21.17 -        dom.configSetVar('vif', " [ 'ip=" + ip + "' ]")
   21.18          dom.start()
   21.19      except DomainError, e:
   21.20          if verbose:
    22.1 --- a/tools/xm-test/tests/restore/04_restore_withdevices_pos.py	Tue Dec 13 10:57:18 2005 +0000
    22.2 +++ b/tools/xm-test/tests/restore/04_restore_withdevices_pos.py	Tue Dec 13 16:26:24 2005 +0000
    22.3 @@ -7,12 +7,9 @@ from XmTestLib import *
    22.4  
    22.5  import re
    22.6  
    22.7 -domain = XmTestDomain()
    22.8 -
    22.9 -domain.configSetVar('vif', "[ '', '' ]")
   22.10 -
   22.11 -domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
   22.12 -domain.configAddDisk("phy:/dev/ram1", "hdb2", "w")
   22.13 +config = {"disk": ["phy:/dev/ram0,hda1,w", "phy:/dev/ram1,hdb2,w"],
   22.14 +          "vif":  ['', '']}
   22.15 +domain = XmTestDomain(extraConfig=config)
   22.16  
   22.17  s, o = traceCommand("mke2fs -q /dev/ram0")
   22.18  if s != 0:
    23.1 --- a/tools/xm-test/tests/sedf/01_sedf_multi_pos.py	Tue Dec 13 10:57:18 2005 +0000
    23.2 +++ b/tools/xm-test/tests/sedf/01_sedf_multi_pos.py	Tue Dec 13 16:26:24 2005 +0000
    23.3 @@ -7,7 +7,7 @@ from XmTestLib import *
    23.4  
    23.5  sedf_opts = "20000000 5000000 0 0 0"
    23.6  
    23.7 -domain = XmTestDomain(extraOpts = {"sched":"sedf"})
    23.8 +domain = XmTestDomain(extraConfig = {"sched":"sedf"})
    23.9  
   23.10  try:
   23.11      domain.start()
    24.1 --- a/tools/xm-test/tests/vcpu-disable/01_vcpu-disable_basic_pos.py	Tue Dec 13 10:57:18 2005 +0000
    24.2 +++ b/tools/xm-test/tests/vcpu-disable/01_vcpu-disable_basic_pos.py	Tue Dec 13 16:26:24 2005 +0000
    24.3 @@ -39,7 +39,7 @@ if smpConcurrencyLevel() <= 1:
    24.4      SKIP("Host not capable of running test")
    24.5  
    24.6  # Start a XmTestDomain with 2 VCPUs
    24.7 -domain = XmTestDomain(extraOpts = {"vcpus":"2"})
    24.8 +domain = XmTestDomain(extraConfig={"vcpus":2})
    24.9  
   24.10  try:
   24.11      domain.start()