]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: support passing pre-opened UNIX socket listen FD
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 14 Mar 2018 12:16:11 +0000 (12:16 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 5 Jun 2018 16:30:28 +0000 (17:30 +0100)
commit30fb2276d88b275dc2aad6ddd28c100d944b59a5
treed5414e30fe46d9af934d6d4d64616e7aaa5aead6
parent7cef131efea7e17af826ffd7dfcad15ebcacc77e
qemu: support passing pre-opened UNIX socket listen FD

There is a race condition when spawning QEMU where libvirt has spawned
QEMU but the monitor socket is not yet open. Libvirt has to repeatedly
try to connect() to QEMU's monitor until eventually it succeeds, or
times out. We use kill() to check if QEMU is still alive so we avoid
waiting a long time if QEMU exited, but having a timeout at all is still
unpleasant.

With QEMU 2.12 we can pass in a pre-opened FD for UNIX domain or TCP
sockets. If libvirt has called bind() and listen() on this FD, then we
have a guarantee that libvirt can immediately call connect() and
succeed without any race.

Although we only really care about this for the monitor socket and agent
socket, this patch does FD passing for all UNIX socket based character
devices since there appears to be no downside to it.

We don't do FD passing for TCP sockets, however, because it is only
possible to pass a single FD, while some hostnames may require listening
on multiple FDs to cover IPv4 and IPv6 concurrently.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_command.h
tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-latest.args
tests/qemuxml2argvdata/disk-virtio-scsi-reservations.x86_64-latest.args
tests/qemuxml2argvdata/genid-auto.x86_64-latest.args
tests/qemuxml2argvdata/genid.x86_64-latest.args
tests/qemuxml2argvdata/vhost-vsock-auto.x86_64-latest.args
tests/qemuxml2argvdata/vhost-vsock.x86_64-latest.args
tests/qemuxml2argvmock.c