ia64/xen-unstable

changeset 7639:c352591ebfdf

Add support for the ioport_permission dom0 op to xend and xm

xm now accepts a parameter 'ioports' that accepts a hex ioport
or ioport range, in the form 02f8[-02ff]

Signed-off-by: Jody Belka <knew (at) pimb (dot) org>
author kaf24@firebug.cl.cam.ac.uk
date Sun Nov 06 16:40:33 2005 +0100 (2005-11-06)
parents b67d2d2465aa
children 55194bd55b86
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Sun Nov 06 16:40:15 2005 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Sun Nov 06 16:40:33 2005 +0100
     1.3 @@ -492,6 +492,40 @@ class XendDomain:
     1.4          except Exception, ex:
     1.5              raise XendError(str(ex))
     1.6  
     1.7 +    def domain_ioport_range_enable(self, domid, first, last):
     1.8 +        """Enable access to a range of IO ports for a domain
     1.9 +
    1.10 +        @param first: first IO port
    1.11 +        @param last: last IO port
    1.12 +        @return: 0 on success, -1 on error
    1.13 +        """
    1.14 +        dominfo = self.domain_lookup(domid)
    1.15 +        nr_ports = last - first + 1
    1.16 +        try:
    1.17 +            return xc.domain_ioport_permission(dominfo.getDomid(),
    1.18 +                                               first_port = first,
    1.19 +                                               nr_ports = nr_ports,
    1.20 +                                               allow_access = 1)
    1.21 +        except Exception, ex:
    1.22 +            raise XendError(str(ex))
    1.23 +
    1.24 +    def domain_ioport_range_disable(self, domid, first, last):
    1.25 +        """Disable access to a range of IO ports for a domain
    1.26 +
    1.27 +        @param first: first IO port
    1.28 +        @param last: last IO port
    1.29 +        @return: 0 on success, -1 on error
    1.30 +        """
    1.31 +        dominfo = self.domain_lookup(domid)
    1.32 +        nr_ports = last - first + 1
    1.33 +        try:
    1.34 +            return xc.domain_ioport_permission(dominfo.getDomid(),
    1.35 +                                               first_port = first,
    1.36 +                                               nr_ports = nr_ports,
    1.37 +                                               allow_access = 0)
    1.38 +        except Exception, ex:
    1.39 +            raise XendError(str(ex))
    1.40 +
    1.41  
    1.42  def instance():
    1.43      """Singleton constructor. Use this instead of the class constructor.
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Sun Nov 06 16:40:15 2005 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Sun Nov 06 16:40:33 2005 +0100
     2.3 @@ -1400,9 +1400,10 @@ def addControllerClass(device_class, cls
     2.4      controllerClasses[device_class] = cls
     2.5  
     2.6  
     2.7 -from xen.xend.server import blkif, netif, tpmif, pciif, usbif
     2.8 +from xen.xend.server import blkif, netif, tpmif, pciif, iopif, usbif
     2.9  addControllerClass('vbd',  blkif.BlkifController)
    2.10  addControllerClass('vif',  netif.NetifController)
    2.11  addControllerClass('vtpm', tpmif.TPMifController)
    2.12  addControllerClass('pci',  pciif.PciController)
    2.13 +addControllerClass('ioports', iopif.IOPortsController)
    2.14  addControllerClass('usb',  usbif.UsbifController)
     3.1 --- a/tools/python/xen/xm/create.py	Sun Nov 06 16:40:15 2005 +0100
     3.2 +++ b/tools/python/xen/xm/create.py	Sun Nov 06 16:40:33 2005 +0100
     3.3 @@ -241,6 +241,12 @@ gopts.var('pci', val='BUS,DEV,FUNC',
     3.4           For example '-pci c0,02,1a'.
     3.5           The option may be repeated to add more than one pci device.""")
     3.6  
     3.7 +gopts.var('ioports', val='FROM[-TO]',
     3.8 +          fn=append_value, default=[],
     3.9 +          use="""Add a legacy I/O range to a domain, using given params (in hex).
    3.10 +         For example '-ioports 02f8-02ff'.
    3.11 +         The option may be repeated to add more than one i/o range.""")
    3.12 +
    3.13  gopts.var('usb', val='PATH',
    3.14            fn=append_value, default=[],
    3.15            use="""Add a physical USB port to a domain, as specified by the path
    3.16 @@ -439,6 +445,13 @@ def configure_pci(config_devs, vals):
    3.17          config_pci = ['pci', ['bus', bus], ['dev', dev], ['func', func]]
    3.18          config_devs.append(['device', config_pci])
    3.19  
    3.20 +def configure_ioports(config_devs, vals):
    3.21 +    """Create the config for legacy i/o ranges.
    3.22 +    """
    3.23 +    for (io_from, io_to) in vals.ioports:
    3.24 +        config_ioports = ['ioports', ['from', io_from], ['to', io_to]]
    3.25 +        config_devs.append(['device', config_ioports])
    3.26 +
    3.27  def configure_usb(config_devs, vals):
    3.28      for path in vals.usb:
    3.29          config_usb = ['usb', ['path', path]]
    3.30 @@ -611,6 +624,7 @@ def make_config(vals):
    3.31      config_devs = []
    3.32      configure_disks(config_devs, vals)
    3.33      configure_pci(config_devs, vals)
    3.34 +    configure_ioports(config_devs, vals)
    3.35      configure_vifs(config_devs, vals)
    3.36      configure_usb(config_devs, vals)
    3.37      configure_vtpm(config_devs, vals)
    3.38 @@ -645,6 +659,20 @@ def preprocess_pci(vals):
    3.39          pci.append(hexd)
    3.40      vals.pci = pci
    3.41  
    3.42 +def preprocess_ioports(vals):
    3.43 +    if not vals.ioports: return
    3.44 +    ioports = []
    3.45 +    for v in vals.ioports:
    3.46 +        d = v.split('-')
    3.47 +        if len(d) < 1 || len(d) > 2:
    3.48 +            err('Invalid i/o port range specifier: ' + v)
    3.49 +        if len(d) == 1:
    3.50 +            d.append(d[0])
    3.51 +        # Components are in hex: add hex specifier.
    3.52 +        hexd = map(lambda v: '0x'+v, d)
    3.53 +        ioports.append(hexd)
    3.54 +    vals.ioports = ioports
    3.55 +        
    3.56  def preprocess_vifs(vals):
    3.57      if not vals.vif: return
    3.58      vifs = []
    3.59 @@ -777,6 +805,7 @@ def preprocess(vals):
    3.60          err("No kernel specified")
    3.61      preprocess_disk(vals)
    3.62      preprocess_pci(vals)
    3.63 +    preprocess_ioports(vals)
    3.64      preprocess_vifs(vals)
    3.65      preprocess_ip(vals)
    3.66      preprocess_nfs(vals)