Skip to content

Commit 5df738f

Browse files
committed
CA-210336: Added exception handling to prevent stack trace dump
Added a try-except block around line 353 which lists devices at a given path in BaseISCSI.py attach method. Also made change in SRCommand.py to prevent raising exceptions that are not of type SR.SRException and dumping the stack trace on command line. Signed-off-by: Letsibogo Ramadi <[email protected]>
1 parent 4a4c5b4 commit 5df738f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

drivers/BaseISCSI.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,14 @@ def attach(self, sr_uuid):
350350
if self.dconf.has_key('SCSIid'):
351351
if self.mpath == 'true':
352352
self.mpathmodule.refresh(self.dconf['SCSIid'], 0)
353-
devs = os.listdir("/dev/disk/by-scsid/%s" % self.dconf['SCSIid'])
353+
try:
354+
devs_path = "/dev/disk/by-scsid/%s" % self.dconf['SCSIid']
355+
devs = os.listdir(devs_path)
356+
except:
357+
util.SMlog("[Errno 2] No such file or directory: '%s'" % devs_path)
358+
raise xs_errors.XenError('ConfigDeviceInvalid',
359+
opterr='check devices path')
360+
354361
for dev in devs:
355362
realdev = os.path.realpath("/dev/disk/by-scsid/%s/%s" % (self.dconf['SCSIid'], dev))
356363
util.set_scheduler(realdev.split("/")[-1], "noop")

drivers/SRCommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,6 @@ def run(driver, driver_info):
369369
if isinstance(e, SR.SRException):
370370
print e.toxml()
371371
else:
372-
raise
372+
sys.exit(1)
373373

374374
sys.exit(0)

0 commit comments

Comments
 (0)