On Wed, 8 Feb 2023 21:03:39 +0100
peze <felerf...@gmx.net> wrote:

> Am 08.02.23 um 19:30 schrieb Charles Curley:
>  [...]  
> 
> If your host is linux, can you show me your qemu-parameters?
> TIA
> 

I was afraid you were going to ask me that. I run qemu via libvirt. So
I will do a bit of detective work.  Here goes.

The XML for libvirt is:

--------------------------------------------------
<hostdev mode="subsystem" type="usb" managed="yes">
  <source>
    <vendor id="0x0718"/>
    <product id="0x0637"/>
    <address bus="2" device="6"/>
  </source>
  <alias name="hostdev0"/>
  <address type="usb" bus="0" port="4"/>
</hostdev>
--------------------------------------------------

You would have to modify the vendor, product, bus, and device IDs to
suit your device.

The command (imported not wrapped, but possibly wrapped in transport)
line is:

--------------------------------------------------
root@hawk:/etc/new.virtual# ps aux | grep -i dti386
libvirt+   62108  1.9  3.4 2958008 555240 ?      Sl   Jan27 345:08 
/usr/bin/qemu-system-x86_64 -name guest=dti386,debug-threads=on -S -object 
secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-6-dti386/master-key.aes
 -machine 
pc-q35-5.2,accel=kvm,usb=off,vmport=off,dump-guest-core=off,memory-backend=pc.ram
 -cpu pentium2 -m 1024 -object memory-backend-ram,id=pc.ram,size=1073741824 
-overcommit mem-lock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 
0f0b9d2c-d741-47f0-842b-336fbbc64c12 -no-user-config -nodefaults -chardev 
socket,id=charmonitor,fd=40,server,nowait -mon 
chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global 
kvm-pit.lost_tick_policy=delay -no-hpet -no-shutdown -global 
ICH9-LPC.disable_s3=1 -global ICH9-LPC.disable_s4=1 -boot menu=on,strict=on 
-device 
pcie-root-port,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2
 -device pcie-root-port,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 
-device pcie-root-port,port=0x12,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 
-device pcie-root-port,port=0x13,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x3 
-device pcie-root-port,port=0x14,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x4 
-device pcie-root-port,port=0x15,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x5 
-device pcie-root-port,port=0x16,chassis=7,id=pci.7,bus=pcie.0,addr=0x2.0x6 
-device qemu-xhci,p2=15,p3=15,id=usb,bus=pci.2,addr=0x0 -device 
virtio-scsi-pci,id=scsi0,bus=pci.4,addr=0x0 -device 
virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 -blockdev 
{"driver":"file","filename":"/var/lib/libvirt/images/firmware-testing-i386-netinst.iso","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}
 -blockdev 
{"node-name":"libvirt-2-format","read-only":true,"driver":"raw","file":"libvirt-2-storage"}
 -device ide-cd,bus=ide.0,drive=libvirt-2-format,id=sata0-0-0,bootindex=2 
-blockdev 
{"driver":"file","filename":"/var/lib/libvirt/images/dti386.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}
 -blockdev 
{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage","backing":null}
 -device ide-hd,bus=ide.1,drive=libvirt-1-format,id=sata0-0-1,bootindex=1 
-netdev tap,fd=45,id=hostnet0,vhost=on,vhostfd=46 -device 
virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:6f:aa:6a,bus=pci.1,addr=0x0 
-chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 
-chardev socket,id=charchannel0,fd=47,server,nowait -device 
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0
 -chardev spicevmc,id=charchannel1,name=vdagent -device 
virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1,name=com.redhat.spice.0
 -device usb-tablet,id=input0,bus=usb.0,port=1 -spice 
port=5902,addr=127.0.0.1,disable-ticketing,image-compression=off,seamless-migration=on
 -device 
qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pcie.0,addr=0x1
 -device ich9-intel-hda,id=sound0,bus=pcie.0,addr=0x1b -device 
hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -chardev 
spicevmc,id=charredir0,name=usbredir -device 
usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=2 -chardev 
spicevmc,id=charredir1,name=usbredir -device 
usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=3 -device 
usb-host,hostdevice=/dev/bus/usb/002/006,id=hostdev0,bus=usb.0,port=4 -device 
virtio-balloon-pci,id=balloon0,bus=pci.5,addr=0x0 -object 
rng-random,id=objrng0,filename=/dev/urandom -device 
virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.6,addr=0x0 -sandbox 
on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg 
timestamp=on
charles   124050  0.0  0.0  12232  2396 pts/6    S+   Jan28   0:00 ssh 
root@dti386.virtual
root      209851  0.0  0.0  12104  1928 pts/32   Ss+  Jan30   0:00 ssh -o 
ControlMaster=auto -o ControlPath=tramp.%C -o ControlPersist=no -e none 
dti386.virtual
charles   507969  0.0  0.0  12108  6684 pts/38   Ss+  15:04   0:00 ssh -o 
ControlMaster=auto -o ControlPath=tramp.%C -o ControlPersist=no -e none 
dti386.virtual
charles   508029  0.0  0.0  12108  6784 pts/39   Ss+  15:06   0:00 ssh -l root 
-o ControlMaster=auto -o ControlPath=tramp.%C -o ControlPersist=no -e none 
dti386.virtual
root      508252  0.0  0.0   6376  2348 pts/18   S+   15:13   0:00 grep 
--colour=auto -i dti386
root@hawk:/etc/new.virtual# 
--------------------------------------------------

I think the part of that mess you want is this:

--------------------------------------------------
-device usb-host,hostdevice=/dev/bus/usb/002/006,id=hostdev0,bus=usb.0,port=4
--------------------------------------------------

Where the /002/006 point to the usb device:

--------------------------------------------------
root@hawk:/etc/new.virtual# lsusb
…
Bus 002 Device 006: ID 0718:0637 Imation Corp. Nano Pro
…
root@hawk:/etc/new.virtual# 
--------------------------------------------------

Check that aginst the XML above, and the vendor, product ID, bus
number and device all agree.

On the guest, the device shows up like so:

--------------------------------------------------
root@dti386:~# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 0718:0637 Imation Corp. Nano Pro
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU USB Tablet
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@dti386:~# 
--------------------------------------------------

I suspect that the "id=hostdev0,bus=usb.0,port=4" is zero-based
(meaning the first entry is entry 0), while the lsusb listing is
one-based. But you may have to fiddle around with that anyway.

I hope that helps.

-- 
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/

Reply via email to