ia64/xen-unstable

changeset 19447:2d19139c1c9c

xend: Fix scsi_id for pvSCSI

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.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 31 11:27:10 2009 +0100 (2009-03-31)
parents 152257350930
children 2ef77b4bdf58
files tools/python/xen/util/vscsi_util.py
line diff
     1.1 --- a/tools/python/xen/util/vscsi_util.py	Tue Mar 31 11:26:10 2009 +0100
     1.2 +++ b/tools/python/xen/util/vscsi_util.py	Tue Mar 31 11:27:10 2009 +0100
     1.3 @@ -36,6 +36,11 @@ SYSFS_SCSI_DEV_TYPEID_PATH = '/type'
     1.4  SYSFS_SCSI_DEV_REVISION_PATH = '/rev'
     1.5  SYSFS_SCSI_DEV_SCSILEVEL_PATH = '/scsi_level'
     1.6  
     1.7 +SCSI_ID_COMMANDS = [
     1.8 +    "/lib/udev/scsi_id -gu --sg-version 3 -d /dev/%s 2>/dev/null",
     1.9 +    "/sbin/scsi_id -gu -s /class/scsi_generic/%s 2>/dev/null"
    1.10 +]
    1.11 +
    1.12  def _vscsi_get_devname_by(name, scsi_devices):
    1.13      """A device name is gotten by the HCTL.
    1.14      (e.g., '0:0:0:0' to '/dev/sda')
    1.15 @@ -79,9 +84,10 @@ def _vscsi_get_hctl_by(phyname, scsi_dev
    1.16  
    1.17  
    1.18  def _vscsi_get_scsiid(sg):
    1.19 -    scsi_id = os.popen('/sbin/scsi_id -gu -s /class/scsi_generic/' + sg).read().split()
    1.20 -    if len(scsi_id):
    1.21 -        return scsi_id[0]
    1.22 +    for scsi_id_command in SCSI_ID_COMMANDS:
    1.23 +        scsi_id = os.popen(scsi_id_command % sg).read().split()
    1.24 +        if len(scsi_id):
    1.25 +            return scsi_id[0]
    1.26      return None
    1.27  
    1.28