[virt-tools-list] [PATCH] Virt-manager host device information bits

Cole Robinson crobinso at redhat.com
Tue Nov 3 18:15:33 UTC 2009

On 11/03/2009 12:58 PM, Michal Novotny wrote:
> On 11/03/2009 06:53 PM, Cole Robinson wrote:
>>> +        if not dev_pretty_name:
>>> +            # Try to get info from bus/addr
>>> +            for dev in devs:
>>> +                try:
>>> +                    dev_id = int(dev.device)
>> Rather than compare by 'int', just keep the
>> hostdevinfo[1]["address"]["device"] in string form and compare like that.
> Well, I was running into some issues ... when having the required 
> variables, it was clearly int() type... ie. `device` is a required 
> variable... but when accessing dev.device, I am getting eg. 0x0000 which 
> is hexadecimal so the comparison is not available because one is int() 
> and second is hex()...

Ah, I see what you mean. A PCI device can be indexed by hex strings in
the domain XML, but the node device XML will be int strings. My bad.

Since this is all repetitive code then, just make an internal helper

def intify(val):
        return int(val)
        return -1


More information about the virt-tools-list mailing list