By default, vscsi expects to be passed the final device name (eg /dev/st3) instead of one of the various udev symlinks (eg /dev/tape/by-path/pci-0000:01:08.0-scsi-0:0:2:0-st). The following patch resolves the path to the real path if the name starts with /dev/ James --- a/tools/python/xen/util/vscsi_util.py 2010-12-03 23:26:46.391655087 +1100 +++ b/tools/python/xen/util/vscsi_util.py 2011-02-07 12:20:37.599527204 +1100 @@ -158,6 +158,8 @@ def vscsi_get_hctl_and_devname_by(target, scsi_devices = None): + if target.startswith(''/dev/''): + target = os.path.realpath(target) if scsi_devices is None: if len(target.split('':'')) == 4: scsi_devices = _vscsi_get_scsidevices_by_lsscsi(target) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Mon, 2011-02-07 at 01:24 +0000, James Harper wrote:> By default, vscsi expects to be passed the final device name (eg > /dev/st3) instead of one of the various udev symlinks (eg > /dev/tape/by-path/pci-0000:01:08.0-scsi-0:0:2:0-st). The following patch > resolves the path to the real path if the name starts with /dev/This needs a signed-off-by.> James > > --- a/tools/python/xen/util/vscsi_util.py 2010-12-03 23:26:46.391655087 > +1100 > +++ b/tools/python/xen/util/vscsi_util.py 2011-02-07 12:20:37.599527204 > +1100 > @@ -158,6 +158,8 @@ > > > def vscsi_get_hctl_and_devname_by(target, scsi_devices = None): > + if target.startswith(''/dev/''): > + target = os.path.realpath(target)Any reason not to just unconditionally resolve symlinks in every target to the underlying device? Thanks, Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
(Adding xen-devel back since I guess you didn''t mean to drop) On Mon, 2011-02-07 at 09:43 +0000, James Harper wrote:> I think target isn''t always a file. It can be a scsi ID like 0:1:2:3. > I think it can be other types of specifier too.OK. So perhaps: if os.path.islink(target): target = os.path.realpath(target) ? Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
> > On Mon, 2011-02-07 at 09:43 +0000, James Harper wrote: > > I think target isn't always a file. It can be a scsi ID like 0:1:2:3. > > I think it can be other types of specifier too. > > OK. So perhaps: > > if os.path.islink(target): > target = os.path.realpath(target) >I guess. I know it's a long shot but what if there was a symlink called 0:1:2:3? While that is unlikely, there might be other incantations used by vscsi that could ambiguously be the filename of a symlink or not. I'd be happier if realpath was only used if an absolute path was specified. Who's going to want to specify a relative path anyway... what would it be relative to? James _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Mon, 2011-02-07 at 11:28 +0000, James Harper wrote:> > > > On Mon, 2011-02-07 at 09:43 +0000, James Harper wrote: > > > I think target isn''t always a file. It can be a scsi ID like 0:1:2:3. > > > I think it can be other types of specifier too. > > > > OK. So perhaps: > > > > if os.path.islink(target): > > target = os.path.realpath(target) > > > > I guess. I know it''s a long shot but what if there was a symlink > called 0:1:2:3? While that is unlikely, there might be other > incantations used by vscsi that could ambiguously be the filename of a > symlink or not. I''d be happier if realpath was only used if an > absolute path was specified. Who''s going to want to specify a relative > path anyway... what would it be relative to?Yes, good points. I guess we could go with target[0] == ''/'' but I think you are right to go with the conservative approach of checking for /dev/ unless/until someone shows up with a bug suggesting we do otherwise. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
James Harper writes ("[Xen-devel] [PATCH] vscsi and symlinks"):> By default, vscsi expects to be passed the final device name (eg > /dev/st3) instead of one of the various udev symlinks (eg > /dev/tape/by-path/pci-0000:01:08.0-scsi-0:0:2:0-st). The following patch > resolves the path to the real path if the name starts with /dev/Thanks. I would have applied this patch but you didn''t provide a "signed-off-by", to confirm that your contribution is in accordance with the Developer''s Certificate of Origin.>From Documentation/SubmittingPatches in the Linux kernel tree:Developer''s Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
With signed-off-by line :) By default, vscsi expects to be passed the final device name (eg /dev/st3) instead of one of the various udev symlinks (eg /dev/tape/by-path/pci-0000:01:08.0-scsi-0:0:2:0-st). The following patch resolves the path to the real path if the name starts with /dev/ Signed-off-by: James Harper <james.harper@bendigoit.com.au> --- a/tools/python/xen/util/vscsi_util.py 2010-12-03 23:26:46.391655087 +1100 +++ b/tools/python/xen/util/vscsi_util.py 2011-02-07 12:20:37.599527204 +1100 @@ -158,6 +158,8 @@ def vscsi_get_hctl_and_devname_by(target, scsi_devices = None): + if target.startswith(''/dev/''): + target = os.path.realpath(target) if scsi_devices is None: if len(target.split('':'')) == 4: scsi_devices = _vscsi_get_scsidevices_by_lsscsi(target)> -----Original Message----- > From: Ian Jackson [mailto:Ian.Jackson@eu.citrix.com] > Sent: Tuesday, 8 February 2011 03:23 > To: James Harper > Cc: xen-devel@lists.xensource.com > Subject: Re: [Xen-devel] [PATCH] vscsi and symlinks > > James Harper writes ("[Xen-devel] [PATCH] vscsi and symlinks"): > > By default, vscsi expects to be passed the final device name (eg > > /dev/st3) instead of one of the various udev symlinks (eg > > /dev/tape/by-path/pci-0000:01:08.0-scsi-0:0:2:0-st). The followingpatch> > resolves the path to the real path if the name starts with /dev/ > > Thanks. I would have applied this patch but you didn''t provide a > "signed-off-by", to confirm that your contribution is in accordance > with the Developer''s Certificate of Origin. > > From Documentation/SubmittingPatches in the Linux kernel tree: > > Developer''s Certificate of Origin 1.1 > > By making a contribution to this project, I certify that: > > (a) The contribution was created in whole or in part by me andI> have the right to submit it under the open source license > indicated in the file; or > > (b) The contribution is based upon previous work that, to thebest> of my knowledge, is covered under an appropriate opensource> license and I have the right under that license to submitthat> work with modifications, whether created in whole or inpart> by me, under the same open source license (unless I am > permitted to submit under a different license), asindicated> in the file; or > > (c) The contribution was provided directly to me by some other > person who certified (a), (b) or (c) and I have notmodified> it. > > (d) I understand and agree that this project and thecontribution> are public and that a record of the contribution(including all> personal information I submit with it, including mysign-off) is> maintained indefinitely and may be redistributedconsistent with> this project or the open source license(s) involved. > > Ian._______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Feb-08 16:36 UTC
RE: [Xen-devel] [PATCH] vscsi and symlinks [and 1 more messages]
James Harper writes ("RE: [Xen-devel] [PATCH] vscsi and symlinks"):> With signed-off-by line :) > > By default, vscsi expects to be passed the final device name (eg > /dev/st3) instead of one of the various udev symlinks (eg > /dev/tape/by-path/pci-0000:01:08.0-scsi-0:0:2:0-st). The following patch > resolves the path to the real path if the name starts with /dev/Thanks, applied. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel