[libvirt] increase number of libvirt threads by starting tansient guest doamin - is it a bug?

Michal Privoznik mprivozn at redhat.com
Fri Sep 26 09:21:04 UTC 2014


On 26.09.2014 09:46, ustermann78 at web.de wrote:
> hello,
>
> if i start a transient guest doamin via "virsh create abcd.xml" i see an additional libvirt thread and also some open files:
>
> pstree -h `pgrep libvirtd`
> libvirtd───11*[{libvirtd}]
>
> libvirtd 3016 root   21w      REG              253,0      6044 1052094 /var/log/libvirt/libxl/abcd.log
> libvirtd 3016 root   22r     FIFO                0,8       0t0  126124 pipe
> libvirtd 3016 root   23w     FIFO                0,8       0t0  126124 pipe
> libvirtd 3016 root   24u      REG               0,37         0       4 /proc/xen/privcmd
> libvirtd 3016 root   25u     unix 0xffff8807d2c3ad80       0t0  126125 socket
> libvirtd 3016 root   26r     FIFO                0,8       0t0  126127 pipe
> libvirtd 3016 root   27w     FIFO                0,8       0t0  126127 pipe
> libvirtd 3016 root   28r     FIFO                0,8       0t0  124783 pipe
> libvirtd 3016 root   29w     FIFO                0,8       0t0  124783 pipe
> libvirtd 3016 root   30r     FIFO                0,8       0t0  127140 pipe
> libvirtd 3016 root   31w     FIFO                0,8       0t0  127140 pipe
>
> if i destroy these vm via "virsh destroy abcd", i see that the additional thread still exists and also the list of openfiles is the same.
> if i start the transient guest domain again, i observe an increase in the number of libvirt threads ans also in the list of openfiles:
>
> [root at localhost libxl]# pstree -h `pgrep libvirtd`
> libvirtd───12*[{libvirtd}]
>
> libvirtd 3016 root   21w      REG              253,0     13783 1052094 /var/log/libvirt/libxl/abcd.log
> libvirtd 3016 root   22r     FIFO                0,8       0t0  126124 pipe
> libvirtd 3016 root   23w     FIFO                0,8       0t0  126124 pipe
> libvirtd 3016 root   24u      REG               0,37         0       4 /proc/xen/privcmd
> libvirtd 3016 root   25u     unix 0xffff8807d2c3ad80       0t0  126125 socket
> libvirtd 3016 root   26r     FIFO                0,8       0t0  126127 pipe
> libvirtd 3016 root   27w     FIFO                0,8       0t0  126127 pipe
> libvirtd 3016 root   28r     FIFO                0,8       0t0  124783 pipe
> libvirtd 3016 root   29w     FIFO                0,8       0t0  124783 pipe
> libvirtd 3016 root   30r     FIFO                0,8       0t0  127140 pipe
> libvirtd 3016 root   31w     FIFO                0,8       0t0  127140 pipe
> libvirtd 3016 root   32w      REG              253,0     13783 1052094 /var/log/libvirt/libxl/abcd.log
> libvirtd 3016 root   33r     FIFO                0,8       0t0  129039 pipe
> libvirtd 3016 root   34w     FIFO                0,8       0t0  129039 pipe
> libvirtd 3016 root   35u      REG               0,37         0       4 /proc/xen/privcmd
> libvirtd 3016 root   36u     unix 0xffff8807d398bb80       0t0  129040 socket
> libvirtd 3016 root   37r     FIFO                0,8       0t0  129042 pipe
> libvirtd 3016 root   38w     FIFO                0,8       0t0  129042 pipe
> libvirtd 3016 root   39r     FIFO                0,8       0t0  129043 pipe
> libvirtd 3016 root   40w     FIFO                0,8       0t0  129043 pipe
> libvirtd 3016 root   41r     FIFO                0,8       0t0  129044 pipe
> libvirtd 3016 root   42w     FIFO                0,8       0t0  129044 pipe
>
> if i destroy the doamin again and define them via "virsh define abcd.xml" and start them then via "virsh start abcd", the number of libvirtd threads don´t increase again and also the number of open files is the same.
>
> My question: is it normal that for transient guest domains the created libvirtd thread sill exists and also the open files after i destroy the doamin? or is it bug?


The thread is created as a result of this commit:

commit 03b3f8940af1a3179b7d5e19b25f54290bde10e0
Author:     Jim Fehlig <jfehlig at suse.com>
AuthorDate: Fri Jan 31 23:06:35 2014 -0700
Commit:     Jim Fehlig <jfehlig at suse.com>
CommitDate: Thu Feb 6 10:17:58 2014 -0700

     libxl: handle domain shutdown events in a thread

     Handling the domain shutdown event within the event handler seems
     a bit unfair to libxl's event machinery.  Domain "shutdown" could
     take considerable time.  E.g. if the shutdown reason is reboot,
     the domain must be reaped and then started again.

     Spawn a shutdown handler thread to do this work, allowing libxl's
     event machinery to go about its business.

     Signed-off-by: Jim Fehlig <jfehlig at suse.com>



Which was then modified by 0a840e23 (pure code movement). The thing is, 
libvirt listens on events from hypervisors. And some actions that are 
taken subsequently may take ages to finish. However, the events are 
executed single threaded, so they serialize effectively. And for the 
long lasting actions (like shutdown, in fact in libxl shutdown only) a 
new thread is spawned so the event loop is not burdened for too long.
The thread is created with 'detach-state' attribute so once the shutdown 
is handled the thread should just disappear.

Michal




More information about the libvir-list mailing list