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

TSADOK, Shlomi (Shlomi) shlomi.tsadok at alcatel-lucent.com
Wed Nov 6 15:59:28 UTC 2013


Yes.. I saw that, but I have to :)

The issue was solved by converting the hook to Python and using 'subprocess.Popen'.  deadlock is gone, all looks good.

Regards

Shlomi


-----Original Message-----
From: Michal Privoznik [mailto:mprivozn at redhat.com] 
Sent: Wednesday, November 06, 2013 5:17 PM
To: TSADOK, Shlomi (Shlomi)
Cc: libvirt-users at redhat.com
Subject: Re: [libvirt-users] Calling 'virsh' from within a hook script - avoid deadlock?

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