diff options
author | Paolo Bonzini | 2017-03-16 16:29:45 +0100 |
---|---|---|
committer | Paolo Bonzini | 2017-03-19 11:12:12 +0100 |
commit | 53fabd4b86e15869e13fb762686d674c64294385 (patch) | |
tree | 8ffb29b28fd121ab3d695e6e89cdd3bef9a6df4b /include | |
parent | nios2: iic: Convert CPU prop to qom link (diff) | |
download | qemu-53fabd4b86e15869e13fb762686d674c64294385.tar.gz qemu-53fabd4b86e15869e13fb762686d674c64294385.tar.xz qemu-53fabd4b86e15869e13fb762686d674c64294385.zip |
qemu-ga: obey LISTEN_PID when using systemd socket activation
qemu-ga's socket activation support was not obeying the LISTEN_PID
environment variable, which avoids that a process uses a socket-activation
file descriptor meant for its parent.
Mess can for example ensue if a process forks a children before consuming
the socket-activation file descriptor and therefore setting O_CLOEXEC
on it.
Luckily, qemu-nbd also got socket activation code, and its copy does
support LISTEN_PID. Some extra fixups are needed to ensure that the
code can be used for both, but that's what this patch does. The
main change is to replace get_listen_fds's "consume" argument with
the FIRST_SOCKET_ACTIVATION_FD macro from the qemu-nbd code.
Cc: "Richard W.M. Jones" <rjones@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/systemd.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/qemu/systemd.h b/include/qemu/systemd.h new file mode 100644 index 0000000000..e6a877e5c6 --- /dev/null +++ b/include/qemu/systemd.h @@ -0,0 +1,26 @@ +/* + * systemd socket activation support + * + * Copyright 2017 Red Hat, Inc. and/or its affiliates + * + * Authors: + * Richard W.M. Jones <rjones@redhat.com> + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_SYSTEMD_H +#define QEMU_SYSTEMD_H 1 + +#define FIRST_SOCKET_ACTIVATION_FD 3 /* defined by systemd ABI */ + +/* + * Check if socket activation was requested via use of the + * LISTEN_FDS and LISTEN_PID environment variables. + * + * Returns 0 if no socket activation, or the number of FDs. + */ +unsigned int check_socket_activation(void); + +#endif |