Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

badjware
Copy link

@badjware badjware commented Apr 9, 2018

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
Copy link

daybat commented Apr 3, 2020

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

@ishioni
Copy link

ishioni commented Mar 12, 2021

@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
Copy link

daybat commented Mar 12, 2021

@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

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

@badjware
Copy link
Author

badjware commented Mar 17, 2021

@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