Martin Polednik has uploaded a new change for review.

Change subject: hostdev: properly detect attached scsi devices
......................................................................

hostdev: properly detect attached scsi devices

SCSI device is addressed by two fields: adapter, meaning the HBA
(scsi_host) and address on the adapter (bus, unit, target).

We tweak is_attached_to method to accurately address the device meant
for hotunplug by taking both fields into consideration and making sure
that no identical device is present.

This fixes scenario, where multiple LUNs exist on multiple adapters but
at the same address. In that case, hotplug would timeout even though it
succeeded.

Change-Id: I5aca2db8dfd73b431e1b7e9255121338ce0e44c1
Signed-off-by: Martin Polednik <mpoled...@redhat.com>
---
M vdsm/virt/vmdevices/hostdevice.py
1 file changed, 9 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/60601/1

diff --git a/vdsm/virt/vmdevices/hostdevice.py 
b/vdsm/virt/vmdevices/hostdevice.py
index 5f2af35..5f4c2b4 100644
--- a/vdsm/virt/vmdevices/hostdevice.py
+++ b/vdsm/virt/vmdevices/hostdevice.py
@@ -249,23 +249,21 @@
     def teardown(self):
         reattach_detachable(self.device)
 
-    @property
-    def _xpath(self):
-        """
-        Returns xpath to the device in libvirt dom xml.
-        The path is relative to the root element.
-        """
+    def is_attached_to(self, xml_string):
         address_fields = []
         for key, value in self.bus_address.items():
             address_fields.append('[@{key}="{value}"]'.format(
                 key=key, value=int(value)))
 
-        return './devices/hostdev/source/address{}'.format(
-            ''.join(address_fields))
-
-    def is_attached_to(self, xml_string):
         dom = ET.fromstring(xml_string)
-        return bool(dom.findall(self._xpath))
+        for src in dom.findall('./devices/hostdev/source'):
+            address = src.find('address{}'.format(''.join(address_fields)))
+            adapter = src.find('adapter[@name="{}"]'.format(self.adapter))
+
+            if (address is not None and adapter is not None):
+                return True
+
+        return False
 
     def getXML(self):
         """


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5aca2db8dfd73b431e1b7e9255121338ce0e44c1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoled...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org

Reply via email to