Re: Is it possible to pass-through a SATA port (not a controller and not a drive, but a single port)?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20/12/2017 13:18, Binarus wrote:
> The guest is started from a disk image, but for certain reasons
> additionally needs direct access to one single big backup disk. Since
> the mainboard has only one SATA controller, the backup disk is connected
> to the same SATA controller as the rest of the disks where the host
> Linux system resides. The backup disk is hot-swappable.
> 
> Currently, I have configured the system so that the backup disk is
> recognized by the host Linux system as block device (in my case
> /dev/sda) and is passed through to the guest as block device. I am
> starting the guest via command line directly (no libvirt or virsh or
> something like that involved) using the following option:
> 
> -drive file=/dev/sda,format=raw,if=virtio,cache=none,index=1
> 
> This setup works reliably, but is a nightmare when the backup disk must
> be changed. Currently, to change that disk, I am
> 
> - shutting down the guest (because I have found no way to let the guest
> (or qemu-kmv?) treat that drive as a removable drive;
> 
> - removing the drive from the Linux host (by doing something like sync;
> echo 1 > /sys/block/sda/device/delete);
> 
> - inserting the next backup disk;
> 
> - restarting the guest VM.

Passing through a port is not possible, but it's possible to hot-unplug
the entire virtio-blk disk and add it back, like:

   -drive if=none,id=bupdisk,file=/dev/sda,format=raw,cache=none
   -device virtio-blk-pci,drive=bupdisk

and then, to change the drive:

   in the guest: sync
   in the QEMU monitor: device_del bupdisk
   on the host: echo 1 > /sys/block/sda/device/delete
   in the QEMU monitor:
      drive_add 0 if=none,id=bupdisk,file=/dev/sda,format=raw,cache=none
      device_add virtio-blk-pci,drive=bupdisk

This uses PCI hotplug.  An alternative is to use virtio-scsi; then you
can keep always the same controller and do the hotplug at the SCSI level:

   -device virtio-scsi-pci,id=scsi
   -drive if=none,id=bupdisk,file=/dev/sda,format=raw,cache=none
   -device scsi-hd,drive=bupdisk,bus=scsi.0

and then, to change the drive:

   in the guest: sync
   in the QEMU monitor: device_del bupdisk
   on the host: echo 1 > /sys/block/sda/device/delete
   in the QEMU monitor:
      drive_add 0 if=none,id=bupdisk,file=/dev/sda,format=raw,cache=none
      device_add scsi-hd,drive=bupdisk,bus=scsi.0

Thanks,

Paolo



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux