[libvirt] [PATCH] virtlockd: acquire locks on re-exec

Daniel P. Berrangé berrange at redhat.com
Fri Mar 2 18:12:28 UTC 2018


On Fri, Mar 02, 2018 at 04:52:23PM +0000, Daniel P. Berrangé wrote:
> On Thu, Mar 01, 2018 at 04:42:36PM -0700, Jim Fehlig wrote:
> > Locks held by virtlockd are dropped on re-exec.
> > 
> > virtlockd       94306 POSIX 5.4G WRITE 0     0   0 /tmp/test.qcow2
> > virtlockd       94306 POSIX   5B WRITE 0     0   0 /run/virtlockd.pid
> > virtlockd       94306 POSIX   5B WRITE 0     0   0 /run/virtlockd.pid
> > 
> > Acquire locks in PostExecRestart code path.
> 
> This is really strange and should *not* be happening.  POSIX locks
> are supposed to be preserved across execve() if the FD has CLOEXEC
> unset, and you don't fork() before the exec.

[snip]

> So I wonder what we've screwed up to cause the locks to get
> released - reaquiring them definitely isn't desirable as we
> should not loose them in the first place !

This is really very strange. The problem seems to be the existance of
threads at time of execve().

If you spawn a thread and the thread exits, and you execve the locks
are preserved.

If you spawn a thread and the thread is still running, and you execve
the locks are lost.

This behaviour makes no sense at all to time. Why should it matter if
the thread exits itself, or is force exited during execve(). I wonder
if it is even possibly a kernel bug.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list