dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0017-virtiofsd-remove-mountpoint-dummy-argument.patch

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