Change in vdsm[master]: network: support PCI passthrough of SR-IOV network interface...

ibarkan at redhat.com ibarkan at redhat.com
Sun Mar 1 10:34:04 UTC 2015


Ido Barkan has uploaded a new change for review.

Change subject: network: support PCI passthrough of SR-IOV network interfaces. Only SR-IOV (Single Root I/O Virtualization) virtual function (VF) devices can be assigned in this manner.
......................................................................

network: support PCI passthrough of SR-IOV network interfaces. Only SR-IOV
(Single Root I/O Virtualization) virtual function (VF) devices can be assigned
in this manner.

Change-Id: Ib962fbf1bb08cd5b82b649cc05612471e4e4d0b8
Signed-off-by: Ido Barkan <ibarkan at redhat.com>
---
M vdsm/virt/vmdevices/hostdevice.py
M vdsm/virt/vmdevices/hwclass.py
2 files changed, 46 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/38249/1

diff --git a/vdsm/virt/vmdevices/hostdevice.py b/vdsm/virt/vmdevices/hostdevice.py
index d61ef45..96e9adb 100644
--- a/vdsm/virt/vmdevices/hostdevice.py
+++ b/vdsm/virt/vmdevices/hostdevice.py
@@ -24,11 +24,12 @@
 
 
 class HostDevice(core.Base):
-    __slots__ = ('name', '_deviceParams')
+    __slots__ = ('name', '_deviceParams', '_mac_address')
 
     def __init__(self, conf, log, **kwargs):
         super(HostDevice, self).__init__(conf, log, **kwargs)
         self._deviceParams = {}
+        self._mac_address = kwargs.get('mac_address')
 
     def detach(self):
         """
@@ -38,28 +39,33 @@
         self._deviceParams = detach_detachable(self.name)
 
     def getXML(self):
-        """
-        Create domxml for a host device.
+        if self._mac_address:
+            return self._build_network_host_device()
+        else:
+            return self._build_standard_host_device()
 
-        <devices>
-            <hostdev mode='subsystem' type='pci' managed='yes'>
-            <source>
-                <address domain='0x0000' bus='0x06' slot='0x02' function='0x0'/>
-            </source>
-            <boot order='1'/>
-            <rom bar='on' file='/etc/fake/boot.bin'/>
-            </hostdev>
-        </devices>
+    def _build_standard_host_device(self):
         """
+            Create domxml for a host device.
+
+            <devices>
+                <hostdev mode='subsystem' type='pci' managed='yes'>
+                <source>
+                    <address domain='0x0000' bus='0x06' slot='0x02'
+                    function='0x0'/>
+                </source>
+                <boot order='1'/>
+                <rom bar='on' file='/etc/fake/boot.bin'/>
+                </hostdev>
+            </devices>
+            """
         hostdev = self.createXmlElem(hwclass.HOSTDEV, None)
         hostdev.setAttrs(managed='no', mode='subsystem',
                          type=self._deviceParams['capability'])
         source = hostdev.appendChildWithArgs('source')
-
         if 'bootOrder' in self.specParams:
             hostdev.appendChildWithArgs(
                 'boot', order=self.specParams['bootOrder'])
-
         if self._deviceParams['capability'] == 'pci':
             source.appendChildWithArgs('address', None,
                                        **self._deviceParams['address'])
@@ -75,5 +81,29 @@
                     romAttrs['file'] = self.specParams['file']
 
             rom.setAttrs(**romAttrs)
-
         return hostdev
+
+    def _build_network_host_device(self):
+        """
+        Create domxml for a host device.
+
+        <devices>
+         <interface type='hostdev' managed='no'>
+          <driver name='vfio'/>
+          <source>
+           <address type='pci' domain='0x0000' bus='0x00' slot='0x07'
+           function='0x0'/>
+          </source>
+          <mac address='52:54:00:6d:90:02'/>
+         </interface>
+        </devices>
+        """
+        interface = self.createXmlElem(hwclass.INTERFACE, hwclass.HOSTDEV)
+        interface.setAttrs(managed='no')
+        interface.appendChildWithArgs('driver', name='vfio')
+        source = interface.appendChildWithArgs('source')
+        source.appendChildWithArgs('address', **self._deviceParams['address'])
+        if self._mac_address:
+            interface.appendChildWithArgs('mac', address=self._mac_address)
+
+        return interface
diff --git a/vdsm/virt/vmdevices/hwclass.py b/vdsm/virt/vmdevices/hwclass.py
index 2a55ee8..afaba53 100644
--- a/vdsm/virt/vmdevices/hwclass.py
+++ b/vdsm/virt/vmdevices/hwclass.py
@@ -34,3 +34,4 @@
 SMARTCARD = 'smartcard'
 TPM = 'tpm'
 HOSTDEV = 'hostdev'
+INTERFACE = 'interface'


-- 
To view, visit https://gerrit.ovirt.org/38249
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib962fbf1bb08cd5b82b649cc05612471e4e4d0b8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <ibarkan at redhat.com>


More information about the vdsm-patches mailing list