Cui, Dexuan
2009-Jun-17 11:02 UTC
[Xen-devel] [PATCH] xend: pci: find_parent: should return string rather than int
Using changeset 19783: 61ec78692b13, device assignment can't work: e.g., in find_the_uppermost_pci_bridge(), parent = dev_parent.find_parent() ... dev_parent = PciDevice(parent), we can see parent['domain'] is int and in PciDevice's __init__, int(dev['domain'], 16) would fail: TypeError: int() can't convert non-string with explicit base The patch fixes the issue. Signed-off-by: Dexuan Cui <dexuan.cui@intel.com> diff -r 61ec78692b13 tools/python/xen/util/pci.py --- a/tools/python/xen/util/pci.py Wed Jun 17 07:39:27 2009 +0100 +++ b/tools/python/xen/util/pci.py Wed Jun 17 18:35:31 2009 +0800 @@ -547,12 +547,12 @@ class PciDevice: else: dev = {} lst = parent.split(':') - dev['domain'] = int(lst[0], 16) - dev['bus'] = int(lst[1], 16) + dev['domain'] = '%04x' % int(lst[0], 16) + dev['bus'] = '%02x' % int(lst[1], 16) lst = lst[2] lst = lst.split('.') - dev['slot'] = int(lst[0], 16) - dev['func'] = int(lst[1], 16) + dev['slot'] = '%02x' % int(lst[0], 16) + dev['func'] = '%x' % int(lst[1], 16) return dev except OSError, (errno, strerr): raise PciDeviceParseError('Can not locate the parent of %s', _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-17 11:31 UTC
[Xen-devel] Re: [PATCH] xend: pci: find_parent: should return string rather than int
On Wed, Jun 17, 2009 at 07:02:27PM +0800, Cui, Dexuan wrote:> Using changeset 19783: 61ec78692b13, device assignment can''t work: > e.g., in find_the_uppermost_pci_bridge(), > parent = dev_parent.find_parent() > ... > dev_parent = PciDevice(parent), > we can see parent[''domain''] is int and in PciDevice''s __init__, int(dev[''domain''], 16) would fail: > TypeError: int() can''t convert non-string with explicit base > > The patch fixes the issue.Hi Dexuan, sorry about that. The fix looks good to me. Could you tell me a bit about what config/command you ran to produce this problem? I''d like to add something to the tests that I run. Acked-by: Simon Horman <horms@verge.net.au>> > diff -r 61ec78692b13 tools/python/xen/util/pci.py > --- a/tools/python/xen/util/pci.py Wed Jun 17 07:39:27 2009 +0100 > +++ b/tools/python/xen/util/pci.py Wed Jun 17 18:35:31 2009 +0800 > @@ -547,12 +547,12 @@ class PciDevice: > else: > dev = {} > lst = parent.split('':'') > - dev[''domain''] = int(lst[0], 16) > - dev[''bus''] = int(lst[1], 16) > + dev[''domain''] = ''%04x'' % int(lst[0], 16) > + dev[''bus''] = ''%02x'' % int(lst[1], 16) > lst = lst[2] > lst = lst.split(''.'') > - dev[''slot''] = int(lst[0], 16) > - dev[''func''] = int(lst[1], 16) > + dev[''slot''] = ''%02x'' % int(lst[0], 16) > + dev[''func''] = ''%x'' % int(lst[1], 16) > return dev > except OSError, (errno, strerr): > raise PciDeviceParseError(''Can not locate the parent of %s'',_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Cui, Dexuan
2009-Jun-17 11:40 UTC
[Xen-devel] RE: [PATCH] xend: pci: find_parent: should return string rather than int
Hi Simon, Attached is my host info of ''lspci''. I pciback.hide 01:00.0 and 00:1b.0 and when I tried to statically assign 01:00.0 to guest, I got the " TypeError: int() can''t convert non-string with explicit base". Thanks, -- Dexuan -----Original Message----- From: Simon Horman [mailto:horms@verge.net.au] Sent: 2009?6?17? 19:31 To: Cui, Dexuan Cc: Keir Fraser; xen-devel@lists.xensource.com Subject: Re: [PATCH] xend: pci: find_parent: should return string rather than int On Wed, Jun 17, 2009 at 07:02:27PM +0800, Cui, Dexuan wrote:> Using changeset 19783: 61ec78692b13, device assignment can''t work: > e.g., in find_the_uppermost_pci_bridge(), > parent = dev_parent.find_parent() > ... > dev_parent = PciDevice(parent), > we can see parent[''domain''] is int and in PciDevice''s __init__, int(dev[''domain''], 16) would fail: > TypeError: int() can''t convert non-string with explicit base > > The patch fixes the issue.Hi Dexuan, sorry about that. The fix looks good to me. Could you tell me a bit about what config/command you ran to produce this problem? I''d like to add something to the tests that I run. Acked-by: Simon Horman <horms@verge.net.au>> > diff -r 61ec78692b13 tools/python/xen/util/pci.py > --- a/tools/python/xen/util/pci.py Wed Jun 17 07:39:27 2009 +0100 > +++ b/tools/python/xen/util/pci.py Wed Jun 17 18:35:31 2009 +0800 > @@ -547,12 +547,12 @@ class PciDevice: > else: > dev = {} > lst = parent.split('':'') > - dev[''domain''] = int(lst[0], 16) > - dev[''bus''] = int(lst[1], 16) > + dev[''domain''] = ''%04x'' % int(lst[0], 16) > + dev[''bus''] = ''%02x'' % int(lst[1], 16) > lst = lst[2] > lst = lst.split(''.'') > - dev[''slot''] = int(lst[0], 16) > - dev[''func''] = int(lst[1], 16) > + dev[''slot''] = ''%02x'' % int(lst[0], 16) > + dev[''func''] = ''%x'' % int(lst[1], 16) > return dev > except OSError, (errno, strerr): > raise PciDeviceParseError(''Can not locate the parent of %s'',_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-17 12:07 UTC
[Xen-devel] Re: [PATCH] xend: pci: find_parent: should return string rather than int
On Wed, Jun 17, 2009 at 07:40:47PM +0800, Cui, Dexuan wrote:> Hi Simon, > Attached is my host info of ''lspci''. > I pciback.hide 01:00.0 and 00:1b.0 and when I tried to statically assign 01:00.0 to guest, I got the " TypeError: int() can''t convert non-string with explicit base".Interesting. That is pretty similar to a test I run, but I didn''t see this particular problem. I''ll investigate further tomorrow. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel