Skip to content

make the virsh run after the udev script to fix a "failed to find host usb device" error#2

Open
badjware wants to merge 1 commit into
olavmrk:masterfrom
badjware:master
Open

make the virsh run after the udev script to fix a "failed to find host usb device" error#2
badjware wants to merge 1 commit into
olavmrk:masterfrom
badjware:master

Conversation

@badjware

@badjware badjware commented Apr 9, 2018

Copy link
Copy Markdown

virsh was throwning the following error:
558: error : qemuMonitorJSONCheckError:394 : internal error: unable to execute QEMU command 'device_add': failed to find host usb device

Running the scipt manually was working fine. After some testing, it seemed that the usb device was not fully available yet when the udev script was running. Runnning virsh slightly after udev using the at command fixed the issue.

@daybat

daybat commented Apr 3, 2020

Copy link
Copy Markdown

please check this solution https://github.com/daybat/usb-libvirt-hotplug

@ishioni

ishioni commented Mar 12, 2021

Copy link
Copy Markdown

@badjware I am baffled why this works. It's needed if I unplug and replug the device, but works on first insertion after I start the VM. sleep 5 wouldn't fix the problem, but this did. Could you exaplain?

@daybat

daybat commented Mar 12, 2021

Copy link
Copy Markdown

@badjware I am baffled why this works. It's needed if I unplug and replug the device, but works on first insertion after I start the VM. sleep 5 wouldn't fix the problem, but this did. Could you exaplain?

hi. what is the problem?

@nitram2342

Copy link
Copy Markdown

@badjware Thank you very much. You patch fixes the issue.

@badjware

badjware commented Mar 17, 2021

Copy link
Copy Markdown
Author

@ishioni

If your vm is configured to use a host usb device, these devices will automatically be attached to your vm when you boot it. Then, if you physically unplug and replug your device or plug in a new device, the vm will not pick the device and it will be left associated to the host. This is what this script addresses. Look up udev if you wish to learn more on how the script works.

I do not remember why sleep does not work here. It must be something to do with how udev run the script that requires that we start a new process to attach the device to the vm. I wrote this almost 3 years ago, shame on me for not commenting properly I guess.

Hope this help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants