[Kimchi-devel] [PATCH v11 2/6] Host device passthrough: List eligible device to passthrough
Zhou Zheng Sheng
zhshzhou at linux.vnet.ibm.com
Wed Oct 8 03:02:45 UTC 2014
on 2014/10/04 00:53, Aline Manera wrote:
>
> On 09/30/2014 07:00 AM, Zhou Zheng Sheng wrote:
>> +def _get_same_iommugroup_devices(dev_infos, device_info):
>> + dev_dict = dict([(dev_info['name'], dev_info) for dev_info in
>> dev_infos])
>> +
>> + def get_iommu_group(dev_info):
>> + # Find out the iommu group of a given device.
>> + # Child device belongs to the same iommu group as the parent
>> device.
>> + try:
>> + return dev_info['iommuGroup']
>> + except KeyError:
>> + pass
>> +
>> + parent = dev_info['parent']
>> + while parent is not None:
>> + try:
>> + parent_info = dev_dict[parent]
>> + except KeyError:
>> + kimchi_log.error("Parent %s of device %s does not
>> exist",
>> + parent, dev_info['name'])
>> + break
>> +
>> + try:
>> + iommuGroup = parent_info['iommuGroup']
>> + except KeyError:
>> + pass
>> + else:
>> + return iommuGroup
>> +
>> + parent = parent_info['parent']
>> +
>> + return -1
>> +
>
> minor comment: true/false (or None) is more like python
>
>> + iommu_group = get_iommu_group(device_info)
>> +
>> + if iommu_group == -1:
>> + return []
>> +
>> + return [dev_info for dev_info in dev_infos
>> + if dev_info['name'] != device_info['name'] and
>> + get_iommu_group(dev_info) == iommu_group]
>> +
>> +
Thank you Aline. This function was re-written several times. I should
have noticed this problem.
More information about the Kimchi-devel
mailing list