[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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
function:

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

Thanks,
Cole


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]