Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA-142595: Non-block devices causing IndexError #203

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions drivers/devscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def adapters(filterstr="any"):
else:
dir = os.path.join(sysfs,lun,"device")
(dev, entry) = _extract_dev(dir, proc, id, lun)
devs[dev] = entry
if dev != "":
devs[dev] = entry
# for new qlogic sysfs layout (rport under device, then target)
for i in filter(match_rport,os.listdir(path)):
newpath = os.path.join(path, i)
Expand Down Expand Up @@ -223,9 +224,14 @@ def _extract_dev_name(device_dir):
return dev.lstrip('block:')
elif kernel_version.startswith('3.'):
# directory for device name lives inside block directory e.g. block/sdx
dev = glob.glob(os.path.join(device_dir, 'block/*'))[0]
# prune path to extract the device name
return os.path.basename(dev)

#bug fixed: some device dir has no subdir "block/" , e.g. LUN 0 has no "block/" subdir, but other LUNs are OK
devs = glob.glob(os.path.join(device_dir, 'block/*'))
if len(devs):
# prune path to extract the device name
return os.path.basename(devs[0])
else:
return ""
else:
msg = 'Kernel version detected: %s' % kernel_version
raise xs_errors.XenError('UnsupportedKernel', msg)
Expand Down