[Kimchi-devel] [PATCH] Remove unecessary call to node_dev.parent()

Daniel Henrique Barboza dhbarboza82 at gmail.com
Fri Jul 17 20:13:52 UTC 2015


Reviewed-by: Daniel Barboza <dhbarboza82 at gmail.com>

On 07/17/2015 01:01 PM, Ramon Medeiros wrote:
> On hostdev.py, device parent was being search 2 times. First, a xml was
> parsed, where the parent device can be found. When device parent not
> present, calling the function .parent() (which is not necessary) will raise
> an error on libvirt. To avoid this, the call for .parent() was removed,
> and parent device is set as None if not present.
>
> Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
> ---
>   src/kimchi/model/hostdev.py | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/kimchi/model/hostdev.py b/src/kimchi/model/hostdev.py
> index 2a4a311..e898d77 100644
> --- a/src/kimchi/model/hostdev.py
> +++ b/src/kimchi/model/hostdev.py
> @@ -169,14 +169,15 @@ def get_dev_info(node_dev):
>       scsi_target is not documented in libvirt official website. Try to
>       parse scsi_target according to the libvirt commit db19834a0a.
>       '''
> -
>       xmlstr = node_dev.XMLDesc(0)
>       info = dictize(xmlstr)['device']
>       dev_type = info['capability'].pop('type')
>       info['device_type'] = dev_type
>       cap_dict = info.pop('capability')
>       info.update(cap_dict)
> -    info['parent'] = node_dev.parent()
> +
> +    # parent device not found: set as None
> +    info["parent"] = info.get("parent")
>   
>       if dev_type in ('scsi', 'scsi_generic', 'scsi_target', 'system', 'usb'):
>           return info




More information about the Kimchi-devel mailing list