ia64/xen-unstable

changeset 19719:728eb34bbfcc

xm, xend: xen-api: DPCI.get_hotplug_slot() returns a decimal

xm uses the following code to read pci information using Xen API:

ppci_ref =3D server.xenapi.DPCI.get_PPCI(dpci_ref)
ppci_record =3D server.xenapi.PPCI.get_record(ppci_ref)
dev =3D {
"domain": int(ppci_record["domain"]),
"bus": int(ppci_record["bus"]),
"slot": int(ppci_record["slot"]),
"func": int(ppci_record["func"]),
"vslot": int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref))
}

As the domain, bus, slot and func values are returned as string
representations of decimal, it makes sense for get_hotplug_slot() to
also return string representations of decimal.

As it is, the int() conversion will break cause xm to fail with
an error if the vslot is in the range 0xa-0xf or 0x1a-0x1f.

$ xm pci-list debian
Error: Invalid argument.

And the int() conversion will return the wrong value if
the vslot is in the range 0x10-0x19.

This patch also alters XendDPCI to store hotplug_vslot as an integer
rather than a string. This is consitent with the way other
values are stored inside XendDPCI.

get_hotplug_slot() returning a string is not consistent
with other calls inside XendDPCI, which return integers.

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 04 10:40:24 2009 +0100 (2009-06-04)
parents 19fc31fe2e31
children 8f64f43624e8
files tools/python/xen/xend/XendDPCI.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDPCI.py	Thu Jun 04 10:39:32 2009 +0100
     1.2 +++ b/tools/python/xen/xend/XendDPCI.py	Thu Jun 04 10:40:24 2009 +0100
     1.3 @@ -119,7 +119,7 @@ class XendDPCI(XendBase):
     1.4  
     1.5          self.VM = record['VM']
     1.6          self.PPCI = record['PPCI']
     1.7 -        self.hotplug_slot = record['hotplug_slot']
     1.8 +        self.hotplug_slot = int(record['hotplug_slot'], 16)
     1.9          if 'options' in record.keys():
    1.10              self.options = record['options']
    1.11  
    1.12 @@ -153,7 +153,7 @@ class XendDPCI(XendBase):
    1.13          return self.PPCI
    1.14  
    1.15      def get_hotplug_slot(self):
    1.16 -        return self.hotplug_slot
    1.17 +        return "%d" % self.hotplug_slot
    1.18  
    1.19      def get_options(self):
    1.20          return self.options