ia64/xen-unstable

changeset 5741:c20bd9f1d204

Device model SXP cleanup

- don't pollute the sxp with unused options
- use the same syntax as paravirtualized domains for disks

Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Jul 11 20:09:10 2005 +0000 (2005-07-11)
parents 09cc6606517d
children 291fa5555eff
files tools/examples/xmexample.vmx tools/python/xen/xend/image.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/examples/xmexample.vmx	Mon Jul 11 16:04:22 2005 +0000
     1.2 +++ b/tools/examples/xmexample.vmx	Mon Jul 11 20:09:10 2005 +0000
     1.3 @@ -46,6 +46,7 @@ nics=0
     1.4  # and MODE is r for read-only, w for read-write.
     1.5  
     1.6  #disk = [ 'phy:hda1,hda1,r' ]
     1.7 +disk = [ 'file:/var/images/min-el3-i386.img,hda,w' ]
     1.8  
     1.9  #----------------------------------------------------------------------------
    1.10  # Set the kernel command line for the new domain.
    1.11 @@ -96,10 +97,6 @@ memmap = '/usr/lib/xen/boot/mem-map.sxp'
    1.12  
    1.13  #-----------------------------------------------------------------------------
    1.14  # Disk image for 
    1.15 -hda='/var/images/min-el3-i386.img'
    1.16 -#hdb=
    1.17 -#hdc=
    1.18 -#hdd=
    1.19  #cdrom=
    1.20  
    1.21  #-----------------------------------------------------------------------------
     2.1 --- a/tools/python/xen/xend/image.py	Mon Jul 11 16:04:22 2005 +0000
     2.2 +++ b/tools/python/xen/xend/image.py	Mon Jul 11 20:09:10 2005 +0000
     2.3 @@ -265,7 +265,7 @@ class VmxImageHandler(ImageHandler):
     2.4      # Return a list of cmd line args to the device models based on the
     2.5      # xm config file
     2.6      def parseDeviceModelArgs(self):
     2.7 -	dmargs = [ 'hda', 'hdb', 'hdc', 'hdd', 'cdrom', 'boot', 'fda', 'fdb',
     2.8 +	dmargs = [ 'cdrom', 'boot', 'fda', 'fdb',
     2.9                     'localtime', 'serial', 'macaddr', 'stdvga', 'isa' ] 
    2.10  	ret = []
    2.11  	for a in dmargs:
    2.12 @@ -276,17 +276,31 @@ class VmxImageHandler(ImageHandler):
    2.13  
    2.14              # Handle booleans gracefully
    2.15              if a in ['localtime', 'std-vga', 'isa']:
    2.16 -                v = int(v)
    2.17 +                if v != None: v = int(v)
    2.18  
    2.19  	    log.debug("args: %s, val: %s" % (a,v))
    2.20  	    if v: 
    2.21  		ret.append("-%s" % a)
    2.22  		ret.append("%s" % v)
    2.23  
    2.24 +        # Handle hd img related options
    2.25 +        device = sxp.child(self.vm.config, 'device')
    2.26 +        vbdinfo = sxp.child(device, 'vbd')
    2.27 +        if not vbdinfo:
    2.28 +            raise VmError("vmx: missing vbd configuration")
    2.29 +        uname = sxp.child_value(vbdinfo, 'uname')
    2.30 +        vbddev = sxp.child_value(vbdinfo, 'dev')
    2.31 +        (vbdtype, vbdparam) = string.split(uname, ':', 1)
    2.32 +        vbddev_list = ['hda', 'hdb', 'hdc', 'hdd']
    2.33 +        if vbdtype != 'file' or vbddev not in vbddev_list:
    2.34 +            raise VmError("vmx: for qemu vbd type=file&dev=hda~hdd")
    2.35 +        ret.append("-%s" % vbddev)
    2.36 +        ret.append("%s" % vbdparam)
    2.37 +
    2.38  	# Handle graphics library related options
    2.39 -	vnc = int(sxp.child_value(self.vm.config, 'vnc'))
    2.40 -	sdl = int(sxp.child_value(self.vm.config, 'sdl'))
    2.41 -	nographic = int(sxp.child_value(self.vm.config, 'nographic'))
    2.42 +	vnc = sxp.child_value(self.vm.config, 'vnc')
    2.43 +	sdl = sxp.child_value(self.vm.config, 'sdl')
    2.44 +	nographic = sxp.child_value(self.vm.config, 'nographic')
    2.45  	if nographic:
    2.46  	    ret.append('-nographic')
    2.47  	    return ret
     3.1 --- a/tools/python/xen/xm/create.py	Mon Jul 11 16:04:22 2005 +0000
     3.2 +++ b/tools/python/xen/xm/create.py	Mon Jul 11 20:09:10 2005 +0000
     3.3 @@ -254,22 +254,6 @@ gopts.var('device_model', val='FILE',
     3.4            fn=set_value, default='',
     3.5            use="Path to device model program.")
     3.6  
     3.7 -gopts.var('hda', val='FILE',
     3.8 -          fn=set_value, default='',
     3.9 -          use="Path to hda")
    3.10 -
    3.11 -gopts.var('hdb', val='FILE',
    3.12 -          fn=set_value, default='',
    3.13 -          use="Path to hdb")
    3.14 -
    3.15 -gopts.var('hdc', val='FILE',
    3.16 -          fn=set_value, default='',
    3.17 -          use="Path to hdc")
    3.18 -
    3.19 -gopts.var('hdd', val='FILE',
    3.20 -          fn=set_value, default='',
    3.21 -          use="Path to hdd")
    3.22 -
    3.23  gopts.var('fda', val='FILE',
    3.24            fn=set_value, default='',
    3.25            use="Path to fda")
    3.26 @@ -442,11 +426,12 @@ def configure_vfr(opts, config, vals):
    3.27  def configure_vmx(opts, config_devs, vals):
    3.28      """Create the config for VMX devices.
    3.29      """
    3.30 -    args = [ 'memmap', 'device_model', 'hda', 'hdb', 'hdc', 'hdd', 'cdrom',
    3.31 +    args = [ 'memmap', 'device_model', 'cdrom',
    3.32   	     'boot', 'fda', 'fdb', 'localtime', 'serial', 'macaddr', 'stdvga', 
    3.33 -             'isa', 'nographic', 'vnc', 'sdl', 'display']	 
    3.34 +             'isa', 'nographic', 'vnc', 'sdl', 'display']	  
    3.35      for a in args:
    3.36 -    	config_devs.append([a, vals.__dict__[a]])
    3.37 +	if (vals.__dict__[a]):
    3.38 +    	    config_devs.append([a, vals.__dict__[a]])
    3.39  
    3.40  def run_bootloader(opts, config, vals):
    3.41      if not os.access(vals.bootloader, os.X_OK):
    3.42 @@ -604,7 +589,7 @@ def preprocess_vnc(opts, vals):
    3.43      """If vnc was specified, spawn a vncviewer in listen mode
    3.44      and pass its address to the domain on the kernel command line.
    3.45      """
    3.46 -    if not vals.vnc: return
    3.47 +    if not vals.vnc or vals.dryrun: return
    3.48      vnc_display = choose_vnc_display()
    3.49      if not vnc_display:
    3.50          opts.warn("No free vnc display")
    3.51 @@ -678,8 +663,6 @@ def main(argv):
    3.52          config = opts.vals.config
    3.53      else:
    3.54          opts.load_defconfig()
    3.55 -        if opts.vals.dryrun:
    3.56 -	    opts.vals.vnc = 0
    3.57          preprocess(opts, opts.vals)
    3.58          if not opts.getopt('name') and opts.getopt('defconfig'):
    3.59              opts.setopt('name', os.path.basename(opts.getopt('defconfig')))