Seitanas / kvm-vdi

linux-kvm based VDI solution
MIT License
218 stars 82 forks source link

usb redirection not working #105

Closed aslefnad closed 6 years ago

aslefnad commented 6 years ago

i hope you can help me. i can't get usb redirection to work. i tried a bunch of different methods and everywhere is look it always says that usb redirection with spice "just works".

is there something i need to install on my hypervisor machine or client? i create a vm using kvm-vdi and virt-manager says that "usb redirector 1" is present. the client is a ubuntu machine set up like in the wiki.

i really hope you can help

i have these settings in the xml of the vm:

<domstatus state='running' reason='booted' pid='41388'>
  <monitor path='/var/lib/libvirt/qemu/domain-mate-vdi-1/monitor.sock' json='1' type='unix'/>
  <vcpus>
    <vcpu pid='41394'/>
    <vcpu pid='41395'/>
    <vcpu pid='41396'/>
    <vcpu pid='41397'/>
  </vcpus>
  <qemuCaps>
    <flag name='kvm'/>
    <flag name='mem-path'/>
    <flag name='drive-serial'/>
    <flag name='chardev'/>
    <flag name='monitor-json'/>
    <flag name='balloon'/>
    <flag name='device'/>
    <flag name='sdl'/>
    <flag name='smp-topology'/>
    <flag name='netdev'/>
    <flag name='rtc'/>
    <flag name='vhost-net'/>
    <flag name='no-hpet'/>
    <flag name='no-kvm-pit'/>
    <flag name='pci-configfd'/>
    <flag name='nodefconfig'/>
    <flag name='boot-menu'/>
    <flag name='fsdev'/>
    <flag name='name-process'/>
    <flag name='drive-readonly'/>
    <flag name='smbios-type'/>
    <flag name='vga-qxl'/>
    <flag name='spice'/>
    <flag name='vga-none'/>
    <flag name='boot-index'/>
    <flag name='hda-duplex'/>
    <flag name='drive-aio'/>
    <flag name='pci-multibus'/>
    <flag name='pci-bootindex'/>
    <flag name='ccid-emulated'/>
    <flag name='ccid-passthru'/>
    <flag name='chardev-spicevmc'/>
    <flag name='virtio-tx-alg'/>
    <flag name='device-qxl-vga'/>
    <flag name='pci-multifunction'/>
    <flag name='virtio-blk-pci.ioeventfd'/>
    <flag name='sga'/>
    <flag name='virtio-blk-pci.event_idx'/>
    <flag name='virtio-net-pci.event_idx'/>
    <flag name='cache-directsync'/>
    <flag name='piix3-usb-uhci'/>
    <flag name='piix4-usb-uhci'/>
    <flag name='usb-ehci'/>
    <flag name='ich9-usb-ehci1'/>
    <flag name='vt82c686b-usb-uhci'/>
    <flag name='pci-ohci'/>
    <flag name='usb-redir'/>
    <flag name='usb-hub'/>
    <flag name='no-shutdown'/>
    <flag name='cache-unsafe'/>
    <flag name='rombar'/>
    <flag name='ich9-ahci'/>
    <flag name='no-acpi'/>
    <flag name='fsdev-readonly'/>
    <flag name='virtio-blk-pci.scsi'/>
    <flag name='blk-sg-io'/>
    <flag name='drive-copy-on-read'/>
    <flag name='cpu-host'/>
    <flag name='fsdev-writeout'/>
    <flag name='drive-iotune'/>
    <flag name='system_wakeup'/>
    <flag name='scsi-disk.channel'/>
    <flag name='scsi-block'/>
    <flag name='transaction'/>
    <flag name='block-job-async'/>
    <flag name='scsi-cd'/>
    <flag name='ide-cd'/>
    <flag name='no-user-config'/>
    <flag name='hda-micro'/>
    <flag name='dump-guest-memory'/>
    <flag name='nec-usb-xhci'/>
    <flag name='balloon-event'/>
    <flag name='bridge'/>
    <flag name='lsi'/>
    <flag name='virtio-scsi-pci'/>
    <flag name='blockio'/>
    <flag name='disable-s3'/>
    <flag name='disable-s4'/>
    <flag name='usb-redir.filter'/>
    <flag name='ide-drive.wwn'/>
    <flag name='scsi-disk.wwn'/>
    <flag name='seccomp-sandbox'/>
    <flag name='reboot-timeout'/>
    <flag name='dump-guest-core'/>
    <flag name='seamless-migration'/>
    <flag name='block-commit'/>
    <flag name='vnc'/>
    <flag name='drive-mirror'/>
    <flag name='usb-redir.bootindex'/>
    <flag name='usb-host.bootindex'/>
    <flag name='blockdev-snapshot-sync'/>
    <flag name='qxl'/>
    <flag name='VGA'/>
    <flag name='cirrus-vga'/>
    <flag name='vmware-svga'/>
    <flag name='device-video-primary'/>
    <flag name='usb-serial'/>
    <flag name='usb-net'/>
    <flag name='add-fd'/>
    <flag name='nbd-server'/>
    <flag name='virtio-rng'/>
    <flag name='rng-random'/>
    <flag name='rng-egd'/>
    <flag name='dtb'/>
    <flag name='megasas'/>
    <flag name='ipv6-migration'/>
    <flag name='machine-opt'/>
    <flag name='machine-usb-opt'/>
    <flag name='tpm-passthrough'/>
    <flag name='tpm-tis'/>
    <flag name='pci-bridge'/>
    <flag name='vfio-pci'/>
    <flag name='vfio-pci.bootindex'/>
    <flag name='scsi-generic'/>
    <flag name='scsi-generic.bootindex'/>
    <flag name='mem-merge'/>
    <flag name='vnc-websocket'/>
    <flag name='drive-discard'/>
    <flag name='mlock'/>
    <flag name='vnc-share-policy'/>
    <flag name='device-del-event'/>
    <flag name='dmi-to-pci-bridge'/>
    <flag name='i440fx-pci-hole64-size'/>
    <flag name='q35-pci-hole64-size'/>
    <flag name='usb-storage'/>
    <flag name='usb-storage.removable'/>
    <flag name='virtio-mmio'/>
    <flag name='ich9-intel-hda'/>
    <flag name='kvm-pit-lost-tick-policy'/>
    <flag name='boot-strict'/>
    <flag name='pvpanic'/>
    <flag name='spice-file-xfer-disable'/>
    <flag name='spiceport'/>
    <flag name='usb-kbd'/>
    <flag name='host-pci-multidomain'/>
    <flag name='msg-timestamp'/>
    <flag name='active-commit'/>
    <flag name='change-backing-file'/>
    <flag name='memory-backend-ram'/>
    <flag name='numa'/>
    <flag name='memory-backend-file'/>
    <flag name='usb-audio'/>
    <flag name='rtc-reset-reinjection'/>
    <flag name='splash-timeout'/>
    <flag name='iothread'/>
    <flag name='migrate-rdma'/>
    <flag name='ivshmem'/>
    <flag name='drive-iotune-max'/>
    <flag name='VGA.vgamem_mb'/>
    <flag name='vmware-svga.vgamem_mb'/>
    <flag name='qxl.vgamem_mb'/>
    <flag name='qxl-vga.vgamem_mb'/>
    <flag name='pc-dimm'/>
    <flag name='machine-vmport-opt'/>
    <flag name='aes-key-wrap'/>
    <flag name='dea-key-wrap'/>
    <flag name='pci-serial'/>
    <flag name='vhost-user-multiqueue'/>
    <flag name='migration-event'/>
    <flag name='ioh3420'/>
    <flag name='x3130-upstream'/>
    <flag name='xio3130-downstream'/>
    <flag name='rtl8139'/>
    <flag name='e1000'/>
    <flag name='virtio-net'/>
    <flag name='gic-version'/>
    <flag name='incoming-defer'/>
    <flag name='virtio-gpu'/>
    <flag name='virtio-keyboard'/>
    <flag name='virtio-mouse'/>
    <flag name='virtio-tablet'/>
    <flag name='virtio-input-host'/>
    <flag name='ich9-disable-s3'/>
    <flag name='ich9-disable-s4'/>
    <flag name='vserport-change-event'/>
    <flag name='virtio-balloon-pci.deflate-on-oom'/>
  </qemuCaps>
  <devices>
    <device alias='virtio-disk0'/>
    <device alias='virtio-serial0'/>
    <device alias='video0'/>
    <device alias='serial0'/>
    <device alias='sound0'/>
    <device alias='balloon0'/>
    <device alias='channel1'/>
    <device alias='channel0'/>
    <device alias='net0'/>
    <device alias='redir0'/>
    <device alias='usb'/>
    <device alias='ide0-1-0'/>
  </devices>
  <domain type='kvm' id='85'>
    <name>mate-vdi-1</name>
    <uuid>348bd270-fea3-4168-86e7-9a12da94b2db</uuid>
    <memory unit='KiB'>2097152</memory>
    <currentMemory unit='KiB'>2097152</currentMemory>
    <vcpu placement='static'>4</vcpu>
    <resource>
      <partition>/machine</partition>
    </resource>
    <os>
      <type arch='x86_64' machine='pc-i440fx-xenial'>hvm</type>
      <boot dev='hd'/>
    </os>
    <features>
      <acpi/>
      <apic/>
    </features>
    <cpu>
      <topology sockets='2' cores='2' threads='1'/>
    </cpu>
    <clock offset='utc'>
      <timer name='rtc' tickpolicy='catchup'/>
      <timer name='pit' tickpolicy='delay'/>
      <timer name='hpet' present='no'/>
    </clock>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>restart</on_crash>
    <pm>
      <suspend-to-mem enabled='no'/>
      <suspend-to-disk enabled='no'/>
    </pm>
    <devices>
      <emulator>/usr/local/VDI/vdi-wrapper</emulator>
      <disk type='file' device='disk'>
        <driver name='qemu' type='qcow2' cache='none'/>
        <source file='/mnt/data/vm/mate-vdi-1-59fc2f88292a4.qcow2'/>
        <backingStore type='file' index='1'>
          <format type='raw'/>
          <source file='/media/ramdrive/mate-init-59fc2f4d125b0.qcow2'/>
          <backingStore/>
        </backingStore>
        <target dev='vda' bus='virtio'/>
        <alias name='virtio-disk0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
      </disk>
      <disk type='file' device='cdrom'>
        <driver name='qemu' type='raw'/>
        <backingStore/>
        <target dev='hdc' bus='ide'/>
        <readonly/>
        <alias name='ide0-1-0'/>
        <address type='drive' controller='0' bus='1' target='0' unit='0'/>
      </disk>
      <controller type='usb' index='0' model='ich9-ehci1'>
        <alias name='usb'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/>
      </controller>
      <controller type='usb' index='0' model='ich9-uhci1'>
        <alias name='usb'/>
        <master startport='0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/>
      </controller>
      <controller type='usb' index='0' model='ich9-uhci2'>
        <alias name='usb'/>
        <master startport='2'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/>
      </controller>
      <controller type='usb' index='0' model='ich9-uhci3'>
        <alias name='usb'/>
        <master startport='4'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/>
      </controller>
      <controller type='pci' index='0' model='pci-root'>
        <alias name='pci.0'/>
      </controller>
      <controller type='ide' index='0'>
        <alias name='ide'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
      </controller>
      <controller type='virtio-serial' index='0'>
        <alias name='virtio-serial0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
      </controller>
      <interface type='bridge'>
        <mac address='52:54:00:4f:7b:11'/>
        <source bridge='virbr0'/>
        <target dev='vnet4'/>
        <model type='virtio'/>
        <alias name='net0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
      </interface>
      <serial type='pty'>
        <source path='/dev/pts/4'/>
        <target port='0'/>
        <alias name='serial0'/>
      </serial>
      <console type='pty' tty='/dev/pts/4'>
        <source path='/dev/pts/4'/>
        <target type='serial' port='0'/>
        <alias name='serial0'/>
      </console>
      <channel type='spicevmc'>
        <target type='virtio' name='com.redhat.spice.0' state='disconnected'/>
        <alias name='channel0'/>
        <address type='virtio-serial' controller='0' bus='0' port='1'/>
      </channel>
      <channel type='unix'>
        <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-mate-vdi-1/com.kvm-vdi.0'/>
        <target type='virtio' name='com.kvm-vdi.0' state='disconnected'/>
        <alias name='channel1'/>
        <address type='virtio-serial' controller='0' bus='0' port='3'/>
      </channel>
      <input type='mouse' bus='ps2'/>
      <input type='keyboard' bus='ps2'/>
      <graphics type='spice' port='5904' autoport='yes' listen='0.0.0.0'>
        <listen type='address' address='0.0.0.0' fromConfig='0'/>
        <image compression='auto_glz'/>
        <streaming mode='filter'/>
        <mouse mode='client'/>
        <clipboard copypaste='no'/>
        <filetransfer enable='no'/>
      </graphics>
      <sound model='ac97'>
        <alias name='sound0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
      </sound>
      <video>
        <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/>
        <alias name='video0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
      </video>
      <redirdev bus='usb' type='spicevmc'>
        <alias name='redir0'/>
      </redirdev>
      <memballoon model='virtio'>
        <alias name='balloon0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
      </memballoon>
    </devices>
  </domain>
</domstatus>
Seitanas commented 6 years ago

Hello, first thing to check is if spice client is compiled with USB support (it seems, that debian native client does not have this functionality - not sure about other distros).

aslefnad commented 6 years ago

i tried the client from your repo with no additional configuration besides changing the ip. but that client should work?

i now tried remote-viewer and there usb redirection worked after i manually selected the usb device even though i got the error message "There are no free USB channels"

Seitanas commented 6 years ago

The client from KVM-VDI repository is just a wrapper. USB support should be compiled into remote-viewer. Manually selected USB device (via virt-manager) uses different approach - it attaches device directly to VM. What you need is a SPICE USB redirection and for that to work, remote-viewer should have USB support compiled in. You can try compile remote-viwer from source to test this.

aslefnad commented 6 years ago

i will try that. thanks very much for your help