[27/30] virtiofsd: make -f (foreground) the default
diff mbox series

Message ID 20191021105832.36574-28-dgilbert@redhat.com
State New
Headers show
Series
  • virtiofs daemon (base)
Related show

Commit Message

Dr. David Alan Gilbert Oct. 21, 2019, 10:58 a.m. UTC
From: Stefan Hajnoczi <stefanha@redhat.com>

According to vhost-user.rst "Backend program conventions", backend
programs should run in the foregound by default.  Follow the
conventions so libvirt and other management tools can control virtiofsd
in a standard way.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 contrib/virtiofsd/helper.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch
diff mbox series

diff --git a/contrib/virtiofsd/helper.c b/contrib/virtiofsd/helper.c
index f67533f053..ab20810c28 100644
--- a/contrib/virtiofsd/helper.c
+++ b/contrib/virtiofsd/helper.c
@@ -26,6 +26,9 @@ 
 
 #define FUSE_HELPER_OPT(t, p) \
 	{ t, offsetof(struct fuse_cmdline_opts, p), 1 }
+#define FUSE_HELPER_OPT_VALUE(t, p, v) \
+	{ t, offsetof(struct fuse_cmdline_opts, p), v }
+
 
 static const struct fuse_opt fuse_helper_opts[] = {
 	FUSE_HELPER_OPT("-h",		show_help),
@@ -39,6 +42,7 @@  static const struct fuse_opt fuse_helper_opts[] = {
 	FUSE_OPT_KEY("-d",		FUSE_OPT_KEY_KEEP),
 	FUSE_OPT_KEY("debug",		FUSE_OPT_KEY_KEEP),
 	FUSE_HELPER_OPT("-f",		foreground),
+	FUSE_HELPER_OPT_VALUE("--daemonize", foreground, 0),
 	FUSE_HELPER_OPT("-s",		singlethread),
 	FUSE_HELPER_OPT("fsname=",	nodefault_subtype),
 	FUSE_OPT_KEY("fsname=",		FUSE_OPT_KEY_KEEP),
@@ -130,6 +134,7 @@  void fuse_cmdline_help(void)
 	       "    -V   --version             print version\n"
 	       "    -d   -o debug              enable debug output (implies -f)\n"
 	       "    -f                         foreground operation\n"
+	       "    --daemonize                run in background\n"
 	       "    -s                         disable multi-threaded operation\n"
 	       "    -o clone_fd                use separate fuse device fd for each thread\n"
 	       "                               (may improve performance)\n"
@@ -160,6 +165,7 @@  int fuse_parse_cmdline(struct fuse_args *args,
 	memset(opts, 0, sizeof(struct fuse_cmdline_opts));
 
 	opts->max_idle_threads = 10;
+	opts->foreground = 1;
 
 	if (fuse_opt_parse(args, opts, fuse_helper_opts,
 			   fuse_helper_opt_proc) == -1)