22c213
From a8a1835a82510be7d2d6edcc28a60e506a2cedad Mon Sep 17 00:00:00 2001
22c213
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
22c213
Date: Mon, 27 Jan 2020 19:00:46 +0100
22c213
Subject: [PATCH 015/116] virtiofsd: remove mountpoint dummy argument
22c213
MIME-Version: 1.0
22c213
Content-Type: text/plain; charset=UTF-8
22c213
Content-Transfer-Encoding: 8bit
22c213
22c213
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
Message-id: <20200127190227.40942-12-dgilbert@redhat.com>
22c213
Patchwork-id: 93466
22c213
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 011/112] virtiofsd: remove mountpoint dummy argument
22c213
Bugzilla: 1694164
22c213
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22c213
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
22c213
22c213
From: Stefan Hajnoczi <stefanha@redhat.com>
22c213
22c213
Classic FUSE file system daemons take a mountpoint argument but
22c213
virtiofsd exposes a vhost-user UNIX domain socket instead.  The
22c213
mountpoint argument is not used by virtiofsd but the user is still
22c213
required to pass a dummy argument on the command-line.
22c213
22c213
Remove the mountpoint argument to clean up the command-line.
22c213
22c213
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
22c213
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
(cherry picked from commit 67aab02272f6cb47c56420f60b370c184961b5ca)
22c213
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
22c213
---
22c213
 tools/virtiofsd/fuse_lowlevel.c  |  2 +-
22c213
 tools/virtiofsd/fuse_lowlevel.h  |  4 +---
22c213
 tools/virtiofsd/helper.c         | 20 +++-----------------
22c213
 tools/virtiofsd/passthrough_ll.c | 12 ++----------
22c213
 4 files changed, 7 insertions(+), 31 deletions(-)
22c213
22c213
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
22c213
index 5c9cb52..2f32c68 100644
22c213
--- a/tools/virtiofsd/fuse_lowlevel.c
22c213
+++ b/tools/virtiofsd/fuse_lowlevel.c
22c213
@@ -2455,7 +2455,7 @@ out1:
22c213
     return NULL;
22c213
 }
22c213
 
22c213
-int fuse_session_mount(struct fuse_session *se, const char *mountpoint)
22c213
+int fuse_session_mount(struct fuse_session *se)
22c213
 {
22c213
     int fd;
22c213
 
22c213
diff --git a/tools/virtiofsd/fuse_lowlevel.h b/tools/virtiofsd/fuse_lowlevel.h
22c213
index adb9054..8d8909b 100644
22c213
--- a/tools/virtiofsd/fuse_lowlevel.h
22c213
+++ b/tools/virtiofsd/fuse_lowlevel.h
22c213
@@ -1863,7 +1863,6 @@ struct fuse_cmdline_opts {
22c213
     int foreground;
22c213
     int debug;
22c213
     int nodefault_subtype;
22c213
-    char *mountpoint;
22c213
     int show_version;
22c213
     int show_help;
22c213
     unsigned int max_idle_threads;
22c213
@@ -1924,12 +1923,11 @@ struct fuse_session *fuse_session_new(struct fuse_args *args,
22c213
 /**
22c213
  * Mount a FUSE file system.
22c213
  *
22c213
- * @param mountpoint the mount point path
22c213
  * @param se session object
22c213
  *
22c213
  * @return 0 on success, -1 on failure.
22c213
  **/
22c213
-int fuse_session_mount(struct fuse_session *se, const char *mountpoint);
22c213
+int fuse_session_mount(struct fuse_session *se);
22c213
 
22c213
 /**
22c213
  * Enter a single threaded, blocking event loop.
22c213
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
22c213
index 5711dd2..5e6f205 100644
22c213
--- a/tools/virtiofsd/helper.c
22c213
+++ b/tools/virtiofsd/helper.c
22c213
@@ -140,27 +140,13 @@ void fuse_cmdline_help(void)
22c213
 static int fuse_helper_opt_proc(void *data, const char *arg, int key,
22c213
                                 struct fuse_args *outargs)
22c213
 {
22c213
+    (void)data;
22c213
     (void)outargs;
22c213
-    struct fuse_cmdline_opts *opts = data;
22c213
 
22c213
     switch (key) {
22c213
     case FUSE_OPT_KEY_NONOPT:
22c213
-        if (!opts->mountpoint) {
22c213
-            if (fuse_mnt_parse_fuse_fd(arg) != -1) {
22c213
-                return fuse_opt_add_opt(&opts->mountpoint, arg);
22c213
-            }
22c213
-
22c213
-            char mountpoint[PATH_MAX] = "";
22c213
-            if (realpath(arg, mountpoint) == NULL) {
22c213
-                fuse_log(FUSE_LOG_ERR, "fuse: bad mount point `%s': %s\n", arg,
22c213
-                         strerror(errno));
22c213
-                return -1;
22c213
-            }
22c213
-            return fuse_opt_add_opt(&opts->mountpoint, mountpoint);
22c213
-        } else {
22c213
-            fuse_log(FUSE_LOG_ERR, "fuse: invalid argument `%s'\n", arg);
22c213
-            return -1;
22c213
-        }
22c213
+        fuse_log(FUSE_LOG_ERR, "fuse: invalid argument `%s'\n", arg);
22c213
+        return -1;
22c213
 
22c213
     default:
22c213
         /* Pass through unknown options */
22c213
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
22c213
index c5850ef..9377718 100644
22c213
--- a/tools/virtiofsd/passthrough_ll.c
22c213
+++ b/tools/virtiofsd/passthrough_ll.c
22c213
@@ -1297,7 +1297,7 @@ int main(int argc, char *argv[])
22c213
         return 1;
22c213
     }
22c213
     if (opts.show_help) {
22c213
-        printf("usage: %s [options] <mountpoint>\n\n", argv[0]);
22c213
+        printf("usage: %s [options]\n\n", argv[0]);
22c213
         fuse_cmdline_help();
22c213
         fuse_lowlevel_help();
22c213
         ret = 0;
22c213
@@ -1308,13 +1308,6 @@ int main(int argc, char *argv[])
22c213
         goto err_out1;
22c213
     }
22c213
 
22c213
-    if (opts.mountpoint == NULL) {
22c213
-        printf("usage: %s [options] <mountpoint>\n", argv[0]);
22c213
-        printf("       %s --help\n", argv[0]);
22c213
-        ret = 1;
22c213
-        goto err_out1;
22c213
-    }
22c213
-
22c213
     if (fuse_opt_parse(&args, &lo, lo_opts, NULL) == -1) {
22c213
         return 1;
22c213
     }
22c213
@@ -1374,7 +1367,7 @@ int main(int argc, char *argv[])
22c213
         goto err_out2;
22c213
     }
22c213
 
22c213
-    if (fuse_session_mount(se, opts.mountpoint) != 0) {
22c213
+    if (fuse_session_mount(se) != 0) {
22c213
         goto err_out3;
22c213
     }
22c213
 
22c213
@@ -1393,7 +1386,6 @@ err_out3:
22c213
 err_out2:
22c213
     fuse_session_destroy(se);
22c213
 err_out1:
22c213
-    free(opts.mountpoint);
22c213
     fuse_opt_free_args(&args);
22c213
 
22c213
     if (lo.root.fd >= 0) {
22c213
-- 
22c213
1.8.3.1
22c213