render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone

Blame 0041-virtiofsd-add-print-capabilities-option.patch

1d442b
From: Stefan Hajnoczi <stefanha@redhat.com>
1d442b
Date: Mon, 27 Jan 2020 19:01:10 +0000
1d442b
Subject: [PATCH] virtiofsd: add --print-capabilities option
1d442b
MIME-Version: 1.0
1d442b
Content-Type: text/plain; charset=UTF-8
1d442b
Content-Transfer-Encoding: 8bit
1d442b
1d442b
Add the --print-capabilities option as per vhost-user.rst "Backend
1d442b
programs conventions".  Currently there are no advertised features.
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 45018fbb0a73ce66fd3dd87ecd2872b45658add4)
1d442b
---
1d442b
 docs/interop/vhost-user.json     |  4 +++-
1d442b
 tools/virtiofsd/fuse_lowlevel.h  |  1 +
1d442b
 tools/virtiofsd/helper.c         |  2 ++
1d442b
 tools/virtiofsd/passthrough_ll.c | 12 ++++++++++++
1d442b
 4 files changed, 18 insertions(+), 1 deletion(-)
1d442b
1d442b
diff --git a/docs/interop/vhost-user.json b/docs/interop/vhost-user.json
1d442b
index da6aaf51c8..d4ea1f7ac5 100644
1d442b
--- a/docs/interop/vhost-user.json
1d442b
+++ b/docs/interop/vhost-user.json
1d442b
@@ -31,6 +31,7 @@
1d442b
 # @rproc-serial: virtio remoteproc serial link
1d442b
 # @scsi: virtio scsi
1d442b
 # @vsock: virtio vsock transport
1d442b
+# @fs: virtio fs (since 4.2)
1d442b
 #
1d442b
 # Since: 4.0
1d442b
 ##
1d442b
@@ -50,7 +51,8 @@
1d442b
       'rpmsg',
1d442b
       'rproc-serial',
1d442b
       'scsi',
1d442b
-      'vsock'
1d442b
+      'vsock',
1d442b
+      'fs'
1d442b
   ]
1d442b
 }
1d442b
 
1d442b
diff --git a/tools/virtiofsd/fuse_lowlevel.h b/tools/virtiofsd/fuse_lowlevel.h
1d442b
index f6b34700af..0d61df8110 100644
1d442b
--- a/tools/virtiofsd/fuse_lowlevel.h
1d442b
+++ b/tools/virtiofsd/fuse_lowlevel.h
1d442b
@@ -1794,6 +1794,7 @@ struct fuse_cmdline_opts {
1d442b
     int nodefault_subtype;
1d442b
     int show_version;
1d442b
     int show_help;
1d442b
+    int print_capabilities;
1d442b
     unsigned int max_idle_threads;
1d442b
 };
1d442b
 
1d442b
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
1d442b
index a3645fc807..b8ec5ac8dc 100644
1d442b
--- a/tools/virtiofsd/helper.c
1d442b
+++ b/tools/virtiofsd/helper.c
1d442b
@@ -40,6 +40,7 @@ static const struct fuse_opt fuse_helper_opts[] = {
1d442b
     FUSE_HELPER_OPT("--help", show_help),
1d442b
     FUSE_HELPER_OPT("-V", show_version),
1d442b
     FUSE_HELPER_OPT("--version", show_version),
1d442b
+    FUSE_HELPER_OPT("--print-capabilities", print_capabilities),
1d442b
     FUSE_HELPER_OPT("-d", debug),
1d442b
     FUSE_HELPER_OPT("debug", debug),
1d442b
     FUSE_HELPER_OPT("-d", foreground),
1d442b
@@ -135,6 +136,7 @@ void fuse_cmdline_help(void)
1d442b
 {
1d442b
     printf("    -h   --help                print help\n"
1d442b
            "    -V   --version             print version\n"
1d442b
+           "    --print-capabilities       print vhost-user.json\n"
1d442b
            "    -d   -o debug              enable debug output (implies -f)\n"
1d442b
            "    -f                         foreground operation\n"
1d442b
            "    --daemonize                run in background\n"
1d442b
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
1d442b
index 037c5d7b26..cd27c09f59 100644
1d442b
--- a/tools/virtiofsd/passthrough_ll.c
1d442b
+++ b/tools/virtiofsd/passthrough_ll.c
1d442b
@@ -1298,6 +1298,14 @@ static struct fuse_lowlevel_ops lo_oper = {
1d442b
     .lseek = lo_lseek,
1d442b
 };
1d442b
 
1d442b
+/* Print vhost-user.json backend program capabilities */
1d442b
+static void print_capabilities(void)
1d442b
+{
1d442b
+    printf("{\n");
1d442b
+    printf("  \"type\": \"fs\"\n");
1d442b
+    printf("}\n");
1d442b
+}
1d442b
+
1d442b
 int main(int argc, char *argv[])
1d442b
 {
1d442b
     struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
1d442b
@@ -1328,6 +1336,10 @@ int main(int argc, char *argv[])
1d442b
         fuse_lowlevel_version();
1d442b
         ret = 0;
1d442b
         goto err_out1;
1d442b
+    } else if (opts.print_capabilities) {
1d442b
+        print_capabilities();
1d442b
+        ret = 0;
1d442b
+        goto err_out1;
1d442b
     }
1d442b
 
1d442b
     if (fuse_opt_parse(&args, &lo, lo_opts, NULL) == -1) {