[libvirt-users] Calling 'virsh' from within a hook script - avoid deadlock?

Michal Privoznik mprivozn at redhat.com
Wed Nov 6 15:17:26 UTC 2013


On 06.11.2013 11:23, TSADOK, Shlomi (Shlomi) wrote:
> I'm trying to create a hook that attaches several virtio-scsi disks to a
> starting vm,
> 
> and it seems like the hook enters a deadlock while attempting to do so.
> 
>  
> 
> Is there any workaround around this? Any better way, forking virsh
> execution somehow?
> 
>  
> 
> Could anyone explain why this is creating a deadlock in the first place?
> Isn't libvirt multithreaded?
> 
>  
> 
> Thanks for the help!
> 
>  
> 
> Shlomi
> 
>  
> 
> ### hook script:
> 
>  
> 
> #!/bin/bash
> 
>  
> 
> enum_scsi() {
> 
>     scsi_devices=`cd /dev;ls sd[^a]*`
> 
> }
> 
>  
> 
> gen_hba_xml() {
> 
>     cat > ./hba.xml << EOF
> 
>     <controller type='scsi' model='virtio-scsi'/>
> 
> EOF
> 
> }
> 
>  
> 
> passthrough_start() {
> 
>     # create virtio-scsi HBA
> 
>     gen_hba_xml
> 
>     virsh attach-device --persistent $domain_name ./hba.xml
> 
>     rm -f ./hba.xml

http://libvirt.org/hooks.html#recursive

Do not do this.

Michal




More information about the libvirt-users mailing list