Change in vdsm[master]: hostdev: don't send address type for source address

mpolednik at redhat.com mpolednik at redhat.com
Thu Jul 30 10:26:26 UTC 2015


Martin Polednik has uploaded a new change for review.

Change subject: hostdev: don't send address type for source address
......................................................................

hostdev: don't send address type for source address

Libvirt (domain_conf.c) does not expect the type for the host address,
and drops it if we send it. This causes USB address matching to fail
when parsing dom XML.

Same applies for SR-IOV, the example in libvirt documentation states
the type but it is again dropped.

Change-Id: I12592dd53f8af25fe8e1312b810e6b6f48411083
Signed-off-by: Martin Polednik <mpolednik at redhat.com>
---
M tests/hostdevTests.py
M vdsm/virt/vmdevices/hostdevice.py
2 files changed, 18 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/77/44177/1

diff --git a/tests/hostdevTests.py b/tests/hostdevTests.py
index febce55..ae0809b 100644
--- a/tests/hostdevTests.py
+++ b/tests/hostdevTests.py
@@ -44,8 +44,7 @@
     '''
     <hostdev managed="no" mode="subsystem" type="pci">
             <source>
-                    <address bus="0" domain="0" function="0" slot="2"
-                    type="pci"/>
+                    <address bus="0" domain="0" function="0" slot="2"/>
             </source>
             %s
     </hostdev>
@@ -54,8 +53,7 @@
     '''
     <hostdev managed="no" mode="subsystem" type="pci">
             <source>
-                    <address bus="0" domain="0" function="0" slot="25"
-                    type="pci"/>
+                    <address bus="0" domain="0" function="0" slot="25"/>
             </source>
             %s
     </hostdev>
@@ -64,8 +62,7 @@
     '''
     <hostdev managed="no" mode="subsystem" type="pci">
             <source>
-                    <address bus="0" domain="0" function="0" slot="26"
-                    type="pci"/>
+                    <address bus="0" domain="0" function="0" slot="26"/>
             </source>
             %s
     </hostdev>
@@ -74,8 +71,7 @@
     '''
     <hostdev managed="no" mode="subsystem" type="pci">
             <source>
-                    <address bus="0" domain="0" function="0" slot="27"
-                    type="pci"/>
+                    <address bus="0" domain="0" function="0" slot="27"/>
             </source>
             %s
     </hostdev>
@@ -84,8 +80,7 @@
     '''
     <hostdev managed="no" mode="subsystem" type="pci">
             <source>
-                    <address bus="0" domain="0" function="2" slot="31"
-                    type="pci"/>
+                    <address bus="0" domain="0" function="2" slot="31"/>
             </source>
             %s
     </hostdev>
@@ -94,7 +89,7 @@
     '''
     <hostdev managed="no" mode="subsystem" type="usb">
             <source>
-                    <address bus="1" device="2" type="usb"/>
+                    <address bus="1" device="2"/>
             </source>
             %s
     </hostdev>
@@ -103,7 +98,7 @@
     '''
     <hostdev managed="no" mode="subsystem" type="usb">
             <source>
-                    <address bus="1" device="10" type="usb"/>
+                    <address bus="1" device="10"/>
             </source>
             %s
     </hostdev>
@@ -112,7 +107,7 @@
     '''
     <hostdev managed="no" mode="subsystem" type="usb">
             <source>
-                    <address bus="1" device="1" type="usb"/>
+                    <address bus="1" device="1"/>
             </source>
             %s
     </hostdev>
@@ -122,8 +117,7 @@
     <interface managed="no" type="hostdev">
             <driver name="vfio"/>
             <source>
-                    <address bus="5" domain="0" function="7" slot="16"
-                    type="pci"/>
+                    <address bus="5" domain="0" function="7" slot="16"/>
             </source>
             <mac address="ff:ff:ff:ff:ff:ff"/>
             <vlan>
diff --git a/vdsm/virt/vmdevices/hostdevice.py b/vdsm/virt/vmdevices/hostdevice.py
index 976a66b..453dc1d 100644
--- a/vdsm/virt/vmdevices/hostdevice.py
+++ b/vdsm/virt/vmdevices/hostdevice.py
@@ -36,9 +36,7 @@
 
         self.macAddr = self.specParams.get('macAddr')
         self.vlanId = self.specParams.get('vlanId')
-        self.hostAddress = self._update_address(
-            self._deviceParams.get('address')
-        )
+        self.hostAddress = self._deviceParams.get('address')
 
     @property
     def address(self):
@@ -54,9 +52,13 @@
         by mutating the address. The address is then returned for convenience.
         '''
         if 'type' not in address:
-            address['type'] = CAPABILITY_TO_XML_ATTR[
-                self._deviceParams['capability']
-            ]
+            try:
+                address['type'] = CAPABILITY_TO_XML_ATTR[
+                    self._deviceParams['capability']]
+            except AttributeError:
+                # _deviceParams may not be yet exist when accessing the
+                # address, in that case we leave it untouched
+                pass
 
         return address
 
@@ -66,7 +68,6 @@
         called before getXML in order to populate _deviceParams.
         """
         self._deviceParams = detach_detachable(self.device)
-        self.hostAddress = self._update_address(self.hostAddress)
 
     def getXML(self):
         if any((self.macAddr, self.vlanId)):
@@ -120,7 +121,7 @@
          <interface type='hostdev' managed='no'>
           <driver name='vfio'/>
           <source>
-           <address type='pci' domain='0x0000' bus='0x00' slot='0x07'
+           <address domain='0x0000' bus='0x00' slot='0x07'
            function='0x0'/>
           </source>
           <mac address='52:54:00:6d:90:02'/>


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I12592dd53f8af25fe8e1312b810e6b6f48411083
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>


More information about the vdsm-patches mailing list