This fixes the virtfs documentation (LP 1581976), deprecates the

-virtfs_synth command line option, along with some assorted cleanups.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEtIKLr5QxQM7yo0kQcdTV5YIvc9YFAlze/ZQACgkQcdTV5YIv
 c9bW3Q//VklZTna/QCMMdkansDXvIPTyR3Ci4bLzr8fZZMDI3XAUhq6VwGRF8lbr
 U4c1huw+hptwZ+BcLF+M7qyfVyqm4OelLRCMO95cT0pDgE0KULXKPM8VyaAS+l2W
 5PvUY59Hkob/qbURnnryf54Y2qrMqZjK+iEmcDlfpEetpa/Ew+Rgx2m46urNzHQb
 vRoX4fXzp/gw6HafDOwzvnBi8yYXEIc3orZxjSNNPH5pD8zLQnG5/yX7spnSfMou
 MhNYFOl0aZK5efCZzbamhvUWrgPkNVLsCaO0AYXQUmFEtJCyCc7AX5KUlhONmsv8
 LDdmKyc3tIc/QSLmZuL3XdTykQynuosKcBP/CfeVhAGiJ2fa6aCfkx3a4CHL1zkg
 zu4TGhbmgx7gl3cUCDFvhdctA+LkxRmIOFAI9Sd+1MvQARO1Vsq5HyFuEK//mlHo
 dAXWTj+UVkxGSWOzIzbORsCr807lT/w7NciDnlSsbhm/URKu0e5E+hl4ybHQx/og
 sAKp0TVYqJR2/H9+zq/JdX8IRFq5nZdHHIFxNfsdINTVejVxbnSYmD0CdWxmpd6A
 kJ7I3RWmGEBBRAxfbgJzqGbmxeBg1dce/tV4mPan0VVSAAKEievGoIPrafZxIRT2
 Rs2IM8aFZ0TgIoVedMkIC9yXkwclIZe0Br8dLF5PHP0s8AVZwpo=
 =B+V3
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging

This fixes the virtfs documentation (LP 1581976), deprecates the
-virtfs_synth command line option, along with some assorted cleanups.

# gpg: Signature made Fri 17 May 2019 19:29:40 BST
# gpg:                using RSA key B4828BAF943140CEF2A3491071D4D5E5822F73D6
# gpg: Good signature from "Greg Kurz <groug@kaod.org>" [full]
# gpg:                 aka "Gregory Kurz <gregory.kurz@free.fr>" [full]
# gpg:                 aka "[jpeg image of size 3330]" [full]
# Primary key fingerprint: B482 8BAF 9431 40CE F2A3  4910 71D4 D5E5 822F 73D6

* remotes/gkurz/tags/for-upstream:
  virtfs: Fix documentation of -fsdev and -virtfs
  vl: Deprecate -virtfs_synth
  fsdev: Error out when unsupported option is passed
  fsdev: Move some types definition to qemu-fsdev.c
  fsdev: Drop unused opaque field
  fsdev: Drop unused extern declaration

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

# Conflicts:
#	qemu-deprecated.texi
This commit is contained in:
Peter Maydell 2019-05-20 10:51:42 +01:00
commit 76c759e033
6 changed files with 171 additions and 57 deletions

View File

@ -147,7 +147,6 @@ struct FileOperations
int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name, int (*renameat)(FsContext *ctx, V9fsPath *olddir, const char *old_name,
V9fsPath *newdir, const char *new_name); V9fsPath *newdir, const char *new_name);
int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags); int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags);
void *opaque;
}; };
#endif #endif

View File

@ -18,15 +18,102 @@
#include "qemu/error-report.h" #include "qemu/error-report.h"
#include "qemu/option.h" #include "qemu/option.h"
/*
* A table to store the various file systems and their callback operations.
* -----------------
* fstype | ops
* -----------------
* local | local_ops
* . |
* . |
* . |
* . |
* -----------------
* etc
*/
typedef struct FsDriverTable {
const char *name;
FileOperations *ops;
const char **opts;
} FsDriverTable;
typedef struct FsDriverListEntry {
FsDriverEntry fse;
QTAILQ_ENTRY(FsDriverListEntry) next;
} FsDriverListEntry;
static QTAILQ_HEAD(, FsDriverListEntry) fsdriver_entries = static QTAILQ_HEAD(, FsDriverListEntry) fsdriver_entries =
QTAILQ_HEAD_INITIALIZER(fsdriver_entries); QTAILQ_HEAD_INITIALIZER(fsdriver_entries);
#define COMMON_FS_DRIVER_OPTIONS "id", "fsdriver", "readonly"
static FsDriverTable FsDrivers[] = { static FsDriverTable FsDrivers[] = {
{ .name = "local", .ops = &local_ops}, {
{ .name = "synth", .ops = &synth_ops}, .name = "local",
{ .name = "proxy", .ops = &proxy_ops}, .ops = &local_ops,
.opts = (const char * []) {
COMMON_FS_DRIVER_OPTIONS,
"security_model",
"path",
"writeout",
"fmode",
"dmode",
"throttling.bps-total",
"throttling.bps-read",
"throttling.bps-write",
"throttling.iops-total",
"throttling.iops-read",
"throttling.iops-write",
"throttling.bps-total-max",
"throttling.bps-read-max",
"throttling.bps-write-max",
"throttling.iops-total-max",
"throttling.iops-read-max",
"throttling.iops-write-max",
"throttling.bps-total-max-length",
"throttling.bps-read-max-length",
"throttling.bps-write-max-length",
"throttling.iops-total-max-length",
"throttling.iops-read-max-length",
"throttling.iops-write-max-length",
"throttling.iops-size",
},
},
{
.name = "synth",
.ops = &synth_ops,
.opts = (const char * []) {
COMMON_FS_DRIVER_OPTIONS,
},
},
{
.name = "proxy",
.ops = &proxy_ops,
.opts = (const char * []) {
COMMON_FS_DRIVER_OPTIONS,
"socket",
"sock_fd",
"writeout",
},
},
}; };
static int validate_opt(void *opaque, const char *name, const char *value,
Error **errp)
{
FsDriverTable *drv = opaque;
const char **opt;
for (opt = drv->opts; *opt; opt++) {
if (!strcmp(*opt, name)) {
return 0;
}
}
error_setg(errp, "'%s' is invalid for fsdriver '%s'", name, drv->name);
return -1;
}
int qemu_fsdev_add(QemuOpts *opts, Error **errp) int qemu_fsdev_add(QemuOpts *opts, Error **errp)
{ {
int i; int i;
@ -57,6 +144,10 @@ int qemu_fsdev_add(QemuOpts *opts, Error **errp)
return -1; return -1;
} }
if (qemu_opt_foreach(opts, validate_opt, &FsDrivers[i], errp)) {
return -1;
}
fsle = g_malloc0(sizeof(*fsle)); fsle = g_malloc0(sizeof(*fsle));
fsle->fse.fsdev_id = g_strdup(fsdev_id); fsle->fse.fsdev_id = g_strdup(fsdev_id);
fsle->fse.ops = FsDrivers[i].ops; fsle->fse.ops = FsDrivers[i].ops;

View File

@ -14,34 +14,9 @@
#define QEMU_FSDEV_H #define QEMU_FSDEV_H
#include "file-op-9p.h" #include "file-op-9p.h"
/*
* A table to store the various file systems and their callback operations.
* -----------------
* fstype | ops
* -----------------
* local | local_ops
* . |
* . |
* . |
* . |
* -----------------
* etc
*/
typedef struct FsDriverTable {
const char *name;
FileOperations *ops;
} FsDriverTable;
typedef struct FsDriverListEntry {
FsDriverEntry fse;
QTAILQ_ENTRY(FsDriverListEntry) next;
} FsDriverListEntry;
int qemu_fsdev_add(QemuOpts *opts, Error **errp); int qemu_fsdev_add(QemuOpts *opts, Error **errp);
FsDriverEntry *get_fsdev_fsentry(char *id); FsDriverEntry *get_fsdev_fsentry(char *id);
extern FileOperations local_ops; extern FileOperations local_ops;
extern FileOperations handle_ops;
extern FileOperations synth_ops; extern FileOperations synth_ops;
extern FileOperations proxy_ops; extern FileOperations proxy_ops;
#endif #endif

View File

@ -77,6 +77,11 @@ the current values of the environment variables to ``-audiodev'' options.
The @code{-realtime mlock=on|off} argument has been replaced by the The @code{-realtime mlock=on|off} argument has been replaced by the
@code{-overcommit mem-lock=on|off} argument. @code{-overcommit mem-lock=on|off} argument.
@subsection -virtfs_synth (since 4.1)
The ``-virtfs_synth'' argument is now deprecated. Please use ``-fsdev synth''
and ``-device virtio-9p-...'' instead.
@section QEMU Machine Protocol (QMP) commands @section QEMU Machine Protocol (QMP) commands
@subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0) @subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0)

View File

@ -1232,26 +1232,35 @@ the write back by pressing @key{C-a s} (@pxref{disk_images}).
ETEXI ETEXI
DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev, DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev,
"-fsdev fsdriver,id=id[,path=path,][security_model={mapped-xattr|mapped-file|passthrough|none}]\n" "-fsdev local,id=id,path=path,security_model=mapped-xattr|mapped-file|passthrough|none\n"
" [,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd][,fmode=fmode][,dmode=dmode]\n" " [,writeout=immediate][,readonly][,fmode=fmode][,dmode=dmode]\n"
" [[,throttling.bps-total=b]|[[,throttling.bps-read=r][,throttling.bps-write=w]]]\n" " [[,throttling.bps-total=b]|[[,throttling.bps-read=r][,throttling.bps-write=w]]]\n"
" [[,throttling.iops-total=i]|[[,throttling.iops-read=r][,throttling.iops-write=w]]]\n" " [[,throttling.iops-total=i]|[[,throttling.iops-read=r][,throttling.iops-write=w]]]\n"
" [[,throttling.bps-total-max=bm]|[[,throttling.bps-read-max=rm][,throttling.bps-write-max=wm]]]\n" " [[,throttling.bps-total-max=bm]|[[,throttling.bps-read-max=rm][,throttling.bps-write-max=wm]]]\n"
" [[,throttling.iops-total-max=im]|[[,throttling.iops-read-max=irm][,throttling.iops-write-max=iwm]]]\n" " [[,throttling.iops-total-max=im]|[[,throttling.iops-read-max=irm][,throttling.iops-write-max=iwm]]]\n"
" [[,throttling.iops-size=is]]\n", " [[,throttling.iops-size=is]]\n"
"-fsdev proxy,id=id,socket=socket[,writeout=immediate][,readonly]\n"
"-fsdev proxy,id=id,sock_fd=sock_fd[,writeout=immediate][,readonly]\n"
"-fsdev synth,id=id\n",
QEMU_ARCH_ALL) QEMU_ARCH_ALL)
STEXI STEXI
@item -fsdev @var{fsdriver},id=@var{id},path=@var{path},[security_model=@var{security_model}][,writeout=@var{writeout}][,readonly][,socket=@var{socket}|sock_fd=@var{sock_fd}][,fmode=@var{fmode}][,dmode=@var{dmode}] @item -fsdev local,id=@var{id},path=@var{path},security_model=@var{security_model} [,writeout=@var{writeout}][,readonly][,fmode=@var{fmode}][,dmode=@var{dmode}] [,throttling.@var{option}=@var{value}[,throttling.@var{option}=@var{value}[,...]]]
@itemx -fsdev proxy,id=@var{id},socket=@var{socket}[,writeout=@var{writeout}][,readonly]
@itemx -fsdev proxy,id=@var{id},sock_fd=@var{sock_fd}[,writeout=@var{writeout}][,readonly]
@itemx -fsdev synth,id=@var{id}[,readonly]
@findex -fsdev @findex -fsdev
Define a new file system device. Valid options are: Define a new file system device. Valid options are:
@table @option @table @option
@item @var{fsdriver} @item local
This option specifies the fs driver backend to use. Accesses to the filesystem are done by QEMU.
Currently "local" and "proxy" file system drivers are supported. @item proxy
Accesses to the filesystem are done by virtfs-proxy-helper(1).
@item synth
Synthetic filesystem, only used by QTests.
@item id=@var{id} @item id=@var{id}
Specifies identifier for this device Specifies identifier for this device.
@item path=@var{path} @item path=@var{path}
Specifies the export path for the file system device. Files under Specifies the export path for the file system device. Files under
this path will be available to the 9p client on the guest. this path will be available to the 9p client on the guest.
@ -1279,48 +1288,76 @@ Enables exporting 9p share as a readonly mount for guests. By default
read-write access is given. read-write access is given.
@item socket=@var{socket} @item socket=@var{socket}
Enables proxy filesystem driver to use passed socket file for communicating Enables proxy filesystem driver to use passed socket file for communicating
with virtfs-proxy-helper with virtfs-proxy-helper(1).
@item sock_fd=@var{sock_fd} @item sock_fd=@var{sock_fd}
Enables proxy filesystem driver to use passed socket descriptor for Enables proxy filesystem driver to use passed socket descriptor for
communicating with virtfs-proxy-helper. Usually a helper like libvirt communicating with virtfs-proxy-helper(1). Usually a helper like libvirt
will create socketpair and pass one of the fds as sock_fd will create socketpair and pass one of the fds as sock_fd.
@item fmode=@var{fmode} @item fmode=@var{fmode}
Specifies the default mode for newly created files on the host. Works only Specifies the default mode for newly created files on the host. Works only
with security models "mapped-xattr" and "mapped-file". with security models "mapped-xattr" and "mapped-file".
@item dmode=@var{dmode} @item dmode=@var{dmode}
Specifies the default mode for newly created directories on the host. Works Specifies the default mode for newly created directories on the host. Works
only with security models "mapped-xattr" and "mapped-file". only with security models "mapped-xattr" and "mapped-file".
@item throttling.bps-total=@var{b},throttling.bps-read=@var{r},throttling.bps-write=@var{w}
Specify bandwidth throttling limits in bytes per second, either for all request
types or for reads or writes only.
@item throttling.bps-total-max=@var{bm},bps-read-max=@var{rm},bps-write-max=@var{wm}
Specify bursts in bytes per second, either for all request types or for reads
or writes only. Bursts allow the guest I/O to spike above the limit
temporarily.
@item throttling.iops-total=@var{i},throttling.iops-read=@var{r}, throttling.iops-write=@var{w}
Specify request rate limits in requests per second, either for all request
types or for reads or writes only.
@item throttling.iops-total-max=@var{im},throttling.iops-read-max=@var{irm}, throttling.iops-write-max=@var{iwm}
Specify bursts in requests per second, either for all request types or for reads
or writes only. Bursts allow the guest I/O to spike above the limit temporarily.
@item throttling.iops-size=@var{is}
Let every @var{is} bytes of a request count as a new request for iops
throttling purposes.
@end table @end table
-fsdev option is used along with -device driver "virtio-9p-pci". -fsdev option is used along with -device driver "virtio-9p-...".
@item -device virtio-9p-pci,fsdev=@var{id},mount_tag=@var{mount_tag} @item -device virtio-9p-@var{type},fsdev=@var{id},mount_tag=@var{mount_tag}
Options for virtio-9p-pci driver are: Options for virtio-9p-... driver are:
@table @option @table @option
@item @var{type}
Specifies the variant to be used. Supported values are "pci", "ccw" or "device",
depending on the machine type.
@item fsdev=@var{id} @item fsdev=@var{id}
Specifies the id value specified along with -fsdev option Specifies the id value specified along with -fsdev option.
@item mount_tag=@var{mount_tag} @item mount_tag=@var{mount_tag}
Specifies the tag name to be used by the guest to mount this export point Specifies the tag name to be used by the guest to mount this export point.
@end table @end table
ETEXI ETEXI
DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs, DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs,
"-virtfs local,path=path,mount_tag=tag,security_model=[mapped-xattr|mapped-file|passthrough|none]\n" "-virtfs local,path=path,mount_tag=tag,security_model=mapped-xattr|mapped-file|passthrough|none\n"
" [,id=id][,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd][,fmode=fmode][,dmode=dmode]\n", " [,id=id][,writeout=immediate][,readonly][,fmode=fmode][,dmode=dmode]\n"
"-virtfs proxy,mount_tag=tag,socket=socket[,id=id][,writeout=immediate][,readonly]\n"
"-virtfs proxy,mount_tag=tag,sock_fd=sock_fd[,id=id][,writeout=immediate][,readonly]\n"
"-virtfs synth,mount_tag=tag[,id=id][,readonly]\n",
QEMU_ARCH_ALL) QEMU_ARCH_ALL)
STEXI STEXI
@item -virtfs @var{fsdriver}[,path=@var{path}],mount_tag=@var{mount_tag}[,security_model=@var{security_model}][,writeout=@var{writeout}][,readonly][,socket=@var{socket}|sock_fd=@var{sock_fd}][,fmode=@var{fmode}][,dmode=@var{dmode}] @item -virtfs local,path=@var{path},mount_tag=@var{mount_tag} ,security_model=@var{security_model}[,writeout=@var{writeout}][,readonly] [,fmode=@var{fmode}][,dmode=@var{dmode}]
@itemx -virtfs proxy,socket=@var{socket},mount_tag=@var{mount_tag} [,writeout=@var{writeout}][,readonly]
@itemx -virtfs proxy,sock_fd=@var{sock_fd},mount_tag=@var{mount_tag} [,writeout=@var{writeout}][,readonly]
@itemx -virtfs synth,mount_tag=@var{mount_tag}
@findex -virtfs @findex -virtfs
The general form of a Virtual File system pass-through options are: Define a new filesystem device and expose it to the guest using a virtio-9p-device. The general form of a Virtual File system pass-through options are:
@table @option @table @option
@item @var{fsdriver} @item local
This option specifies the fs driver backend to use. Accesses to the filesystem are done by QEMU.
Currently "local" and "proxy" file system drivers are supported. @item proxy
Accesses to the filesystem are done by virtfs-proxy-helper(1).
@item synth
Synthetic filesystem, only used by QTests.
@item id=@var{id} @item id=@var{id}
Specifies identifier for this device Specifies identifier for the filesystem device
@item path=@var{path} @item path=@var{path}
Specifies the export path for the file system device. Files under Specifies the export path for the file system device. Files under
this path will be available to the 9p client on the guest. this path will be available to the 9p client on the guest.
@ -1348,17 +1385,19 @@ Enables exporting 9p share as a readonly mount for guests. By default
read-write access is given. read-write access is given.
@item socket=@var{socket} @item socket=@var{socket}
Enables proxy filesystem driver to use passed socket file for Enables proxy filesystem driver to use passed socket file for
communicating with virtfs-proxy-helper. Usually a helper like libvirt communicating with virtfs-proxy-helper(1). Usually a helper like libvirt
will create socketpair and pass one of the fds as sock_fd will create socketpair and pass one of the fds as sock_fd.
@item sock_fd @item sock_fd
Enables proxy filesystem driver to use passed 'sock_fd' as the socket Enables proxy filesystem driver to use passed 'sock_fd' as the socket
descriptor for interfacing with virtfs-proxy-helper descriptor for interfacing with virtfs-proxy-helper(1).
@item fmode=@var{fmode} @item fmode=@var{fmode}
Specifies the default mode for newly created files on the host. Works only Specifies the default mode for newly created files on the host. Works only
with security models "mapped-xattr" and "mapped-file". with security models "mapped-xattr" and "mapped-file".
@item dmode=@var{dmode} @item dmode=@var{dmode}
Specifies the default mode for newly created directories on the host. Works Specifies the default mode for newly created directories on the host. Works
only with security models "mapped-xattr" and "mapped-file". only with security models "mapped-xattr" and "mapped-file".
@item mount_tag=@var{mount_tag}
Specifies the tag name to be used by the guest to mount this export point.
@end table @end table
ETEXI ETEXI
@ -1368,7 +1407,8 @@ DEF("virtfs_synth", 0, QEMU_OPTION_virtfs_synth,
STEXI STEXI
@item -virtfs_synth @item -virtfs_synth
@findex -virtfs_synth @findex -virtfs_synth
Create synthetic file system image Create synthetic file system image. Note that this option is now deprecated.
Please use @code{-fsdev synth} and @code{-device virtio-9p-...} instead.
ETEXI ETEXI
DEF("iscsi", HAS_ARG, QEMU_OPTION_iscsi, DEF("iscsi", HAS_ARG, QEMU_OPTION_iscsi,

4
vl.c
View File

@ -3537,6 +3537,10 @@ int main(int argc, char **argv, char **envp)
QemuOpts *fsdev; QemuOpts *fsdev;
QemuOpts *device; QemuOpts *device;
warn_report("'-virtfs_synth' is deprecated, please use "
"'-fsdev synth' and '-device virtio-9p-...' "
"instead");
fsdev = qemu_opts_create(qemu_find_opts("fsdev"), "v_synth", fsdev = qemu_opts_create(qemu_find_opts("fsdev"), "v_synth",
1, NULL); 1, NULL);
if (!fsdev) { if (!fsdev) {