[libvirt-users] ruby-libvirt connection stays open
by "Gergely Pál - night[w]"
Hi,
I have a problem regarding the Ruby bindings of Libvirt. The sort
summary is that the connection does not closed properly when I have
retrieved a domain from it. The small sample code is the following (I
use irb for easy reading of return values):
The working connection closing (when I do nothing with the connection):
1.9.3p125 :001 > require 'libvirt'
=> true
1.9.3p125 :002 > conn = Libvirt::open('qemu+ssh://localhost/system')
=> #<Libvirt::Connect:0x00000001a40c30>
1.9.3p125 :003 > conn.close
=> nil
1.9.3p125 :004 > conn.closed?
=> true
(Note: I know I should not use ssh for localhost, it's just a test, in
general we use different remote hosts for this, so ssh is needed.)
In this case there is no connection left open.
But look at this code:
1.9.3p125 :001 > require 'libvirt'
=> true
1.9.3p125 :002 > conn = Libvirt::open('qemu+ssh://localhost/system')
=> #<Libvirt::Connect:0x00000001af3d80>
1.9.3p125 :003 > domain = conn.lookup_domain_by_name('gomboc18')
=> #<Libvirt::Domain:0x00000001adf0d8>
1.9.3p125 :004 > conn.close
=> nil
1.9.3p125 :005 > conn.closed?
=> true
And i run a ps auxww there are the relevant processes:
nightw 9241 0.2 0.3 88380 13256 pts/0 Sl+ 11:39 0:00 irb
nightw 9248 0.0 0.0 41188 2772 pts/0 S+ 11:39 0:00 ssh
localhost sh -c 'nc -q 2>&1 | grep "requires an argument" >/dev/null;if
[ $? -eq 0 ] ; then CMD="nc -q 0 -U
/var/run/libvirt/libvirt-sock";else CMD="nc -U
/var/run/libvirt/libvirt-sock";fi;eval "$CMD";'
root 9249 0.0 0.0 85752 3696 ? Ss 11:39 0:00 sshd:
nightw [priv]
nightw 9402 0.0 0.0 85752 1692 ? S 11:39 0:00 sshd:
nightw@notty
nightw 9403 0.0 0.0 4272 584 ? Ss 11:39 0:00 sh -c
nc -q 2>&1 | grep "requires an argument" >/dev/null;if [ $? -eq 0 ] ;
then CMD="nc -q 0 -U /var/run/libvirt/libvirt-sock";else CMD="nc -U
/var/run/libvirt/libvirt-sock";fi;eval "$CMD";
nightw 9406 0.0 0.0 14136 472 ? S 11:39 0:00 nc -q 0
-U /var/run/libvirt/libvirt-sock
And they remain open until i close irb (or the original ruby application
on the real development system)
Do you have any suggestions for solving this problem?
Thanks,
Pal