All of lore.kernel.org
 help / color / mirror / Atom feed
From: lists-xen@pimb.org
To: xen-devel@lists.xensource.com
Subject: [PATCH 4/4] ioports: xend/xm support
Date: Sun, 6 Nov 2005 02:46:31 +0100	[thread overview]
Message-ID: <20051106014631.GD12698@pimb.org> (raw)
In-Reply-To: <20051106014026.GN5268@pimb.org>

[-- Attachment #1: Type: text/plain, Size: 45 bytes --]

4/4

-- 
Jody Belka
knew (at) pimb (dot) org

[-- Attachment #2: ioport-4.patch --]
[-- Type: text/plain, Size: 5258 bytes --]

# HG changeset patch
# User jmb@artemis.home.pimb.org
# Node ID e2b5c74938f64d55609a690c22a18c3875b21d04
# Parent  3acad8d6d0cf5c8a00833aea7fdbb20f9e73868e
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>

diff -r 3acad8d6d0cf -r e2b5c74938f6 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py	Sun Nov  6 01:15:12 2005
+++ b/tools/python/xen/xend/XendDomain.py	Sun Nov  6 01:15:44 2005
@@ -492,6 +492,40 @@
         except Exception, ex:
             raise XendError(str(ex))
 
+    def domain_ioport_range_enable(self, domid, first, last):
+        """Enable access to a range of IO ports for a domain
+
+        @param first: first IO port
+        @param last: last IO port
+        @return: 0 on success, -1 on error
+        """
+        dominfo = self.domain_lookup(domid)
+        nr_ports = last - first + 1
+        try:
+            return xc.domain_ioport_permission(dominfo.getDomid(),
+                                               first_port = first,
+                                               nr_ports = nr_ports,
+                                               allow_access = 1)
+        except Exception, ex:
+            raise XendError(str(ex))
+
+    def domain_ioport_range_disable(self, domid, first, last):
+        """Disable access to a range of IO ports for a domain
+
+        @param first: first IO port
+        @param last: last IO port
+        @return: 0 on success, -1 on error
+        """
+        dominfo = self.domain_lookup(domid)
+        nr_ports = last - first + 1
+        try:
+            return xc.domain_ioport_permission(dominfo.getDomid(),
+                                               first_port = first,
+                                               nr_ports = nr_ports,
+                                               allow_access = 0)
+        except Exception, ex:
+            raise XendError(str(ex))
+
 
 def instance():
     """Singleton constructor. Use this instead of the class constructor.
diff -r 3acad8d6d0cf -r e2b5c74938f6 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py	Sun Nov  6 01:15:12 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py	Sun Nov  6 01:15:44 2005
@@ -1400,9 +1400,10 @@
     controllerClasses[device_class] = cls
 
 
-from xen.xend.server import blkif, netif, tpmif, pciif, usbif
+from xen.xend.server import blkif, netif, tpmif, pciif, iopif, usbif
 addControllerClass('vbd',  blkif.BlkifController)
 addControllerClass('vif',  netif.NetifController)
 addControllerClass('vtpm', tpmif.TPMifController)
 addControllerClass('pci',  pciif.PciController)
+addControllerClass('ioports', iopif.IOPortsController)
 addControllerClass('usb',  usbif.UsbifController)
diff -r 3acad8d6d0cf -r e2b5c74938f6 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py	Sun Nov  6 01:15:12 2005
+++ b/tools/python/xen/xm/create.py	Sun Nov  6 01:15:44 2005
@@ -241,6 +241,12 @@
          For example '-pci c0,02,1a'.
          The option may be repeated to add more than one pci device.""")
 
+gopts.var('ioports', val='FROM[-TO]',
+          fn=append_value, default=[],
+          use="""Add a legacy I/O range to a domain, using given params (in hex).
+         For example '-ioports 02f8-02ff'.
+         The option may be repeated to add more than one i/o range.""")
+
 gopts.var('usb', val='PATH',
           fn=append_value, default=[],
           use="""Add a physical USB port to a domain, as specified by the path
@@ -438,6 +444,13 @@
     for (bus, dev, func) in vals.pci:
         config_pci = ['pci', ['bus', bus], ['dev', dev], ['func', func]]
         config_devs.append(['device', config_pci])
+
+def configure_ioports(config_devs, vals):
+    """Create the config for legacy i/o ranges.
+    """
+    for (io_from, io_to) in vals.ioports:
+        config_ioports = ['ioports', ['from', io_from], ['to', io_to]]
+        config_devs.append(['device', config_ioports])
 
 def configure_usb(config_devs, vals):
     for path in vals.usb:
@@ -611,6 +624,7 @@
     config_devs = []
     configure_disks(config_devs, vals)
     configure_pci(config_devs, vals)
+    configure_ioports(config_devs, vals)
     configure_vifs(config_devs, vals)
     configure_usb(config_devs, vals)
     configure_vtpm(config_devs, vals)
@@ -645,6 +659,20 @@
         pci.append(hexd)
     vals.pci = pci
 
+def preprocess_ioports(vals):
+    if not vals.ioports: return
+    ioports = []
+    for v in vals.ioports:
+        d = v.split('-')
+        if len(d) < 1 || len(d) > 2:
+            err('Invalid i/o port range specifier: ' + v)
+        if len(d) == 1:
+            d.append(d[0])
+        # Components are in hex: add hex specifier.
+        hexd = map(lambda v: '0x'+v, d)
+        ioports.append(hexd)
+    vals.ioports = ioports
+        
 def preprocess_vifs(vals):
     if not vals.vif: return
     vifs = []
@@ -777,6 +805,7 @@
         err("No kernel specified")
     preprocess_disk(vals)
     preprocess_pci(vals)
+    preprocess_ioports(vals)
     preprocess_vifs(vals)
     preprocess_ip(vals)
     preprocess_nfs(vals)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  parent reply	other threads:[~2005-11-06  1:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-06  1:40 [PATCH 0/4] fleshing out the ioport support lists-xen
2005-11-06  1:43 ` [PATCH 1/4] ioports: disable ioports in dom0 at boot-time lists-xen
2005-11-06  1:44 ` [PATCH 2/4] ioports: libxc support lists-xen
2005-11-06  1:45 ` [PATCH 3/4] ioports: xen.lowlevel.xc support lists-xen
2005-11-06  1:46 ` lists-xen [this message]
2005-11-06 20:09 ` [PATCH 5/4] ioports: iopif.py missing from last patch Jody Belka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051106014631.GD12698@pimb.org \
    --to=lists-xen@pimb.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.