From: Raphael Norwitz <raphael.norwitz@nutanix.com>
To: "mst@redhat.com" <mst@redhat.com>,
"peter.maydell@linaro.org" <peter.maydell@linaro.org>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"mreitz@redhat.com" <mreitz@redhat.com>,
"stefanha@redhat.com" <stefanha@redhat.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
Raphael Norwitz <raphael.norwitz@nutanix.com>,
"eblake@redhat.com" <eblake@redhat.com>,
"sgarzare@redhat.com" <sgarzare@redhat.com>
Subject: [PATCH 1/2] storage-daemon: add opt to print when initialized
Date: Fri, 27 Aug 2021 16:50:35 +0000 [thread overview]
Message-ID: <20210827164954.13951-1-raphael.norwitz@nutanix.com> (raw)
This change adds a command line option to print a line to standard out
when the storage daemon has completed initialization and is ready to
serve client connections.
This option will be used to resolve a hang in the vhost-user-blk-test.
Signed-off-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
---
storage-daemon/qemu-storage-daemon.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index fc8b150629..c4f76d1564 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -61,6 +61,9 @@
static const char *pid_file;
static volatile bool exit_requested = false;
+static bool print_setup;
+
+const char *init_msg = "Block exports setup\n";
void qemu_system_killed(int signal, pid_t pid)
{
@@ -82,6 +85,7 @@ static void help(void)
" -T, --trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
" specify tracing options\n"
" -V, --version output version information and exit\n"
+" -P, --printset print to stdout once server is fully initialized\n"
"\n"
" --blockdev [driver=]<driver>[,node-name=<N>][,discard=ignore|unmap]\n"
" [,cache.direct=on|off][,cache.no-flush=on|off]\n"
@@ -174,6 +178,7 @@ static void process_options(int argc, char *argv[])
{"nbd-server", required_argument, NULL, OPTION_NBD_SERVER},
{"object", required_argument, NULL, OPTION_OBJECT},
{"pidfile", required_argument, NULL, OPTION_PIDFILE},
+ {"printset", no_argument, NULL, 'P'},
{"trace", required_argument, NULL, 'T'},
{"version", no_argument, NULL, 'V'},
{0, 0, 0, 0}
@@ -195,6 +200,9 @@ static void process_options(int argc, char *argv[])
trace_opt_parse(optarg);
trace_init_file();
break;
+ case 'P':
+ print_setup = true;
+ break;
case 'V':
printf("qemu-storage-daemon version "
QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
@@ -310,6 +318,7 @@ static void pid_file_init(void)
int main(int argc, char *argv[])
{
+ int err;
#ifdef CONFIG_POSIX
signal(SIGPIPE, SIG_IGN);
#endif
@@ -341,6 +350,18 @@ int main(int argc, char *argv[])
*/
pid_file_init();
+ /*
+ * If requested to pipe output once exports are initialized, print to
+ * stdout.
+ */
+ if (print_setup) {
+ err = write(1, init_msg, strlen(init_msg));
+ if (err == -1) {
+ fprintf(stderr, "Write to pipe failed: %m\n");
+ return -1;
+ }
+ }
+
while (!exit_requested) {
main_loop_wait(false);
}
--
2.20.1
next reply other threads:[~2021-08-27 16:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-27 16:50 Raphael Norwitz [this message]
2021-08-27 16:50 ` [PATCH 2/2] Prevent vhost-user-blk-test hang Raphael Norwitz
2021-08-27 18:55 ` eblake
2021-08-27 18:51 ` [PATCH 1/2] storage-daemon: add opt to print when initialized eblake
2021-08-30 15:56 ` Raphael Norwitz
2021-08-30 16:05 ` eblake
2021-08-30 21:51 ` Michael S. Tsirkin
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=20210827164954.13951-1-raphael.norwitz@nutanix.com \
--to=raphael.norwitz@nutanix.com \
--cc=eblake@redhat.com \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
/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).