[Kimchi-devel] [PATCH] [Kimchi 1/2] Add multi-function field in PCI information
Rodrigo Trujillo
rodrigo.trujillo at linux.vnet.ibm.com
Thu Dec 10 12:17:04 UTC 2015
Hey Paulo, I believe this is a minor issue and does not impact the code.
Reviewed-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
On 12/08/2015 04:21 PM, Paulo Ricardo Paz Vital wrote:
> On 12/08/2015 11:52 AM, Jose Ricardo Ziviani wrote:
>> - This commit adds a new field in the PCI device data structure to
>> notify the client that such PCI is a multi-function device. The
>> goal is to make it easy to identify whether a given device is
>> multi-function or not in the client side.
>>
>> Signed-off-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
>> ---
>> model/host.py | 27 ++++++++++++++++++++++++++-
>> model/vmhostdevs.py | 3 ++-
>> 2 files changed, 28 insertions(+), 2 deletions(-)
>>
>> diff --git a/model/host.py b/model/host.py
>> index 628ae71..72d7d0e 100644
>> --- a/model/host.py
>> +++ b/model/host.py
>> @@ -18,6 +18,7 @@
>> # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>>
>> import libvirt
>> +from collections import defaultdict
>> from lxml import objectify
>>
>> from wok.exception import InvalidParameter
>> @@ -144,6 +145,21 @@ class DevicesModel(object):
>> class DeviceModel(object):
>> def __init__(self, **kargs):
>> self.conn = kargs['conn']
>> + self.iommu_groups = self._get_iommu_groups()
>> +
>> + def _get_iommu_groups(self):
>> + iommu_groups = defaultdict(list)
>> + conn = self.conn.get()
>> +
>> + devices = DevicesModel(conn=self.conn).get_list()
> Why not use 'conn=self.conn' in the first line and use only conn object,
> instead of 'conn=self.conn'? Then you can use conn.get().nodeDevice...
> in the below line also.
>
>> + for device in devices:
>> + info = hostdev.get_dev_info(conn.nodeDeviceLookupByName(device))
>> + if 'iommuGroup' not in info:
>> + continue
>> + iommu_group_nr = int(info['iommuGroup'])
>> + iommu_groups[iommu_group_nr].append(device)
>> +
>> + return iommu_groups
>>
>> def lookup(self, nodedev_name):
>> conn = self.conn.get()
>> @@ -151,7 +167,16 @@ class DeviceModel(object):
>> dev = conn.nodeDeviceLookupByName(nodedev_name)
>> except:
>> raise NotFoundError('KCHHOST0003E', {'name': nodedev_name})
>> - return hostdev.get_dev_info(dev)
>> +
>> + info = hostdev.get_dev_info(dev)
>> + info['multifunction'] = self.is_multifunction_pci(info)
>> + return info
>> +
>> + def is_multifunction_pci(self, info):
>> + if 'iommuGroup' not in info:
>> + return False
>> + iommu_group_nr = int(info['iommuGroup'])
>> + return len(self.iommu_groups[iommu_group_nr]) > 1
>>
>> @staticmethod
>> def _toint(num_str):
>> diff --git a/model/vmhostdevs.py b/model/vmhostdevs.py
>> index c4fb815..de52cd8 100644
>> --- a/model/vmhostdevs.py
>> +++ b/model/vmhostdevs.py
>> @@ -279,7 +279,8 @@ class VMHostDevModel(object):
>> return {'name': dev_name,
>> 'type': e.attrib['type'],
>> 'product': dev_info.get('product', None),
>> - 'vendor': dev_info.get('vendor', None)}
>> + 'vendor': dev_info.get('vendor', None),
>> + 'multifunction': dev_info.get('multifunction', None)}
>>
>> raise NotFoundError('KCHVMHDEV0001E',
>> {'vmid': vmid, 'dev_name': dev_name})
>>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>
More information about the Kimchi-devel
mailing list