KVM: pass-through SATA hot-swap drive

kvm-virtualizationpassthroughsatavirtualization

I have a SATA hot-swap cage in my Linux box. Is it possible to pass-through the SATA disk which is injected in that cage to a KVM guest? I have multiple disks however the SATA port will be always the same.

Ideally it should work just as without virtualization which means I can start the VM if no drive is present, can add it later without any manual intervention and remove it at any time (provided of course that OS does not access the drive anymore).

Best Answer

You cannot pass-through inexistent device. But you can dynamically attach and detach it when you plug it in and out. You can use libvirt's virsh attach-disk/detach disk to simplify this.

I don't think there is a ready script doing that on VM start/stop, but it's not that hard to write one.