xm, xend: passthrough: Add assigned_or_requested_vslot()

Add an accessor to simplify accessing vslot if available,
otherwise requested_vslot.

Signed-off-by: Simon Horman <horms@verge.net.au>
This commit is contained in:
Keir Fraser committed 2009-05-26 10:04:10 +01:00
1 parent b562a316db
commit e25dc9429b
4 files changed
+25 -27

No files matched your search

+13 -1
View File
@@ -138,7 +138,13 @@ def parse_pci_name(pci_name_string):
func = parse_hex(pci_dev_info['func'])
return (domain, bus, slot, func)
def assigned_or_requested_vslot(dev):
if dev.has_key("vslot"):
return dev["vslot"]
if dev.has_key("requested_vslot"):
return dev["requested_vslot"]
raise PciDeviceVslotMissing("%s" % dev)
def find_sysfs_mnt():
try:
@@ -355,6 +361,12 @@ class PciDeviceAssignmentError(Exception):
return 'pci: impproper device assignment spcified: ' + \
self.message
class PciDeviceVslotMissing(Exception):
def __init__(self,msg):
self.message = msg
def __str__(self):
return 'pci: no vslot or requested_vslot: ' + self.message
class PciDevice:
def __init__(self, domain, bus, slot, func):
self.domain = domain
+4 -12
View File
@@ -38,6 +38,7 @@ from xen.util import asserts, auxbin
from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype
import xen.util.xsm.xsm as security
from xen.util import xsconstants
from xen.util.pci import assigned_or_requested_vslot
from xen.xend import balloon, sxp, uuid, image, arch
from xen.xend import XendOptions, XendNode, XendConfig
@@ -621,10 +622,7 @@ class XendDomainInfo:
pci_conf = self.info['devices'][dev_uuid][1]
pci_devs = pci_conf['devs']
for x in pci_devs:
if x.has_key('vslot'):
x_vslot = x['vslot']
else:
x_vslot = x['requested_vslot']
x_vslot = assigned_or_requested_vslot(x)
if (int(x_vslot, 16) == int(new_dev['requested_vslot'], 16) and
int(x_vslot, 16) != AUTO_PHP_SLOT):
raise VmError("vslot %s already have a device." % (new_dev['requested_vslot']))
@@ -819,10 +817,7 @@ class XendDomainInfo:
int(x['bus'], 16) == int(dev['bus'], 16) and
int(x['slot'], 16) == int(dev['slot'], 16) and
int(x['func'], 16) == int(dev['func'], 16) ):
if x.has_key('vslot'):
vslot = x['vslot']
else:
vslot = x['requested_vslot']
vslot = assigned_or_requested_vslot(x)
break
if vslot == AUTO_PHP_SLOT_STR:
raise VmError("Device %04x:%02x:%02x.%01x is not connected"
@@ -1119,10 +1114,7 @@ class XendDomainInfo:
#find the pass-through device with the virtual slot
devnum = 0
for x in pci_conf['devs']:
if x.has_key('vslot'):
x_vslot = x['vslot']
else:
x_vslot = x['requested_vslot']
x_vslot = assigned_or_requested_vslot(x)
if int(x_vslot, 16) == vslot:
break
devnum += 1
+5 -5
View File
@@ -71,15 +71,15 @@ class PciController(DevController):
pcidevid = 0
vslots = ""
for pci_config in config.get('devs', []):
vslot = pci_config.get('vslot')
if vslot is not None:
vslots = vslots + vslot + ";"
attached_vslot = pci_config.get('vslot')
if attached_vslot is not None:
vslots = vslots + attached_vslot + ";"
domain = parse_hex(pci_config.get('domain', 0))
bus = parse_hex(pci_config.get('bus', 0))
slot = parse_hex(pci_config.get('slot', 0))
func = parse_hex(pci_config.get('func', 0))
requested_vslot = parse_hex(pci_config.get('requested_vslot', 0))
vslot = parse_hex(assigned_or_requested_vslot(pci_config))
opts = pci_config.get('opts', '')
if len(opts) > 0:
@@ -90,7 +90,7 @@ class PciController(DevController):
back['dev-%i' % pcidevid] = "%04x:%02x:%02x.%01x" % \
(domain, bus, slot, func)
back['uuid-%i' % pcidevid] = pci_config.get('uuid', '')
back['vslot-%i' % pcidevid] = "%02x" % requested_vslot
back['vslot-%i' % pcidevid] = "%02x" % vslot
pcidevid += 1
if vslots != "":
+3 -9
View File
@@ -2168,18 +2168,12 @@ def xm_pci_list(args):
has_vslot = False
for x in devs:
if x.has_key('vslot'):
if x['vslot'] == "0x%s" % AUTO_PHP_SLOT_STR:
x['vslot'] = '-'
else:
has_vslot = True
elif not x.has_key('requested_vslot'):
x['vslot'] = '-'
elif x['requested_vslot'] == "0x%s" % AUTO_PHP_SLOT_STR:
vslot = assigned_or_requested_vslot(x)
if int(vslot, 16) == AUTO_PHP_SLOT:
x['vslot'] = '-'
else:
x['vslot'] = vslot
has_vslot = True
x['vslot'] = x['requested_vslot']
if has_vslot:
hdr_str = 'VSlt domain bus slot func'
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.