pvscsi xend python syntax problem
PATCH 1/1 pvscsi xend python syntax problem
xen-unstable changeset 17959:6ae87b27cc contains a syntax error in vscsi_get_scsidevices:
File "/local/scratch/xenrt/xenrtbuildH17919/build/dist/install/usr/lib/python/xen/util/vscsi_util.py", line 126, in vscsi_get_scsidevices
UnboundLocalError: local variable 'sg' referenced before assignment
This is because the loop tries to add the device, including information about its sg, without first setting sg. I've grepped the code and setting sg to None seems the safest bet.
Ian.
tools/python/xen/util/vscsi_util.py +2 -0
@@ -122,6 +122,8 @@ def vscsi_get_scsidevices(): scsi_id = '-' else: scsi_id = lines[0] + else: + sg = None devices.append([hctl, block, sg, scsi_id])
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Also, I've just noticed this:
if re.match('^scsi_generic', f):
os.chdir(os.path.join(paths, f)) sg = os.path.basename(os.getcwd())
which is really crazy! A utility function like this must not just use chdir! Is this really the best way of doing this ?
In the meantime this might be a better patch. (NB: not tested.)
Ian.
tools/python/xen/util/vscsi_util.py +3 -1
@@ -114,7 +114,7 @@ def vscsi_get_scsidevices(): os.chdir(os.path.join(paths, f)) block = os.path.basename(os.getcwd()) - if re.match('^scsi_generic', f): + if false and re.match('^scsi_generic', f): os.chdir(os.path.join(paths, f)) sg = os.path.basename(os.getcwd()) lines = os.popen('/sbin/scsi_id -gu -s /class/scsi_generic/' + sg).read().split()
@@ -122,6 +122,8 @@ def vscsi_get_scsidevices(): scsi_id = '-' else: scsi_id = lines[0] + else: + sg = None devices.append([hctl, block, sg, scsi_id])
Hi Ian,
Thanks for your report.
I will fix them.
Best regards,
Kan
Quoted 40 lines · Ian Jackson
Also, I've just noticed this:
if
re.match('^scsi_generic', f):
os.chdir(os.path.join(paths, f))sg = os.path.basename(os.getcwd())which is really crazy! A utility function like this must not just use chdir! Is this really the best way of doing this ?
In the meantime this might be a better patch. (NB: not tested.)
Ian.
diff -r
4129f0f2f2batools/python/xen/util/vscsi_util.pytools/python/xen/util/vscsi_util.py +1
-1@@ -114,7 +114,7 @@ def vscsi_get_scsidevices(): os.chdir(os.path.join(paths, f)) block = os.path.basename(os.getcwd()) - if re.match('^scsi_generic', f): + if false and re.match('^scsi_generic', f): os.chdir(os.path.join(paths, f)) sg = os.path.basename(os.getcwd()) lines = os.popen('/sbin/scsi_id -gu -s /class/scsi_generic/' + sg).read().split()
tools/python/xen/util/vscsi_util.py +2
-0@@ -122,6 +122,8 @@ def vscsi_get_scsidevices(): scsi_id = '-' else: scsi_id = lines[0] + else: + sg = None devices.append([hctl, block, sg, scsi_id])_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel