ia64/xen-unstable

changeset 19618:780041c4a96d

xend: Fix xm pci commands for inactive managed domains.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 19 02:23:32 2009 +0100 (2009-05-19)
parents 62ec6aae4ba9
children 303793468225
files tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue May 19 02:18:48 2009 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue May 19 02:23:32 2009 +0100
     1.3 @@ -621,9 +621,13 @@ class XendDomainInfo:
     1.4              pci_conf = self.info['devices'][dev_uuid][1]
     1.5              pci_devs = pci_conf['devs']
     1.6              for x in pci_devs:
     1.7 -                if (int(x['vslot'], 16) == int(new_dev['vslot'], 16) and
     1.8 -                   int(x['vslot'], 16) != AUTO_PHP_SLOT):
     1.9 -                    raise VmError("vslot %s already have a device." % (new_dev['vslot']))
    1.10 +                if x.has_key('vslot'):
    1.11 +                    x_vslot = x['vslot']
    1.12 +                else:
    1.13 +                    x_vslot = x['requested_vslot']
    1.14 +                if (int(x_vslot, 16) == int(new_dev['requested_vslot'], 16) and
    1.15 +                   int(x_vslot, 16) != AUTO_PHP_SLOT):
    1.16 +                    raise VmError("vslot %s already have a device." % (new_dev['requested_vslot']))
    1.17  
    1.18                  if (int(x['domain'], 16) == int(new_dev['domain'], 16) and
    1.19                     int(x['bus'], 16)    == int(new_dev['bus'], 16) and
    1.20 @@ -710,14 +714,14 @@ class XendDomainInfo:
    1.21                  new_dev['bus'],
    1.22                  new_dev['slot'],
    1.23                  new_dev['func'],
    1.24 -                new_dev['vslot'],
    1.25 +                new_dev['requested_vslot'],
    1.26                  opts)
    1.27              self.image.signalDeviceModel('pci-ins', 'pci-inserted', bdf_str)
    1.28  
    1.29              vslot = xstransact.Read("/local/domain/0/device-model/%i/parameter"
    1.30                                      % self.getDomid())
    1.31          else:
    1.32 -            vslot = new_dev['vslot']
    1.33 +            vslot = new_dev['requested_vslot']
    1.34  
    1.35          return vslot
    1.36  
    1.37 @@ -815,7 +819,10 @@ class XendDomainInfo:
    1.38                           int(x['bus'], 16) == int(dev['bus'], 16) and
    1.39                           int(x['slot'], 16) == int(dev['slot'], 16) and
    1.40                           int(x['func'], 16) == int(dev['func'], 16) ):
    1.41 -                        vslot = x['vslot']
    1.42 +                        if x.has_key('vslot'):
    1.43 +                            vslot = x['vslot']
    1.44 +                        else:
    1.45 +                            vslot = x['requested_vslot']
    1.46                          break
    1.47                  if vslot == AUTO_PHP_SLOT_STR:
    1.48                      raise VmError("Device %04x:%02x:%02x.%01x is not connected"
    1.49 @@ -1112,7 +1119,11 @@ class XendDomainInfo:
    1.50          #find the pass-through device with the virtual slot
    1.51          devnum = 0
    1.52          for x in pci_conf['devs']:
    1.53 -            if int(x['vslot'], 16) == vslot:
    1.54 +            if x.has_key('vslot'):
    1.55 +                x_vslot = x['vslot']
    1.56 +            else:
    1.57 +                x_vslot = x['requested_vslot']
    1.58 +            if int(x_vslot, 16) == vslot:
    1.59                  break
    1.60              devnum += 1
    1.61  
     2.1 --- a/tools/python/xen/xm/main.py	Tue May 19 02:18:48 2009 +0100
     2.2 +++ b/tools/python/xen/xm/main.py	Tue May 19 02:23:32 2009 +0100
     2.3 @@ -2165,13 +2165,27 @@ def xm_pci_list(args):
     2.4      if len(devs) == 0:
     2.5          return
     2.6  
     2.7 -    has_vslot = devs[0].has_key('vslot')
     2.8 +    has_vslot = False
     2.9 +    for x in devs:
    2.10 +        if x.has_key('vslot'):
    2.11 +            if x['vslot'] == "0x%s" % AUTO_PHP_SLOT_STR:
    2.12 +                x['vslot'] = '-'
    2.13 +            else:
    2.14 +                has_vslot = True
    2.15 +        elif not x.has_key('requested_vslot'):
    2.16 +            x['vslot'] = '-'
    2.17 +        elif x['requested_vslot'] == "0x%s" % AUTO_PHP_SLOT_STR:
    2.18 +            x['vslot'] = '-'
    2.19 +        else:
    2.20 +            has_vslot = True
    2.21 +            x['vslot'] = x['requested_vslot']
    2.22 +
    2.23      if has_vslot:
    2.24          hdr_str = 'VSlt domain   bus   slot   func'
    2.25 -        fmt_str =  "%(vslot)-3s    %(domain)-3s  %(bus)-3s   %(slot)-3s    %(func)-3s    "
    2.26 +        fmt_str =  "%(vslot)-4s %(domain)-6s   %(bus)-4s  %(slot)-4s   %(func)-3s    "
    2.27      else:
    2.28          hdr_str = 'domain   bus   slot   func'
    2.29 -        fmt_str =  "%(domain)-3s  %(bus)-3s   %(slot)-3s    %(func)-3s    "
    2.30 +        fmt_str =  "%(domain)-6s   %(bus)-4s  %(slot)-4s   %(func)-3s    "
    2.31      hdr = 0
    2.32  
    2.33      for x in devs:
    2.34 @@ -2457,7 +2471,7 @@ def parse_pci_configuration(args, state,
    2.35                  ['bus', '0x'+ pci_dev_info['bus']],
    2.36                  ['slot', '0x'+ pci_dev_info['slot']],
    2.37                  ['func', '0x'+ pci_dev_info['func']],
    2.38 -                ['vslot', '0x%x' % int(vslot, 16)]]
    2.39 +                ['requested_vslot', '0x%x' % int(vslot, 16)]]
    2.40          if len(opts) > 0:
    2.41              pci_bdf.append(['opts', opts])
    2.42          pci.append(pci_bdf)