Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > 8f7319b3fa97b585796e134036e489da > files > 14

scsi-target-utils-1.0.4-3.el6_0.1.i686.rpm

The MMC emulation in TGTD can emulate a DVD device capable of writing/burning
to emulated blank disks.

The emulation supports three types of behaviour (profiles) which are
automatically selected by TGTD at runtime.

These three types are :
NO_PROFILE : This is the behaviour used when the device is OFFLINE or when
there is no backing store file present. In this profile the emulation will
behave as if there is no media (disk) inserted in the drive tray.

DVD-ROM : This is used if the device is ONLINE and also if the backing store
file exists and contains data (i.e. the file size is >0). In this mode
TGTD will behave as if a read-only DVD-ROM disk is inserted in the tray.

DVD+R : This is used if the device is ONLINE and the backing store file exists
and is empty (i.e. the file size is == 0). In this mode the emulation
will behave as if there is a blank, writeable, DVD+R disk in the tray.
In this mode you can burn an ISO image onto the device.
Once the burning process has finished and the application issues the
CLOSE TRACK command to finalize the track, the emulation will morph
from DVD+R and into DVD-ROM so that subsequent access to the drive
will behave as if there is now a DVD-ROM disk in the tray.



Compatibility :
The MMC commandset for writeable media is extensive. This emulation currently
only implements a small subset of the full MMC specification.
In particular, during development the windows application DVD-Decrypter
was used to view which commands and subcommands were required to successfully
burn a disk.
This emulation supports all commands that that application uses when
accessing a DVD drive to identify and write to a blank disk.
Other applications may use a different subset of MMC to perform the same
operations in which case it may or may not work.
It is the intent that the emulation will be enhanced to provide compatibility
with all DVD burning applications on all important platforms.

The emulation is also compatible with Linux:dvdrecorder but you must
specify the command arguments -dao -ignsize -overburn

Example:
dvdrecord -dao -ignsize -overburn dev=/dev/sg3 ./IMAGE.iso


Please report incompatibilities with other burning applications other than
Windows/DVD-Decrypter to ronniesahlberg@gmail.com and I will try to
enhance the emulation to also support your application of choice.
I can however only test with Windows free-ware or linux applications.





#
# Example 1: How to create a MMC device that contains an empty writeable
# DVD+R disk which can be written to using DVD-Decrypter
#

# Create a target
tgtadm --lld iscsi --mode target --op new --tid 1 -T iqn.2007-03:virtual-dvd:`hostname`

# Create an empty file that will represent a writeable DVD+R disk
rm -rf /tmp/empty-disk.iso
tgtimg --op new --device-type cd --type dvd+r --file /tmp/empty-disk.iso

# Create LUN - CD/ROM
tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 -b /tmp/empty-disk.iso --device-type=cd

# Give it a nice name
SN=XYZ123
tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 1 --params vendor_id=STGT_DVD,product_id=DVD101,product_rev=0010,scsi_sn=$SN,removable=1


# Allow ALL initiators to connect to this target
tgtadm --lld iscsi --mode target --op bind --tid 1 -I ALL

# Show all our good work.
tgtadm --lld iscsi --mode target --op show


#
# Example 2: How to mark the device "offline" meaning the device will show up
# as "no disk in tray"
#
tgtadm --tid 1 --lun 1 --op update --mode logicalunit --name online --value No


#
# Example 3: While the device is "offline" we can swap the disk in the tray,
# by just pointing the device to a different backing store file.
# In this example we just swap it to another blank DVD+R disk.
#
rm -rf /tmp/empty-disk2.iso
tgtimg --op new --device-type cd --type dvd+r --file /tmp/empty-disk2.iso
tgtadm --tid 1 --lun 1 --op update --mode logicalunit --name path --value /tmp/empty-disk2.iso

# note: when we updated the device to a new bakend storage file the device
# automatically goes online again with the new media present.








#
# Example 4: How to create a DVD jukebox with 8 disk trays
#

# Create a target
tgtadm --lld iscsi --mode target --op new --tid 1 -T iqn.2007-03:virtual-dvd:`hostname`

# Create a DVD drive and give it a nice name
# The dvd starts out without a backing store file, i.e. no disk loaded
tgtadm --op new --mode logicalunit --tid 1 --lun 1 -Y cd
tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 1 --params vendor_id=STGT_DVD,product_id=DVD101,product_rev=0010,scsi_sn=STGTDVD01,removable=1


# We need a backend store file for the media changer
if [ ! -f $HOME/smc ]; then
	dd if=/dev/zero of=$HOME/smc bs=1k count=1
fi

# Create the SMC device and give it a nice name
tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 2 -b $HOME/smc --device-type=changer
tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 2 --params vendor_id=STK,product_id=L700,product_rev=0010,scsi_sn=XYZZY_0,removable=1


# Add a Data Transfer devices (1 drive)
tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 2 --params element_type=4,start_address=1,quantity=1

# Specify that the DVD above (LUN 1) is the data transfer device we created
tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 2 --params element_type=4,address=1,tid=1,lun=1

# Medium Transport Elements (robot arm / picker)
tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 2 --params element_type=1,start_address=16,quantity=1

# define path to virtual media
VTL=${HOME}/vtl
mkdir -p ${VTL} 2>/dev/null
tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 2 --params media_home=${VTL}

# Storage Elements - 8 starting at addr 1024
tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 2 --params element_type=2,start_address=1024,quantity=8

# Add 'media' to slots 1 and 2 and leave the other 6 slots empty
# slot 1
tgtimg --op new --device-type cd --type dvd+r --file ${VTL}/DISK_001
tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 2 --params element_type=2,address=1024,barcode=DISK_001,sides=1

# slot 2
tgtimg --op new --device-type cd --type dvd+r --file ${VTL}/DISK_002
tgtadm --lld iscsi --mode logicalunit --op update --tid 1 --lun 2 --params element_type=2,address=1025,barcode=DISK_002,sides=1

# Allow ALL initiators to connect to this target
tgtadm --lld iscsi --mode target --op bind --tid 1 -I ALL

# Show all our good work.
tgtadm --lld iscsi --mode target --op show




Now you should be able to access the devices and try it out :
tgtadm --lld iscsi --mode target --op show

Target 1: iqn.2007-03:virtual-dvd:ronnie
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: deadbeaf1:0
            SCSI SN: beaf10
            Size: 0 MB
            Online: Yes
            Removable media: No
            Backing store: No backing store
        LUN: 1
            Type: cd/dvd
            SCSI ID: deadbeaf1:1
            SCSI SN: STGTDVD0
            Size: 0 MB
            Online: No
            Removable media: Yes
            Backing store: No backing store
        LUN: 2
            Type: changer
            SCSI ID: deadbeaf1:2
            SCSI SN: XYZZY_0
            Size: 0 MB
            Online: Yes
            Removable media: Yes
            Backing store: /root/smc
    Account information:
    ACL information:
        ALL


You can use the 'mtx' command under linux to manage the jukebox (man mtx)
mtx -f /dev/sg4 status

  Storage Changer /dev/sg4:1 Drives, 8 Slots ( 0 Import/Export )
Data Transfer Element 0:Empty
      Storage Element 1:Full :VolumeTag=DISK_001
      Storage Element 2:Full :VolumeTag=DISK_002
      Storage Element 3:Empty:VolumeTag=
      Storage Element 4:Empty:VolumeTag=
      Storage Element 5:Empty:VolumeTag=
      Storage Element 6:Empty:VolumeTag=
      Storage Element 7:Empty:VolumeTag=
      Storage Element 8:Empty:VolumeTag=

Now load the disk in slot 1 :
mtx -f /dev/sg4 load 1
mtx -f /dev/sg4 status

  Storage Changer /dev/sg4:1 Drives, 8 Slots ( 0 Import/Export )
Data Transfer Element 0:Full (Storage Element 1 Loaded):VolumeTag = DISK_00
      Storage Element 1:Empty:VolumeTag=
      Storage Element 2:Full :VolumeTag=DISK_002
      Storage Element 3:Empty:VolumeTag=
      Storage Element 4:Empty:VolumeTag=
      Storage Element 5:Empty:VolumeTag=
      Storage Element 6:Empty:VolumeTag=
      Storage Element 7:Empty:VolumeTag=
      Storage Element 8:Empty:VolumeTag=

And if we look at the devices again we see the DVD drive is now online and has
a disk loaded :
tgtadm --lld iscsi --mode target --op show

Target 1: iqn.2007-03:virtual-dvd:ronnie    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
        I_T nexus: 1
            Initiator: iqn.1993-08.org.debian:ronnie
            Connection: 0
                IP Address: 127.0.0.1
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: deadbeaf1:0
            SCSI SN: beaf10
            Size: 0 MB
            Online: Yes
            Removable media: No
            Backing store: No backing store
        LUN: 1
            Type: cd/dvd
            SCSI ID: deadbeaf1:1
            SCSI SN: STGTDVD0
            Size: 0 MB
            Online: Yes
            Removable media: Yes
            Backing store: /root/vtl/DISK_001
        LUN: 2
            Type: changer
            SCSI ID: deadbeaf1:2
            SCSI SN: XYZZY_0
            Size: 0 MB
            Online: Yes
            Removable media: Yes
            Backing store: /root/smc
    Account information:
    ACL information:
        ALL

Have fun building big DVD jukeboxes !!!