Skip to contentSkip to conversation

add iomem feature to xm

PATCH In review Matthew Fioravante 1 participant 1 message Sep 18, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 6/6 add iomem feature to xm

This adds the iomem feature from patch 3 to xm as well.

Signed off by Matthew Fioravante [email protected]

(quoted diff) +0 -0

b/tools/python/xen/xend/XendDevices.py

tools/python/xen/xend/XendDevices.py +0 -1
@@ -19,7 +19,7 @@
 # A collection of DevControllers
 #
 
-from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif,

vfbif, vscsiif, netif2, vusbif
+from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, iomemif, vfbif, vscsiif, netif2, vusbif
from xen.xend.server.BlktapController import BlktapController,
Blktap2Controller
from xen.xend.server.ConsoleController import ConsoleController

@@ -42,6 +42,7 @@ class XendDevices:
'pci': pciif.PciController,
'ioports': iopif.IOPortsController,
'irq': irqif.IRQController,
+ 'iomem': iomemif.IOMEMController,
'tap': BlktapController,
'tap2': Blktap2Controller,
'vfb': vfbif.VfbifController,

(quoted diff) +0 -0

b/tools/python/xen/xend/server/iomemif.py

tools/python/xen/xend/server/iomemif.py new file +54 -0

54 lines not on this page · raw message

transaction)
+ if transaction is None:
+ devinfo = self.readBackend(devid, *self.valid_cfg)
+ else:
+ devinfo = self.readBackendTxn(transaction, devid,
*self.valid_cfg)
+ config = dict(zip(self.valid_cfg, devinfo))
+ config = dict([(key, val) for key, val in config.items()
+ if val != None])
+ return config
+
+ def getDeviceDetails(self, config):
+ """@see DevController.getDeviceDetails"""
+
+ def get_param(field):
+ try:
+ val = config.get(field)
+
+ if not val:
+ raise VmError('iomem: Missing %s config setting' %
field)
+
+ return parse_iomemaddr(val)
+ except:
+ raise VmError('iomem: Invalid config setting %s: %s' %
+ (field, val))
+

+        mfn = get_param('mfn')
+        nmfns = get_param('nmfns')
+        enable = get_param('enable')

+
+ if nmfns <= 0:
+ raise VmError('iomem: invalid number of mfns: %s' % str(nmfns))
+ #FIXME: Bounds check for max iomem range??
+
+ rc = xc.domain_iomem_permission(domid = self.getDomid(),
+ first_pfn = mfn,
+ nr_pfns = nmfns,
+ allow_access = enable)
+
+ if rc < 0:
+ #todo non-fatal
+ raise VmError(
+ 'iomem: Failed to configure memory mapped i/o range:
%s,%s' %
+ (str(mfn), str(nmfns)))
+
+ back = dict([(k, config[k]) for k in self.valid_cfg if k in
config])
+ return (self.allocateDeviceID(), back, {})
+
+ def waitForDevice(self, devid):
+ # don't wait for hotplug
+ return

tools/python/xen/xm/create.py +3 -0
@@ -378,6 +378,14 @@ gopts.var('irq', val='IRQ',
          For example 'irq=7'.
          This option may be repeated to add more than one IRQ.""")
 
+gopts.var('iomem', val='MFN,NMFNS,ENABLE',
+          fn=append_value, default=[],
+          use="""Allow access to memory mapped IO pages, using the

given params.
+ For example 'iomem=e4df0,5,1', to allow access to 5 pages starting
+ at page number 0xe4df0. The first arg is in hex, the second in
decimal.
+ The last argument is a 1 or 0, to either enable or disable the
memory region.
+ This option may be repeated to add more than one memory range""")
+
gopts.var('vfb',
val="vnc=1,sdl=1,vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY,vncpasswd=PASSWORD,opengl=1,keymap=FILE,serial=FILE,monitor=FILE",
fn=append_value, default=[],
use="""Make the domain a framebuffer backend.
@@ -947,6 +955,13 @@ def configure_irq(config_devs, vals):

         config_irq = ['irq', ['irq', irq]]
         config_devs.append(['device', config_irq])

+def configure_iomem(config_devs, vals):

+    """Create the config for iomem.
+    """
+    for (mfn, nmfns, enable) in vals.iomem:

+ config_iomem = ['iomem', ['mfn', mfn], ['nmfns', nmfns],
['enable', enable]]
+ config_devs.append(['device', config_iomem])
+
def configure_vfbs(config_devs, vals):
for f in vals.vfb:
d = comma_sep_kv_to_dict(f)
@@ -1191,6 +1206,7 @@ def make_config(vals):
configure_vscsis(config_devs, vals)
configure_vusbs(config_devs, vals)
configure_ioports(config_devs, vals)
+ configure_iomem(config_devs, vals)
configure_irq(config_devs, vals)
configure_vifs(config_devs, vals)
configure_vtpm(config_devs, vals)
@@ -1307,6 +1323,18 @@ def preprocess_irq(vals):
irq.append(d)
vals.irq = irq

+def preprocess_iomem(vals):

+    if not vals.iomem: return
+    iomem = []
+    for v in vals.iomem:
+        d = v.split(',')
+    if len(d) < 1 or len(d) > 3:
+       err('Invalid iomem range specifier: ' + v)
+    #Add hex specifier to the page number
+    d[0] = '0x' + d[0]
+    iomem.append(d)
+    vals.iomem = iomem

+
def preprocess_vtpm(vals):
if not vals.vtpm: return
vtpms = []
@@ -1398,6 +1426,7 @@ def preprocess(vals):
preprocess_pci(vals)
preprocess_vscsi(vals)
preprocess_ioports(vals)
+ preprocess_iomem(vals)
preprocess_ip(vals)
preprocess_irq(vals)
preprocess_nfs(vals)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel