Automatically, bind USB device on hotplug to a KVM or openVZ + Tape Drive via iscsi-

  • Thread starter Thread starter gohu
  • Start date Start date
G

gohu

Guest
Hi
I got 3 devices to assign to a KVM/OpenVZ

The first one is a Tape Drive that I configured as an iscsi target on the host.

The two others are USB storage devices that are Backup Volumes that needs to always been passed to the VM.

First I was doing it for the tape drive via device assignment into an openVZ.

I needed iscsi for the tape drive because it's required for another external machine that got the old backup software ( the new one is on a VM on proxmox ) in order to be able to restore older backups on the old backup system and not beeing rebooting the proxmox node in order to plug the tape drive every time I do a tape archive or a restore.

I was going to do the same on the USB storages w/ iscsi ( because i prefer to use only one system for both KVM&openVZ ) but I need to automatically pass the USB volume to the virtual machine according to his label/uuid.

I am blocking on passing automatically the hard drives to an iscsi target.

I started by editing an udev rule :
ACTION=="add",
ENV{DEVTYPE}=="disk",
ENV{ID_FS_LABEL_ENC}=="GKEY",
ENV{ID_FS_UUID_ENC}=="7B43-1EE3",
ENV{ID_FS_USAGE}=="filesystem|other|crypto",
RUN+="some script"

ACTION=="remove",
ENV{ID_FS_LABEL_ENC}=="GKEY",
ENV{ID_FS_USAGE}=="filesystem|other",
RUN+="some script"

The script that I add in the run+= section is executed so the USB device is detected.

My problem is more a the iscsi-scst level.
Here is the essential part of my script :
IADMIN="/usr/sbin/scstadmin"
${IADMIN} -adddev ${D_NAME} -handler vdisk -path ${DEVICE} -options REMOVABLE
${IADMIN} -assigndev ${D_NAME} -group ${TARGET} -lun 0
When I use scstadmin to add a device to a target it's not working like when I do it in the /etc/scst.conf
I think that scst admin can only add a device to a classic security group ( not a target ).

Scst.conf ( this file works but I need to make this dynamically so that the device is shared once it's plugged I dont want the device not found error when the USB device is not plugged): [HANDLER vdisk]
#DEVICE vdisk name,device path,options,block size
DEVICE scst_usb_iscsi,/dev/disk/by-label/GKEY,,512
[ASSIGNMENT Default]

[ASSIGNMENT Default_iqn.test:test]
#DEVICE device name,lun
DEVICE scst_usb_iscsi,0

Does anybody have some idea to pass automatically a USB Storage Device to a vm or a container trough iscsi ?

Thanks

Hugo
 
Last edited by a moderator: