Vasiliy Tolstov
2015-Jul-23 13:17 UTC
[libvirt-users] global lock when executing hook scripts
Hello. I'm try to understand, why in case of 20 workers libvirt fully locked when runs qemu hook (when domain starts) virsh list freezes. As i understand in case of using more workers it utilized to run hooks too, but as i see in pstree only main libvirt process executes hook. Why this happening? pstree -a -p 6642 libvirtd,6642 -d -l ├─qemu,9272 /etc/libvirt/hooks/qemu testvm prepare begin - │ └─prepare,9468 -x /usr/local/prepare.sh testvm │ └─sleep,9469 5000 ├─{libvirtd},6643 ├─{libvirtd},6644 ├─{libvirtd},6645 ├─{libvirtd},6646 ├─{libvirtd},6647 ├─{libvirtd},6648 -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru
Daniel P. Berrange
2015-Jul-23 13:22 UTC
Re: [libvirt-users] global lock when executing hook scripts
On Thu, Jul 23, 2015 at 04:17:22PM +0300, Vasiliy Tolstov wrote:> Hello. I'm try to understand, why in case of 20 workers libvirt fully > locked when runs qemu hook (when domain starts) virsh list freezes. > As i understand in case of using more workers it utilized to run hooks > too, but as i see in pstree only main libvirt process executes hook. > Why this happening?The process for starting up a QEMU guest holds locks on various data structures. These same locks are needed when running a variety of other commands such as those run by virsh list. So those commands will be blocked until the guest startup lock is released, which in turns is pending on the hook script exiting. This why hook scripts should never call back into libvirt APIs, and why they should also try to be as fast as possible at execution. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Vasiliy Tolstov
2015-Jul-23 13:26 UTC
Re: [libvirt-users] global lock when executing hook scripts
2015-07-23 16:22 GMT+03:00 Daniel P. Berrange <berrange@redhat.com>:> The process for starting up a QEMU guest holds locks on various > data structures. These same locks are needed when running a variety > of other commands such as those run by virsh list. So those commands > will be blocked until the guest startup lock is released, which > in turns is pending on the hook script exiting. This why hook > scripts should never call back into libvirt APIs, and why they should > also try to be as fast as possible at execution.Thank you for your explanation! -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru