Re: script called from qemu hook freezes.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 03, 2019 at 18:07:58 +0100, daggs wrote:
> Greetings,
> 
> I'm executing an external script when the qemu hook is called with start or release, the script is rather simple, upon start it iterates over the output of lsusb -t and for each device, it looks if it should be added to the vm we started, if so, it attaches it to the vm as follows:
> virsh --connect qemu:///system "${cmd}" "${domain}" /dev/stdin << END
> <hostdev mode='subsystem' type='usb'>
>   <source>
>    <address bus='${busnum}' device='${devnum}' />
>   </source>
> </hostdev>
> END
> 
> where cmd is attach-device, domain is the vm's name, busnum and devnum come from the output of the lsusb -t.
> my issue is that upon the first attach attempt, the cmd hangs, I need to kill it and after than I cannot preform any virsh cmd, I must restart the host.
> if I try to execute the same cmd after the vm is up, it works great.
> 
> why the attach process gets stuck? do I need to execute it under different stage?

Hook scripts shall never call any libvirt API (even through virsh). At
the point when the hook script is called the VM startup process is
paused until the script returns. If the script attempts to modify the VM
it gets stuck as the VM is locked at that point.

You either need to add the device prior to startup, but AFAIK that is
not possible with a hook script or after but the script needs to return.

So you either fork off a process which will wait for the startup to
finish from the hook script or write an APP using the libvirt API which
will wait for the VM start event and then execute what's necessary.

Attachment: signature.asc
Description: PGP signature

_______________________________________________
libvirt-users mailing list
libvirt-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvirt-users

[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux