yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtiofsd-remove-mountpoint-dummy-argument.patch

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