Skip to contentSkip to conversation

Fix about scsi_id for pvSCSI

PATCH New Masaki Kanno 1 participant 1 message Mar 25, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix about scsi_id for pvSCSI

Hi,

pvSCSI allocations fail if the version of udev in a host OS is relatively-new. I have not been able to detect the failure because I have used udev of the version 095. The failure occurs by an incompatibility problem of scsi_id command included udev. This patch tackles the incompatibility problem.

Best regards,
Kan

tools/python/xen/util/vscsi_util.py +9 -3
diff -r 0e1449d6f231 tools/python/xen/util/vscsi_util.py
@@ -35,6 +35,11 @@ SYSFS_SCSI_DEV_TYPEID_PATH = '/type'
 SYSFS_SCSI_DEV_TYPEID_PATH = '/type'
 SYSFS_SCSI_DEV_REVISION_PATH = '/rev'
 SYSFS_SCSI_DEV_SCSILEVEL_PATH = '/scsi_level'
+
+SCSI_ID_COMMANDS = [
+    "/lib/udev/scsi_id -gu --sg-version 3 -d /dev/%s 2>/dev/null",
+    "/sbin/scsi_id -gu -s /class/scsi_generic/%s 2>/dev/null"
+]
 
 def _vscsi_get_devname_by(name, scsi_devices):
     """A device name is gotten by the HCTL.
@@ -79,9 +84,10 @@ def _vscsi_get_hctl_by(phyname, scsi_dev
 
 
 def _vscsi_get_scsiid(sg):
-    scsi_id = os.popen('/sbin/scsi_id -gu -s /class/scsi_generic/' + sg).read().split()
-    if len(scsi_id):
-        return scsi_id[0]
+    for scsi_id_command in SCSI_ID_COMMANDS:
+        scsi_id = os.popen(scsi_id_command % sg).read().split()
+        if len(scsi_id):
+            return scsi_id[0]
     return None
 
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel