diff mbox series

[2/4] virtiofsd: add --print-capabilities option

Message ID 20190827095437.18819-3-stefanha@redhat.com
State New
Headers show
Series virtiofsd: implement vhost-user.rst "Backend program conventions" | expand

Commit Message

Stefan Hajnoczi Aug. 27, 2019, 9:54 a.m. UTC
Add the --print-capabilities option as per vhost-user.rst "Backend
programs conventions".  Currently there are no advertised features.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 docs/interop/vhost-user.json       |  4 +++-
 contrib/virtiofsd/fuse_lowlevel.h  |  1 +
 contrib/virtiofsd/helper.c         |  2 ++
 contrib/virtiofsd/passthrough_ll.c | 12 ++++++++++++
 4 files changed, 18 insertions(+), 1 deletion(-)

Comments

Dr. David Alan Gilbert Sept. 3, 2019, 5:26 p.m. UTC | #1
* Stefan Hajnoczi (stefanha@redhat.com) wrote:
> Add the --print-capabilities option as per vhost-user.rst "Backend
> programs conventions".  Currently there are no advertised features.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

That looks OK to me, but can someone who understands the json
requirement explain what says whether a 'features' entry is optional?

Dave

> ---
>  docs/interop/vhost-user.json       |  4 +++-
>  contrib/virtiofsd/fuse_lowlevel.h  |  1 +
>  contrib/virtiofsd/helper.c         |  2 ++
>  contrib/virtiofsd/passthrough_ll.c | 12 ++++++++++++
>  4 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/docs/interop/vhost-user.json b/docs/interop/vhost-user.json
> index da6aaf51c8..d4ea1f7ac5 100644
> --- a/docs/interop/vhost-user.json
> +++ b/docs/interop/vhost-user.json
> @@ -31,6 +31,7 @@
>  # @rproc-serial: virtio remoteproc serial link
>  # @scsi: virtio scsi
>  # @vsock: virtio vsock transport
> +# @fs: virtio fs (since 4.2)
>  #
>  # Since: 4.0
>  ##
> @@ -50,7 +51,8 @@
>        'rpmsg',
>        'rproc-serial',
>        'scsi',
> -      'vsock'
> +      'vsock',
> +      'fs'
>    ]
>  }
>  
> diff --git a/contrib/virtiofsd/fuse_lowlevel.h b/contrib/virtiofsd/fuse_lowlevel.h
> index b441d3dfed..e3d8747571 100644
> --- a/contrib/virtiofsd/fuse_lowlevel.h
> +++ b/contrib/virtiofsd/fuse_lowlevel.h
> @@ -1796,6 +1796,7 @@ struct fuse_cmdline_opts {
>  	int nodefault_subtype;
>  	int show_version;
>  	int show_help;
> +	int print_capabilities;
>  	int clone_fd;
>  	int syslog;
>  	int log_level;
> diff --git a/contrib/virtiofsd/helper.c b/contrib/virtiofsd/helper.c
> index 8d8bca889b..84bf1c834d 100644
> --- a/contrib/virtiofsd/helper.c
> +++ b/contrib/virtiofsd/helper.c
> @@ -35,6 +35,7 @@ static const struct fuse_opt fuse_helper_opts[] = {
>  	FUSE_HELPER_OPT("--help",	show_help),
>  	FUSE_HELPER_OPT("-V",		show_version),
>  	FUSE_HELPER_OPT("--version",	show_version),
> +	FUSE_HELPER_OPT("--print-capabilities", print_capabilities),
>  	FUSE_HELPER_OPT("-d",		debug),
>  	FUSE_HELPER_OPT("debug",	debug),
>  	FUSE_HELPER_OPT("-d",		foreground),
> @@ -137,6 +138,7 @@ void fuse_cmdline_help(void)
>  {
>  	printf("    -h   --help                print help\n"
>  	       "    -V   --version             print version\n"
> +	       "    --print-capabilities       print vhost-user.json\n"
>  	       "    -d   -o debug              enable debug output (implies -f)\n"
>  	       "    --syslog                   log to syslog (default stderr)\n"
>  	       "    -f                         foreground operation\n"
> diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthrough_ll.c
> index 0ef01b7e3f..e2e20f22cd 100644
> --- a/contrib/virtiofsd/passthrough_ll.c
> +++ b/contrib/virtiofsd/passthrough_ll.c
> @@ -2879,6 +2879,14 @@ static void fuse_lo_data_cleanup(struct lo_data *lo)
>          free((char *)lo->source);
>  }
>  
> +/* Print vhost-user.json backend program capabilities */
> +static void print_capabilities(void)
> +{
> +	printf("{\n");
> +	printf("  \"type\": \"fs\"\n");
> +	printf("}\n");
> +}
> +
>  int main(int argc, char *argv[])
>  {
>  	struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
> @@ -2931,6 +2939,10 @@ int main(int argc, char *argv[])
>  		fuse_lowlevel_version();
>  		ret = 0;
>  		goto err_out1;
> +	} else if (opts.print_capabilities) {
> +		print_capabilities();
> +		ret = 0;
> +		goto err_out1;
>  	}
>  
>  	if (fuse_opt_parse(&args, &lo, lo_opts, NULL)== -1)
> -- 
> 2.21.0
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Stefan Hajnoczi Sept. 4, 2019, 3:51 p.m. UTC | #2
On Tue, Sep 03, 2019 at 06:26:44PM +0100, Dr. David Alan Gilbert wrote:
> * Stefan Hajnoczi (stefanha@redhat.com) wrote:
> > Add the --print-capabilities option as per vhost-user.rst "Backend
> > programs conventions".  Currently there are no advertised features.
> > 
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> 
> That looks OK to me, but can someone who understands the json
> requirement explain what says whether a 'features' entry is optional?

I have defined a VHostUserBackendType ('fs') but no
VHostUserBackendCapabilities union field.

I guess this is allowed since many other VIRTIO device types are also
defined without a VHostUserBackendCapabilities union field (only 'gpu'
and 'input' have one).

Stefan
Stefan Hajnoczi Sept. 12, 2019, 11:12 a.m. UTC | #3
On Wed, Sep 04, 2019 at 04:51:21PM +0100, Stefan Hajnoczi wrote:
> On Tue, Sep 03, 2019 at 06:26:44PM +0100, Dr. David Alan Gilbert wrote:
> > * Stefan Hajnoczi (stefanha@redhat.com) wrote:
> > > Add the --print-capabilities option as per vhost-user.rst "Backend
> > > programs conventions".  Currently there are no advertised features.
> > > 
> > > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > 
> > That looks OK to me, but can someone who understands the json
> > requirement explain what says whether a 'features' entry is optional?
> 
> I have defined a VHostUserBackendType ('fs') but no
> VHostUserBackendCapabilities union field.
> 
> I guess this is allowed since many other VIRTIO device types are also
> defined without a VHostUserBackendCapabilities union field (only 'gpu'
> and 'input' have one).

Hi Marc-André,
Please review when you have time.  You are the vhost-user.json expert
:).

Stefan
Marc-André Lureau Sept. 12, 2019, 12:40 p.m. UTC | #4
Hi

On Tue, Aug 27, 2019 at 1:55 PM Stefan Hajnoczi <stefanha@redhat.com> wrote:
>
> Add the --print-capabilities option as per vhost-user.rst "Backend
> programs conventions".  Currently there are no advertised features.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  docs/interop/vhost-user.json       |  4 +++-
>  contrib/virtiofsd/fuse_lowlevel.h  |  1 +
>  contrib/virtiofsd/helper.c         |  2 ++
>  contrib/virtiofsd/passthrough_ll.c | 12 ++++++++++++
>  4 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/docs/interop/vhost-user.json b/docs/interop/vhost-user.json
> index da6aaf51c8..d4ea1f7ac5 100644
> --- a/docs/interop/vhost-user.json
> +++ b/docs/interop/vhost-user.json
> @@ -31,6 +31,7 @@
>  # @rproc-serial: virtio remoteproc serial link
>  # @scsi: virtio scsi
>  # @vsock: virtio vsock transport
> +# @fs: virtio fs (since 4.2)
>  #
>  # Since: 4.0
>  ##
> @@ -50,7 +51,8 @@
>        'rpmsg',
>        'rproc-serial',
>        'scsi',
> -      'vsock'
> +      'vsock',
> +      'fs'
>    ]
>  }
>
> diff --git a/contrib/virtiofsd/fuse_lowlevel.h b/contrib/virtiofsd/fuse_lowlevel.h
> index b441d3dfed..e3d8747571 100644
> --- a/contrib/virtiofsd/fuse_lowlevel.h
> +++ b/contrib/virtiofsd/fuse_lowlevel.h
> @@ -1796,6 +1796,7 @@ struct fuse_cmdline_opts {
>         int nodefault_subtype;
>         int show_version;
>         int show_help;
> +       int print_capabilities;
>         int clone_fd;
>         int syslog;
>         int log_level;
> diff --git a/contrib/virtiofsd/helper.c b/contrib/virtiofsd/helper.c
> index 8d8bca889b..84bf1c834d 100644
> --- a/contrib/virtiofsd/helper.c
> +++ b/contrib/virtiofsd/helper.c
> @@ -35,6 +35,7 @@ static const struct fuse_opt fuse_helper_opts[] = {
>         FUSE_HELPER_OPT("--help",       show_help),
>         FUSE_HELPER_OPT("-V",           show_version),
>         FUSE_HELPER_OPT("--version",    show_version),
> +       FUSE_HELPER_OPT("--print-capabilities", print_capabilities),
>         FUSE_HELPER_OPT("-d",           debug),
>         FUSE_HELPER_OPT("debug",        debug),
>         FUSE_HELPER_OPT("-d",           foreground),
> @@ -137,6 +138,7 @@ void fuse_cmdline_help(void)
>  {
>         printf("    -h   --help                print help\n"
>                "    -V   --version             print version\n"
> +              "    --print-capabilities       print vhost-user.json\n"
>                "    -d   -o debug              enable debug output (implies -f)\n"
>                "    --syslog                   log to syslog (default stderr)\n"
>                "    -f                         foreground operation\n"
> diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthrough_ll.c
> index 0ef01b7e3f..e2e20f22cd 100644
> --- a/contrib/virtiofsd/passthrough_ll.c
> +++ b/contrib/virtiofsd/passthrough_ll.c
> @@ -2879,6 +2879,14 @@ static void fuse_lo_data_cleanup(struct lo_data *lo)
>          free((char *)lo->source);
>  }
>
> +/* Print vhost-user.json backend program capabilities */
> +static void print_capabilities(void)
> +{
> +       printf("{\n");
> +       printf("  \"type\": \"fs\"\n");
> +       printf("}\n");
> +}
> +
>  int main(int argc, char *argv[])
>  {
>         struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
> @@ -2931,6 +2939,10 @@ int main(int argc, char *argv[])
>                 fuse_lowlevel_version();
>                 ret = 0;
>                 goto err_out1;
> +       } else if (opts.print_capabilities) {
> +               print_capabilities();
> +               ret = 0;
> +               goto err_out1;
>         }
>
>         if (fuse_opt_parse(&args, &lo, lo_opts, NULL)== -1)
> --
> 2.21.0
>
diff mbox series

Patch

diff --git a/docs/interop/vhost-user.json b/docs/interop/vhost-user.json
index da6aaf51c8..d4ea1f7ac5 100644
--- a/docs/interop/vhost-user.json
+++ b/docs/interop/vhost-user.json
@@ -31,6 +31,7 @@ 
 # @rproc-serial: virtio remoteproc serial link
 # @scsi: virtio scsi
 # @vsock: virtio vsock transport
+# @fs: virtio fs (since 4.2)
 #
 # Since: 4.0
 ##
@@ -50,7 +51,8 @@ 
       'rpmsg',
       'rproc-serial',
       'scsi',
-      'vsock'
+      'vsock',
+      'fs'
   ]
 }
 
diff --git a/contrib/virtiofsd/fuse_lowlevel.h b/contrib/virtiofsd/fuse_lowlevel.h
index b441d3dfed..e3d8747571 100644
--- a/contrib/virtiofsd/fuse_lowlevel.h
+++ b/contrib/virtiofsd/fuse_lowlevel.h
@@ -1796,6 +1796,7 @@  struct fuse_cmdline_opts {
 	int nodefault_subtype;
 	int show_version;
 	int show_help;
+	int print_capabilities;
 	int clone_fd;
 	int syslog;
 	int log_level;
diff --git a/contrib/virtiofsd/helper.c b/contrib/virtiofsd/helper.c
index 8d8bca889b..84bf1c834d 100644
--- a/contrib/virtiofsd/helper.c
+++ b/contrib/virtiofsd/helper.c
@@ -35,6 +35,7 @@  static const struct fuse_opt fuse_helper_opts[] = {
 	FUSE_HELPER_OPT("--help",	show_help),
 	FUSE_HELPER_OPT("-V",		show_version),
 	FUSE_HELPER_OPT("--version",	show_version),
+	FUSE_HELPER_OPT("--print-capabilities", print_capabilities),
 	FUSE_HELPER_OPT("-d",		debug),
 	FUSE_HELPER_OPT("debug",	debug),
 	FUSE_HELPER_OPT("-d",		foreground),
@@ -137,6 +138,7 @@  void fuse_cmdline_help(void)
 {
 	printf("    -h   --help                print help\n"
 	       "    -V   --version             print version\n"
+	       "    --print-capabilities       print vhost-user.json\n"
 	       "    -d   -o debug              enable debug output (implies -f)\n"
 	       "    --syslog                   log to syslog (default stderr)\n"
 	       "    -f                         foreground operation\n"
diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthrough_ll.c
index 0ef01b7e3f..e2e20f22cd 100644
--- a/contrib/virtiofsd/passthrough_ll.c
+++ b/contrib/virtiofsd/passthrough_ll.c
@@ -2879,6 +2879,14 @@  static void fuse_lo_data_cleanup(struct lo_data *lo)
         free((char *)lo->source);
 }
 
+/* Print vhost-user.json backend program capabilities */
+static void print_capabilities(void)
+{
+	printf("{\n");
+	printf("  \"type\": \"fs\"\n");
+	printf("}\n");
+}
+
 int main(int argc, char *argv[])
 {
 	struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
@@ -2931,6 +2939,10 @@  int main(int argc, char *argv[])
 		fuse_lowlevel_version();
 		ret = 0;
 		goto err_out1;
+	} else if (opts.print_capabilities) {
+		print_capabilities();
+		ret = 0;
+		goto err_out1;
 	}
 
 	if (fuse_opt_parse(&args, &lo, lo_opts, NULL)== -1)