[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v3 1/5] qemu-nbd: Add --pid-file option
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [PATCH v3 1/5] qemu-nbd: Add --pid-file option |
Date: |
Fri, 24 May 2019 10:07:27 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
On 5/8/19 4:18 PM, Max Reitz wrote:
> --fork is a bit boring if there is no way to get the child's PID. This
> option helps.
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> qemu-nbd.c | 11 +++++++++++
> qemu-nbd.texi | 2 ++
> 2 files changed, 13 insertions(+)
>
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index dca9e72cee..edb5195208 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -59,6 +59,7 @@
> #define QEMU_NBD_OPT_IMAGE_OPTS 262
> #define QEMU_NBD_OPT_FORK 263
> #define QEMU_NBD_OPT_TLSAUTHZ 264
> +#define QEMU_NBD_OPT_PID_FILE 265
>
> #define MBR_SIZE 512
>
> @@ -111,6 +112,7 @@ static void usage(const char *name)
> " specify tracing options\n"
> " --fork fork off the server process and exit the
> parent\n"
> " once the server is running\n"
> +" --pid-file=PATH store the server's process ID in the given
> file\n"
Are we guaranteed that the pid file does not appear until after the
socket has been created?
/me rereads full file...
> @@ -876,6 +880,9 @@ int main(int argc, char **argv)
> case 'L':
> list = true;
> break;
> + case QEMU_NBD_OPT_PID_FILE:
> + pid_file_name = optarg;
> + break;
> }
> }
>
...
socket_activation = check_socket_activation();
if (socket_activation == 0) {
setup_address_and_port(&bindto, &port);
} else {
/* Using socket activation - check user didn't use -p etc. */
...
> @@ -1196,6 +1203,10 @@ int main(int argc, char **argv)
>
> nbd_update_server_watch();
>
> + if (pid_file_name) {
> + qemu_write_pidfile(pid_file_name, &error_fatal);
> + }
Yes, we are. So,
> +
> /* now when the initialization is (almost) complete, chdir("/")
> * to free any busy filesystems */
> if (chdir("/") < 0) {
> diff --git a/qemu-nbd.texi b/qemu-nbd.texi
> index de342c76b8..7f55657722 100644
> --- a/qemu-nbd.texi
> +++ b/qemu-nbd.texi
> @@ -117,6 +117,8 @@ option; or provide the credentials needed for connecting
> as a client
> in list mode.
> @item --fork
> Fork off the server process and exit the parent once the server is running.
> address@hidden --pid-file=PATH
> +Store the server's process ID in the given file.
since that is a useful trick to know (the pid file intentionally does
NOT appear until after the socket is ready to go), we should mention it
in the documentation.
I can make that tweak while queueing, if you'd like.
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-block] [PATCH v3 0/5] iotests: Let 233 run concurrently, Max Reitz, 2019/05/08
- [Qemu-block] [PATCH v3 1/5] qemu-nbd: Add --pid-file option, Max Reitz, 2019/05/08
- Re: [Qemu-block] [PATCH v3 1/5] qemu-nbd: Add --pid-file option,
Eric Blake <=
- [Qemu-block] [PATCH v3 2/5] iotests.py: Add qemu_nbd_early_pipe(), Max Reitz, 2019/05/08
- [Qemu-block] [PATCH v3 3/5] qemu-nbd: Do not close stderr, Max Reitz, 2019/05/08
- [Qemu-block] [PATCH v3 4/5] iotests: Use qemu-nbd's --pid-file, Max Reitz, 2019/05/08
- [Qemu-block] [PATCH v3 5/5] iotests: Let 233 run concurrently, Max Reitz, 2019/05/08
- Re: [Qemu-block] [PATCH v3 0/5] iotests: Let 233 run concurrently, Eric Blake, 2019/05/24