I am searching for information on mapping an existing drive (USB drive) to a KVM virtual machine using libvirt. I have been going over http://libvirt.org/formatstorage.html#StoragePoolTarget. But I don't quite understand what options are needed to expose an existing device to the VM (or if it is even possible).
From what I am reading, the target
element is expecting a path
element to a folder on the machine to store a file based image. Can the path
be a device such as /dev/sdc1
? with a type
of raw
?
Check out the 'USB passthrough | Using Libvirt' section of this page from the Edubuntu wiki. More info here and here.
If you don't ever plan to hot plug/unplug the usb drive while the guest is running you could also try adding a section like
to your VM's xml definition file. Just change the source dev to match what was assigned to your usb when it was plugged in. However, you can't guarantee the usb's dev assignment will survive reboot if other devices are added or removed, so I'd recommend the approach in the first link above instead.
In case the link disappears, here is the relevant USB passthrough section of the linked docs: