How to pass removable USB or eSata devices from host to KVM

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

gohu

Guest
I got some backups to do on an hard drive.
My backup software is on a KVM.
How can I easily pass theses drive without having much configuration and without configuring this each time I connect the drive ?

I looked at udev but is there a tool that can do it for me because it's a daily manipulation and the two drive may have to change in the time

Moreover my backups have to run every nights even if am not there so other people can just plug the hard drive and every thing works

Thank you

Hugo
 
What is your target client OS?

You can pass USB devices to vm adding them manually to the vm's config file (in /etc/quemu-server/). Check man qm for syntax.

Will NOT work for Win7 and Windows2008 clients (or newer, i guess).

Regards, Holger
 
The target client OS is Cent OS

What I need is something that is totally transparent for the user.
He plugs the usb hard drive on the host
then the host recognise the hard drive by the usb port that is used or by the uuid of the filesystem.
Then the Device is automatically passed to the VM

Have you an idea ?
Maybe with udev ?
It's a manipulation that I (or users ) will have to do a lot of times so is there an assistant or a script that could do this functionnality ?
If not, I can devellop a little but I dont know really what to do
 
...udev will create/maintainb symlinks for your disk-device under /dev/disk/<...> once you plug it in or out.
But it will not create a symlink for your USB device (-port), which is a fixed pci address anyway.

I don't quite get if hot-plugging on the KVM-VM side will be required in your usecase.
Then, udev is not for you. You'll have to pass the usb device...which is USB1.1 speed only.
If you are in need to share the USB-ports over several VMs at a time, then only one VM at a time can be active.

If you do not need hot-plugging for the disk devices, just define your own rule in a customized 60-persistent-storage.rules file.
 
Ok thank you,
After some experiments I 'd prefer to pass the block device and not the usb port. Moreover, the USB1.1 speed only is not enought. Also I may use firewire, usb or eSata hard drives.

I think to do a udev rule that execute a command to qm. It will recognise partitions on drives via their uuid.

The point that are critical is that:
- I may remove the drive at anytime once it's unounted on the vm
- I may connect the drive when the virtual machine is not running so
- I may have to connect others drives like that and I want to configure them like that

I know that udev creates symlinks on /dev/disk/by-uuid, I may configure qm to pass this device node:
But it may not work because:
- The device is removable : The /dev/disk/by-uuid will disapear
- The device is removable : It's plugged/unplugged many times wheareas the virtual machine could not be reboot each time
- QM wont discover directly that the /dev/disk/by-uuid devnode has been created.

Which command should I use to pass this removable block device ? I have seen -device and -drive options and I dont know wich one to use
 
...the command is simple, because it is statically changing the VM config.
That'll be "qm set <vmid> virtio|scsi|ide<no> </dev/disk/by-?????/<your-drive>" or something like that.
But since what you describe is hot-plugging the device t the VM...this setup will not help you, won't it?

Maybe you should think of using an USB over IP solution?
See some options here: http://forum.proxmox.com/threads/5629-How-to-make-the-VM-run-USB-stuff?p=31859#poststop
By the looks of it, the usbipd is now maintained in the linux kernel tree...
But this is USB only...no eSATA
 
Last edited: