Datera / targetcli

CLI and shell for the Linux SCSI Target
http://linux-iscsi.org/wiki/targetcli
Apache License 2.0
52 stars 21 forks source link

Targetcli ignores TYPE_TAPE devices for pscsi export #17

Open dkt5 opened 8 years ago

dkt5 commented 8 years ago

http://www.spinics.net/lists/target-devel/msg09414.html http://article.gmane.org/gmane.linux.scsi.target.devel/3602

When attempting to add via targetcli as 'create tape0 /dev/st0' (or /dev/sg1) "Cannot find SCSI device by path and dev parameter...." If I specify the device scsi parameters it says "scsi device does not exist"

Adding with tcm_node it shows up as a broken storage link.

Manually creating in /sys/kernel/config/target/core, the kernel panic when 'echo 1 > enable'

Unable to include kernel backtrace.

dkt5 commented 8 years ago

Another relevant item http://www.spinics.net/lists/target-devel/msg03940.html

Malvineous commented 7 years ago

FWIW I have been able to successfully export /dev/nst0 over pscsi and I successfully wrote to the tape from another machine over the resulting iSCSI connection, so perhaps this issue is now fixed?

jondzpike commented 6 years ago

(edit: this is for "python rtslib" which is what came with the package targetcli, on Ubuntu 16.04.3. I realize now this post is very old and perhaps i am looking at an old version) Hi, I was able to make a tape drive work by applying these corrections to rtslib/utils.py.
I dont have any patch file as I only program occasionally, if you want to try it you'll have to edit the files:

-----------PATCH 1 of 2 --------------------------------------
1. In function convert_scsi_path_to_hctl

OLD: 
    try:
        hctl = os.listdir("/sys/block/%s/device/scsi_device"
                          % devname)[0].split(':')
    except:
        return None
    return [int(data) for data in hctl]

NEW: 
    try:
       hctl = os.listdir("/sys/block/%s/device/scsi_device"
                             % devname)[0].split(':')
       return [int(data) for data in hctl]
    except OSError: pass

    try:
       hctl = os.listdir("/sys/class/scsi_tape/%s/device/scsi_device"
                          % devname)[0].split(':')
       return [int(data) for data in hctl]
    except OSError: pass

    return None

-----------PATCH 2 of 2 --------------------------------------
In function convert_scsi_hctl_to_path
OLD: 
    for devname in os.listdir("/sys/block"):
        path = "/dev/%s" % devname
        hctl = [host, controller, target, lun]
        if convert_scsi_path_to_hctl(path) == hctl:
            return os.path.realpath(path)
NEW:
    for devname in os.listdir("/sys/block"):
        path = "/dev/%s" % devname
        hctl = [host, controller, target, lun]
        if convert_scsi_path_to_hctl(path) == hctl:
            return os.path.realpath(path)
    try:
        for devname in os.listdir("/sys/class/scsi_tape"):
            path = "/dev/%s" % devname
            hctl = [host, controller, target, lun]
            if convert_scsi_path_to_hctl(path) == hctl:
                return os.path.realpath(path)
    except OSError: pass