ia64/xen-unstable

changeset 19314:20a2e3f724d5

xm: Sort pvSCSI devices information by virtual HCTL

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Mar 11 10:13:46 2009 +0000 (2009-03-11)
parents cfacba42091c
children 57a67b02e448
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Wed Mar 11 10:12:14 2009 +0000
     1.2 +++ b/tools/python/xen/xm/main.py	Wed Mar 11 10:13:46 2009 +0000
     1.3 @@ -2231,6 +2231,33 @@ def xm_pci_list_assignable_devices(args)
     1.4              print d.name,
     1.5          print
     1.6  
     1.7 +def vscsi_sort(devs):
     1.8 +    def sort_hctl(ds, l):
     1.9 +        s = []
    1.10 +        for d1 in ds:
    1.11 +            for d2 in d1:
    1.12 +                v_dev = sxp.child_value(d2, 'v-dev')
    1.13 +                n = int(v_dev.split(':')[l])
    1.14 +                try:
    1.15 +                    j = s[n]
    1.16 +                except IndexError:
    1.17 +                    j = []
    1.18 +                    s.extend([ [] for _ in range(len(s), n+1) ])
    1.19 +                j.append(d2)
    1.20 +                s[n] = j
    1.21 +        return s
    1.22 +
    1.23 +    for i in range(len(devs)):
    1.24 +        ds1 = [ devs[i][1][0][1] ]
    1.25 +        ds1 = sort_hctl(ds1, 3)
    1.26 +        ds1 = sort_hctl(ds1, 2)
    1.27 +        ds1 = sort_hctl(ds1, 1)
    1.28 +        ds2 = []
    1.29 +        for d in ds1:
    1.30 +            ds2.extend(d)
    1.31 +        devs[i][1][0][1] = ds2
    1.32 +    return devs
    1.33 +
    1.34  def vscsi_convert_sxp_to_dict(dev_sxp):
    1.35      dev_dict = {}
    1.36      for opt_val in dev_sxp[1:]:
    1.37 @@ -2271,6 +2298,9 @@ def xm_scsi_list(args):
    1.38      else:
    1.39          devs = server.xend.domain.getDeviceSxprs(dom, 'vscsi')
    1.40  
    1.41 +    # Sort devs by virtual HCTL.
    1.42 +    devs = vscsi_sort(devs)
    1.43 +
    1.44      if use_long:
    1.45          map(PrettyPrint.prettyprint, devs)
    1.46      else: