[CentOS] Centos 7 and qemu-kvm

Sat May 9 16:01:33 UTC 2015
Stephen Harris <lists at spuddy.org>

On Sat, May 09, 2015 at 10:11:16AM -0500, Robert Nichols wrote:
> On 05/09/2015 08:26 AM, Jerry Geis wrote:
> >so I installed virt-manager - I have file images and those work.
> >some times I do directly to a USB connected disk.
> >
> >I do not see how to do that in virt-manager ???
> >
> >How do I use a device like /dev/sdh as my disk???
> 
> Click on "Add Hardware", select "Storage", then "Select managed or
> other existing storage" and type "/dev/sdh" into the box.  You can
> choose "IDE disk" or "Virtio Disk" as the device type, and the
> device will be available as "/dev/sd?" or "/dev/vd?" accordingly.

Alternatively you might be able to do this using hotswap code.  eg I have
a USB based 'scope that I want to pass through to a windows instance.
To do this I have a udev rule:

  % cat /etc/udev/rules.d/90-owon.rules
  ACTION=="add", \
    SUBSYSTEM=="usb", \
    SYSFS{idVendor}=="5345", \
    SYSFS{idProduct}=="1234", \
    RUN+="/usr/bin/virsh attach-device XP_VM1 /etc/libvirt/HotPlug/owon.xml"

  ACTION=="remove", \
    SUBSYSTEM=="usb", \
    SYSFS{idVendor}=="5345", \
    SYSFS{idProduct}=="1234", \
    RUN+="/usr/bin/virsh detach-device XP_VM1 /etc/libvirt/HotPlug/owon.xml"

Then the 'owon.xml' file determines the device as seen by the VM:
  % cat /etc/libvirt/HotPlug/owon.xml
  <hostdev mode='subsystem' type='usb'>
    <source>
      <vendor id='0x5345'/>
      <product id='0x1234'/>
    </source>
  </hostdev>

This passes the USB device 'raw' through to the VM.  For Windows this
means I can load the native drivers and it'll look like I've plugged
the 'scope directly into the windows machine.

Pretty sure something like this would work for hotswap disks as well.
Just make sure the Vendor/product ID numbers match the device you're
plugging in!

-- 

rgds
Stephen