[Kimchi-devel] [PATCH v2] [Kimchi 1/2] Add multi-function field in PCI information

Aline Manera alinefm at linux.vnet.ibm.com
Fri Dec 11 09:40:58 UTC 2015



On 10/12/2015 21:50, Jose Ricardo Ziviani wrote:
> Hi Aline,
>
> This param will be removed as soon as live PCI multi-function 
> attachment is fixed (in Libvirt or QEMU). This is something that I 
> don't expect anybody else to use it.. Do you still think API.md should 
> be updated with such param?
>

Yeap!

> Thanks
>
> On 10-12-2015 19:08, Aline Manera wrote:
>>
>> Hi Ziviani,
>>
>> You are changing the API with this patch by adding a new parameter
>> 'multifunction', so, please, add docs/API.md and anything else needed.
>>
>>
>> On 10/12/2015 15:03, 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       | 33 ++++++++++++++++++++++++++++++++-
>>>   model/vmhostdevs.py |  3 ++-
>>>   2 files changed, 34 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/model/host.py b/model/host.py
>>> index 628ae71..583accd 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,27 @@ 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
>>> +
>>> +        try:
>>> +            devices = DevicesModel(conn=conn).get_list()
>>> +
>>> +        except:
>>> +            return iommu_groups
>>> +
>>> +        for device in devices:
>>> +            info = hostdev.get_dev_info(
>>> +                conn.get().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 +173,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})
>>
>




More information about the Kimchi-devel mailing list