virtiofsd: implement vhost-user.rst "Backend program conventions"
Subsystems (2)
cover virtiofsd: implement vhost-user.rst "Backend program conventions"
This series implements the conventions for vhost-user backend programs described in vhost-user.rst:
1. Run in the foreground by default.
2. Show vhost-user.json capabilities when --print-capabilities is given.
3. Ship a vhost-user.json file so the program can be discovered.
No command-line options or VHostUserBackendCapabilities are defined for the 'fs' backend type yet. Let's until it becomes clear what should be standard for all 'fs' backends and what is specific to virtiofsd.
Stefan Hajnoczi (4):
virtiofsd: make -f (foreground) the default
virtiofsd: add --print-capabilities option
virtiofsd: install virtiofsd in libexec
virtiofsd: add vhost-user.json file
docs/interop/vhost-user.json | 4 +++- Makefile | 3 +++ contrib/virtiofsd/fuse_lowlevel.h | 1 + contrib/virtiofsd/helper.c | 5 +++++ contrib/virtiofsd/passthrough_ll.c | 12 ++++++++++++ .gitignore | 1 + contrib/virtiofsd/50-qemu-virtiofsd.json.in | 5 +++++ 7 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 contrib/virtiofsd/50-qemu-virtiofsd.json.in
Signature · 1 line
2.21.0
PATCH 1/4 virtiofsd: make -f (foreground) the default
According to vhost-user.rst "Backend program conventions", backend programs should run in the foregound by default. Follow the conventions so libvirt and other management tools can control virtiofsd in a standard way.
--- contrib/virtiofsd/helper.c | 3 +++ 1 file changed, 3 insertions(+)
contrib/virtiofsd/helper.c +3 -0
@@ -42,6 +42,7 @@ static const struct fuse_opt fuse_helper_opts[] = {FUSE_OPT_KEY ("-d" ,FUSE_OPT_KEY_KEEP ),FUSE_OPT_KEY ("debug" ,FUSE_OPT_KEY_KEEP ),FUSE_HELPER_OPT ("-f" , foreground), +FUSE_HELPER_OPT_VALUE ("--daemonize" , foreground,0 ),FUSE_HELPER_OPT ("-s" , singlethread),FUSE_HELPER_OPT ("fsname=" , nodefault_subtype), FUSE_OPT_KEY("fsname=", FUSE_OPT_KEY_KEEP),
@@ -139,6 +140,7 @@ void fuse_cmdline_help(void)" -d -o debug enable debug output (implies -f)\n" " --syslog log to syslog (default stderr)\n" " -f foreground operation\n" +" --daemonize run in background\n" " -s disable multi-threaded operation\n" " -o clone_fd use separate fuse device fd for each thread\n" " (may improve performance)\n"
@@ -171,6 +173,7 @@ int fuse_parse_cmdline(struct fuse_args *args,memset (opts,0 ,sizeof (struct fuse_cmdline_opts )); opts->max_idle_threads =10 ; + opts->foreground =1 ;if (fuse_opt_parse (args, opts, fuse_helper_opts, fuse_helper_opt_proc) ==-1 )
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH 1/4] virtiofsd: make -f (foreground) the default
Quoted 6 lines · * Stefan Hajnoczi ([email protected]) wrote:
According to
vhost-user.rst"Backend program conventions", backend programs should run in the foregound by default. Follow the conventions so libvirt and other management tools can control virtiofsd in a standard way.Signed-off-by Stefan Hajnoczi <[email protected]>
Quoted 35 lines
--- contrib/virtiofsd/helper.c | 3 +++ 1 file changed, 3 insertions(+)contrib/virtiofsd/helper.c +3
-0@@ -42,6 +42,7 @@ static const struct fuse_opt fuse_helper_opts[] = {FUSE_OPT_KEY ("-d" ,FUSE_OPT_KEY_KEEP ),FUSE_OPT_KEY ("debug" ,FUSE_OPT_KEY_KEEP ),FUSE_HELPER_OPT ("-f" , foreground), +FUSE_HELPER_OPT_VALUE ("--daemonize" , foreground,0 ),FUSE_HELPER_OPT ("-s" , singlethread),FUSE_HELPER_OPT ("fsname=" , nodefault_subtype), FUSE_OPT_KEY("fsname=", FUSE_OPT_KEY_KEEP),@@ -139,6 +140,7 @@ void fuse_cmdline_help(void)" -d -o debug enable debug output (implies -f)\n" " --syslog log to syslog (default stderr)\n" " -f foreground operation\n" +" --daemonize run in background\n" " -s disable multi-threaded operation\n" " -o clone_fd use separate fuse device fd for each thread\n" " (may improve performance)\n" @@ -171,6 +173,7 @@ int fuse_parse_cmdline(struct fuse_args *args,memset (opts,0 ,sizeof (struct fuse_cmdline_opts )); opts->max_idle_threads =10 ; + opts->foreground =1 ;if (fuse_opt_parse (args, opts, fuse_helper_opts, fuse_helper_opt_proc) ==-1 )Signature · 1 line
2.21.0
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 2/4 virtiofsd: add --print-capabilities option
In reply to Stefan HajnocziAdd the --print-capabilities option as per vhost-user.rst "Backend programs conventions". Currently there are no advertised features.
--- 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(-)
docs/interop/vhost-user.json +3 -1
@@ -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' ] }
contrib/virtiofsd/fuse_lowlevel.h +1 -0
@@ -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;
contrib/virtiofsd/helper.c +2 -0
@@ -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"
contrib/virtiofsd/passthrough_ll.c +12 -0
@@ -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 )
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH 2/4] virtiofsd: add --print-capabilities option
Quoted 4 lines · * Stefan Hajnoczi ([email protected]) 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 <[email protected]>
That looks OK to me, but can someone who understands the json requirement explain what says whether a 'features' entry is optional?
Dave
Quoted 94 lines
--- 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(-)docs/interop/vhost-user.json +3
-1@@ -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' ] }contrib/virtiofsd/fuse_lowlevel.h +1
-0@@ -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;contrib/virtiofsd/helper.c +2
-0@@ -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"contrib/virtiofsd/passthrough_ll.c +12
-0@@ -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 )Signature · 1 line
2.21.0
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 2/4] virtiofsd: add --print-capabilities option
Quoted 8 lines · Dr. David Alan Gilbert
Quoted 4 lines · * Stefan Hajnoczi ([email protected]) 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 <[email protected]>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
Re: [Qemu-devel] [PATCH 2/4] virtiofsd: add --print-capabilities option
Quoted 10 lines · Stefan Hajnoczi
Quoted 8 lines · Dr. David Alan Gilbert
Quoted 4 lines · * Stefan Hajnoczi ([email protected]) 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 <[email protected]>That looks OK to me, but can someone who understands the json requirement explain what says whether a 'features' entry is optional?
Quoted 6 lines
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
Re: [Qemu-devel] [PATCH 2/4] virtiofsd: add --print-capabilities option
In reply to Stefan HajnocziHi
Quoted 5 lines · Stefan Hajnoczi
Add the --print-capabilities option as per
vhost-user.rst"Backend programs conventions". Currently there are no advertised features.Signed-off-by Stefan Hajnoczi <[email protected]>
Quoted 94 lines
--- 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(-)docs/interop/vhost-user.json +3
-1@@ -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' ] }contrib/virtiofsd/fuse_lowlevel.h +1
-0@@ -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;contrib/virtiofsd/helper.c +2
-0@@ -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"contrib/virtiofsd/passthrough_ll.c +12
-1@@ -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
PATCH 3/4 virtiofsd: install virtiofsd in libexec
In reply to Stefan HajnocziBuild and install virtiofsd on Linux hosts. This is also how vhost-user-gpu is handled.
--- Makefile | 2 ++ 1 file changed, 2 insertions(+)
Makefile +2 -0
@@ -317,6 +317,8 @@ HELPERS-y = HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF) ifdef CONFIG_LINUX +HELPERS-y += virtiofsd$(EXESUF) + ifdef CONFIG_VIRGL ifdef CONFIG_GBM HELPERS-y += vhost-user-gpu$(EXESUF)
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH 3/4] virtiofsd: install virtiofsd in libexec
Quoted 4 lines · * Stefan Hajnoczi ([email protected]) wrote:
Build and install virtiofsd on Linux hosts. This is also how vhost-user-gpu is handled.
Signed-off-by Stefan Hajnoczi <[email protected]>
Quoted 20 lines
--- Makefile | 2 ++ 1 file changed, 2 insertions(+)Makefile +2
-0@@ -317,6 +317,8 @@ HELPERS-y = HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF) ifdef CONFIG_LINUX +HELPERS-y += virtiofsd$(EXESUF) + ifdef CONFIG_VIRGL ifdef CONFIG_GBM HELPERS-y += vhost-user-gpu$(EXESUF)Signature · 1 line
2.21.0
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 4/4 virtiofsd: add vhost-user.json file
In reply to Stefan HajnocziInstall a vhost-user.json file describing virtiofsd. This allows libvirt and other management tools to enumerate vhost-user backend programs.
--- Makefile | 1 + .gitignore | 1 + contrib/virtiofsd/50-qemu-virtiofsd.json.in | 5 +++++ 3 files changed, 7 insertions(+) create mode 100644 contrib/virtiofsd/50-qemu-virtiofsd.json.in
Makefile +1 -0
@@ -318,6 +318,7 @@ HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXE ifdef CONFIG_LINUX HELPERS-y += virtiofsd$(EXESUF) +vhost-user-json-y += contrib/virtiofsd/50-qemu-virtiofsd.json ifdef CONFIG_VIRGL ifdef CONFIG_GBM
.gitignore +1 -0
@@ -6,6 +6,7 @@ /config-target.* /config.status /config-temp +/contrib/virtiofsd/50-qemu-virtiofsd.json /elf2dmp /trace-events-all /trace/generated-events.h
contrib/virtiofsd/50-qemu-virtiofsd.json.in new file +5 -0
@@ -0,0 +1,5 @@ +{ + "description": "QEMU virtiofsd vhost-user-fs", + "type": "fs", + "binary": "@libexecdir@/virtiofsd" +}
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH 4/4] virtiofsd: add vhost-user.json file
Quoted 5 lines · * Stefan Hajnoczi ([email protected]) wrote:
Install a vhost-user.json file describing virtiofsd. This allows libvirt and other management tools to enumerate vhost-user backend programs.
Signed-off-by Stefan Hajnoczi <[email protected]>
Quoted 45 lines
--- Makefile | 1 + .gitignore | 1 + contrib/virtiofsd/50-qemu-virtiofsd.json.in | 5 +++++ 3 files changed, 7 insertions(+) create mode 100644 contrib/virtiofsd/50-qemu-virtiofsd.json.inMakefile +1
-0@@ -318,6 +318,7 @@ HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXE ifdef CONFIG_LINUX HELPERS-y += virtiofsd$(EXESUF) +vhost-user-json-y += contrib/virtiofsd/50-qemu-virtiofsd.json ifdef CONFIG_VIRGL ifdef CONFIG_GBM.gitignore +1
-0@@ -6,6 +6,7 @@ /config-target.* /config.status /config-temp +/contrib/virtiofsd/50-qemu-virtiofsd.json /elf2dmp /trace-events-all /trace/generated-events.hcontrib/virtiofsd/50-qemu-virtiofsd.json.in new file +5
-0@@ -0,0 +1,5 @@ +{ + "description": "QEMU virtiofsd vhost-user-fs", + "type": "fs", + "binary": "@libexecdir@/virtiofsd" +}Signature · 1 line
2.21.0
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 9 lines · * Stefan Hajnoczi ([email protected]) wrote:
This series implements the conventions for vhost-user backend programs described in
vhost-user.rst:
1. Run in the foreground by default.
2. Show vhost-user.json capabilities when --print-capabilities is given.
3. Ship a vhost-user.json file so the program can be discovered.No command-line options or VHostUserBackendCapabilities are defined for the 'fs' backend type yet. Let's until it becomes clear what should be standard for all 'fs' backends and what is specific to virtiofsd.
1,3,4 merged; 2 waiting on reivew from someone who understands the json requirement.
Quoted 7 lines
Stefan Hajnoczi (4):
virtiofsd: make -f (foreground) the default
virtiofsd: add --print-capabilities option
virtiofsd: install virtiofsd in libexec
virtiofsd: add vhost-user.json file
Quoted 13 lines
docs/interop/vhost-user.json | 4 +++- Makefile | 3 +++ contrib/virtiofsd/fuse_lowlevel.h | 1 + contrib/virtiofsd/helper.c | 5 +++++ contrib/virtiofsd/passthrough_ll.c | 12 ++++++++++++ .gitignore | 1 + contrib/virtiofsd/50-qemu-virtiofsd.json.in | 5 +++++ 7 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 contrib/virtiofsd/50-qemu-virtiofsd.json.inSignature · 1 line
2.21.0
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK