From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: "open list:Network Block Dev..." <qemu-block@nongnu.org>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PULL 1/9] qemu-nbd: Add --pid-file option
Date: Thu, 13 Jun 2019 10:48:29 -0500 [thread overview]
Message-ID: <20190613154837.21734-2-eblake@redhat.com> (raw)
In-Reply-To: <20190613154837.21734-1-eblake@redhat.com>
From: Max Reitz <mreitz@redhat.com>
--fork is a bit boring if there is no way to get the child's PID. This
option helps.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20190508211820.17851-2-mreitz@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
qemu-nbd.texi | 2 ++
qemu-nbd.c | 11 +++++++++++
2 files changed, 13 insertions(+)
diff --git a/qemu-nbd.texi b/qemu-nbd.texi
index de342c76b873..7f55657722bd 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.
+@item --pid-file=PATH
+Store the server's process ID in the given file.
@item --tls-authz=ID
Specify the ID of a qauthz object previously created with the
--object option. This will be used to authorize connecting users
diff --git a/qemu-nbd.c b/qemu-nbd.c
index e24dd2f76766..99377a3f14e2 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -61,6 +61,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
@@ -113,6 +114,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"
#if HAVE_NBD_DEVICE
"\n"
"Kernel NBD client support:\n"
@@ -641,6 +643,7 @@ int main(int argc, char **argv)
{ "image-opts", no_argument, NULL, QEMU_NBD_OPT_IMAGE_OPTS },
{ "trace", required_argument, NULL, 'T' },
{ "fork", no_argument, NULL, QEMU_NBD_OPT_FORK },
+ { "pid-file", required_argument, NULL, QEMU_NBD_OPT_PID_FILE },
{ NULL, 0, NULL, 0 }
};
int ch;
@@ -667,6 +670,7 @@ int main(int argc, char **argv)
bool list = false;
int old_stderr = -1;
unsigned socket_activation;
+ const char *pid_file_name = NULL;
/* The client thread uses SIGTERM to interrupt the server. A signal
* handler ensures that "qemu-nbd -v -c" exits with a nice status code.
@@ -866,6 +870,9 @@ int main(int argc, char **argv)
case 'L':
list = true;
break;
+ case QEMU_NBD_OPT_PID_FILE:
+ pid_file_name = optarg;
+ break;
}
}
@@ -1186,6 +1193,10 @@ int main(int argc, char **argv)
nbd_update_server_watch();
+ if (pid_file_name) {
+ qemu_write_pidfile(pid_file_name, &error_fatal);
+ }
+
/* now when the initialization is (almost) complete, chdir("/")
* to free any busy filesystems */
if (chdir("/") < 0) {
--
2.20.1
next prev parent reply other threads:[~2019-06-13 17:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 15:48 [Qemu-devel] [PULL 0/9] NBD patches through 2019-06-13 Eric Blake
2019-06-13 15:48 ` Eric Blake [this message]
2019-06-13 15:48 ` [Qemu-devel] [PULL 2/9] iotests.py: Add qemu_nbd_early_pipe() Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 3/9] qemu-nbd: Do not close stderr Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 4/9] iotests: Use qemu-nbd's --pid-file Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 5/9] iotests: Let 233 run concurrently Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 6/9] nbd/server: Nicer spelling of max BLOCK_STATUS reply length Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 7/9] block/nbd-client: drop stale logout Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 8/9] block/nbd: merge nbd-client.* to nbd.c Eric Blake
2019-06-13 15:48 ` [Qemu-devel] [PULL 9/9] block/nbd: merge NBDClientSession struct back to BDRVNBDState Eric Blake
2019-06-13 17:56 ` [Qemu-devel] [PULL 0/9] NBD patches through 2019-06-13 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190613154837.21734-2-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).