how to hotplug USB device on Qemu 4.2.0? - usb

I have Qemu 4.2.0 with Debian Testing Bullseye and Kernel 5.4.0 and I need to hotplug and unplug an USB device.
Currently I attach my USB device with
qemu... -usb -device usb-host,hostbus=x,hostaddr=y
but when I physically remove the device I can't longer detect it from within the VM (Win7).
So, what should I do to send a plug/unplug usb signal to the virtual machine??

You can do plug/unplug via qemu monitor. see https://en.wikibooks.org/wiki/QEMU/Monitor.
To hot plug a usb device, type bellow in qemu monitor:
(qemu) device_add usb-host,hostbus=2,hostport=1.2.2,id=idofyourdevice
To remove a usb device, type bellow in qemu monitor:
(qemu) device_del idofyourdevice

Related

ToupTek XCAM4K8MPA camera connection to Linux computer

I'm trying to connect a ToupTek XCAM4K8MPA camera to a Linux Ubuntu 20.04 64-bit computer to use with their provided ToupLite software for microscopy image capturing. The camera comes with a USB 3.0 cable, HDMI cable and USB WLAN adapter.
I have managed to set up the ToupTek ToupLite software (Link to manual, Link to download page) which, as far as I understand, comes with the SDK included. I have then connected the camera via USB 3.0 and HDMI cable to the computer, but ToupLite shows No device as in, the camera is not recognized or connected. I have tested the camera by simply connecting it to a computer monitor via HDMI cable and it works, but for capture I would like it to be connected to a computer and the WLAN or Wi-Fi connection solution is not really a good option.
Perhaps someone has some ideas of what I am missing.
Note: Relevant tags include touptek, touplite, microscopy
I ended up using the WLAN connection. Made a non-changing IP address for the camera and the ToupLite software recognizes that it is on the local network.

How to change the vendor id of any Pnp (Plug and Play) device inside Virtualbox?

I want to change the default vendor id prefix VID_80EE Give by Virtual Box.
VID_80EE
I am doing malware analysis and malware use this id to detect whether it is running in a Virtual BOX or not.
It is a virtual usb device, which runs inside the VM. Normal usb drivers talk to usb devices on the usb bus. This virtual device is still on the virtual usb bus, but it is not a hardware, instead it is talking to the virtualbox process on the host. The virtualbox has some kernel drivers, they provide the virtual usb devices which bind the virtual usb bus of the guest with the virtualbox process of the host.
To change their USB vendor/product ID, I see no way than change their source code and recompiling them. They are Linux kernel drivers, part of the upstream virtualbox sources.
The vendor/product id of the virtual USB keyboard is here, and of the mouse is here.
You can do the recompilation following the virtualbox build instructions.
I did already some vbox recompilation, and it is not trivial, but it can be done without major problems. And you only need the guest kernel drivers.

How to passthrough an usb hub to a vm (based on kvm)?

linux kernel 4.9.7
libvirt 2.4.0
qemu 2.7.0
HOST:
i7 6700
ASUS B250M-PLUS
2xGTX1060 3GB
500Wpower
1x PCIEtoUSB3.0 card (Reneses chip)
I have two VMs using different GPU
I'm using usb controller passthrough now
VM1 has motherboard controller
VM2 has the PCIE CARD
BUT!!!!!!it is instability!!!!!
mouse and keyboard will be no use sometimes
so i am thinking about passthrough usb hub to be stable
is there any way to do it
this question is interesting. But you should provide more infos about the problem, how you started the machine, what precisel is working and what not.
Btw, use some more time to format your question...
Maybe you background is, that it is dificult and mayby impossible to passthrough an hub to a vom using the normal QEMU VID/PID combination. You can probably show the VM the hub, but all devcices connected to it are still owned by the host.^^
The only way I see is to pass through your nice PCIe USB3.0 controller to your desired VM. You need to enable the IOMMU feature in Grub for KVM to do so. But then it will work.

Getting Hotplug react when plugging 3G netstick (with mdev)

I'm trying to get a device running embedded linux V-2.6.31 to automatically recognize when a Huawei 3G usb stick is plugged to it, run usb_modeswitch, and communicate with the module.
it seems that usb_modeswitch doesn't work well in a system that has mdev, since the path /dev/bus/usb is only being created with udev.
I found a script that create this path and enable usb_modeswitch to work properly.
now, all i need is automation of this process, e.g., when plugging the 3G module, hotplug will first call my script, and then usb_modeswitch.
the problem is that when plugging the 3G module nothing happens when the enumeration is done (the hotplug wont run), see trace:
[83175.520000] usb 2-1: new full speed USB device using bcm5892-ohci:PORT-2 and address 3
[83175.730000] usb 2-1: not running at top speed; connect to a high speed hub
[83175.750000] usb 2-1: New USB device found, idVendor=12d1, idProduct=1f1c
[83175.760000] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[83175.770000] usb 2-1: Product: HUAWEI Mobile
[83175.770000] usb 2-1: Manufacturer: Vodafone(Huawei)
[83175.780000] usb 2-1: SerialNumber: FFFFFFFFFFFFFFFF
[83175.800000] usb 2-1: configuration #1 chosen from 2 choices
[83175.870000] scsi1 : SCSI emulation for USB Mass Storage devices
[83180.910000] scsi 1:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
I'm not sure what is wrong, is there something i didn't enable? is there a KO that i need to load in order for it to work?
Thank you in advance!

emulating usb device with another PC

Task: Testing production software on PC notebook without production unit attached via USB and without changing prodcution software.
Goal: Emulate production device with another PC. The test application runs on the second PC to emulate our device commands/responses.
Challenge: Using a USB bridge cable or other device requires that we can change the PID/VID to look like our device.
Suggestions?
You need a hardware device on the second PC to do this type of emulation.
USB ports on a normal PC are USB host ports. Two such ports cannot be connected with each other directly. USB device (or USB OTG - switchable) ports can be found on programmable smartphones (Android, maybe others) and some developer boards like these. I think you probably need to use a smartphone or developer board rather than ordinary PC as the your USB device emulator.