Browse Source

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
master
Peter Maydell 3 weeks ago
parent
commit
76c759e033
6 changed files with 171 additions and 57 deletions
  1. 0
    1
      fsdev/file-op-9p.h
  2. 94
    3
      fsdev/qemu-fsdev.c
  3. 0
    25
      fsdev/qemu-fsdev.h
  4. 5
    0
      qemu-deprecated.texi
  5. 68
    28
      qemu-options.hx
  6. 4
    0
      vl.c

+ 0
- 1
fsdev/file-op-9p.h View File

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

+ 94
- 3
fsdev/qemu-fsdev.c View File

@@ -18,15 +18,102 @@
18 18
 #include "qemu/error-report.h"
19 19
 #include "qemu/option.h"
20 20
 
21
+/*
22
+ * A table to store the various file systems and their callback operations.
23
+ * -----------------
24
+ * fstype | ops
25
+ * -----------------
26
+ *  local | local_ops
27
+ *  .     |
28
+ *  .     |
29
+ *  .     |
30
+ *  .     |
31
+ * -----------------
32
+ *  etc
33
+ */
34
+typedef struct FsDriverTable {
35
+    const char *name;
36
+    FileOperations *ops;
37
+    const char **opts;
38
+} FsDriverTable;
39
+
40
+typedef struct FsDriverListEntry {
41
+    FsDriverEntry fse;
42
+    QTAILQ_ENTRY(FsDriverListEntry) next;
43
+} FsDriverListEntry;
44
+
21 45
 static QTAILQ_HEAD(, FsDriverListEntry) fsdriver_entries =
22 46
     QTAILQ_HEAD_INITIALIZER(fsdriver_entries);
23 47
 
48
+#define COMMON_FS_DRIVER_OPTIONS "id", "fsdriver", "readonly"
49
+
24 50
 static FsDriverTable FsDrivers[] = {
25
-    { .name = "local", .ops = &local_ops},
26
-    { .name = "synth", .ops = &synth_ops},
27
-    { .name = "proxy", .ops = &proxy_ops},
51
+    {
52
+        .name = "local",
53
+        .ops = &local_ops,
54
+        .opts = (const char * []) {
55
+            COMMON_FS_DRIVER_OPTIONS,
56
+            "security_model",
57
+            "path",
58
+            "writeout",
59
+            "fmode",
60
+            "dmode",
61
+            "throttling.bps-total",
62
+            "throttling.bps-read",
63
+            "throttling.bps-write",
64
+            "throttling.iops-total",
65
+            "throttling.iops-read",
66
+            "throttling.iops-write",
67
+            "throttling.bps-total-max",
68
+            "throttling.bps-read-max",
69
+            "throttling.bps-write-max",
70
+            "throttling.iops-total-max",
71
+            "throttling.iops-read-max",
72
+            "throttling.iops-write-max",
73
+            "throttling.bps-total-max-length",
74
+            "throttling.bps-read-max-length",
75
+            "throttling.bps-write-max-length",
76
+            "throttling.iops-total-max-length",
77
+            "throttling.iops-read-max-length",
78
+            "throttling.iops-write-max-length",
79
+            "throttling.iops-size",
80
+        },
81
+    },
82
+    {
83
+        .name = "synth",
84
+        .ops = &synth_ops,
85
+        .opts = (const char * []) {
86
+            COMMON_FS_DRIVER_OPTIONS,
87
+        },
88
+    },
89
+    {
90
+        .name = "proxy",
91
+        .ops = &proxy_ops,
92
+        .opts = (const char * []) {
93
+            COMMON_FS_DRIVER_OPTIONS,
94
+            "socket",
95
+            "sock_fd",
96
+            "writeout",
97
+        },
98
+    },
28 99
 };
29 100
 
101
+static int validate_opt(void *opaque, const char *name, const char *value,
102
+                        Error **errp)
103
+{
104
+    FsDriverTable *drv = opaque;
105
+    const char **opt;
106
+
107
+    for (opt = drv->opts; *opt; opt++) {
108
+        if (!strcmp(*opt, name)) {
109
+            return 0;
110
+        }
111
+    }
112
+
113
+    error_setg(errp, "'%s' is invalid for fsdriver '%s'", name, drv->name);
114
+    return -1;
115
+}
116
+
30 117
 int qemu_fsdev_add(QemuOpts *opts, Error **errp)
31 118
 {
32 119
     int i;
@@ -57,6 +144,10 @@ int qemu_fsdev_add(QemuOpts *opts, Error **errp)
57 144
         return -1;
58 145
     }
59 146
 
147
+    if (qemu_opt_foreach(opts, validate_opt, &FsDrivers[i], errp)) {
148
+        return -1;
149
+    }
150
+
60 151
     fsle = g_malloc0(sizeof(*fsle));
61 152
     fsle->fse.fsdev_id = g_strdup(fsdev_id);
62 153
     fsle->fse.ops = FsDrivers[i].ops;

+ 0
- 25
fsdev/qemu-fsdev.h View File

@@ -14,34 +14,9 @@
14 14
 #define QEMU_FSDEV_H
15 15
 #include "file-op-9p.h"
16 16
 
17
-
18
-/*
19
- * A table to store the various file systems and their callback operations.
20
- * -----------------
21
- * fstype | ops
22
- * -----------------
23
- *  local | local_ops
24
- *  .     |
25
- *  .     |
26
- *  .     |
27
- *  .     |
28
- * -----------------
29
- *  etc
30
- */
31
-typedef struct FsDriverTable {
32
-    const char *name;
33
-    FileOperations *ops;
34
-} FsDriverTable;
35
-
36
-typedef struct FsDriverListEntry {
37
-    FsDriverEntry fse;
38
-    QTAILQ_ENTRY(FsDriverListEntry) next;
39
-} FsDriverListEntry;
40
-
41 17
 int qemu_fsdev_add(QemuOpts *opts, Error **errp);
42 18
 FsDriverEntry *get_fsdev_fsentry(char *id);
43 19
 extern FileOperations local_ops;
44
-extern FileOperations handle_ops;
45 20
 extern FileOperations synth_ops;
46 21
 extern FileOperations proxy_ops;
47 22
 #endif

+ 5
- 0
qemu-deprecated.texi View File

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

+ 68
- 28
qemu-options.hx View File

@@ -1232,26 +1232,35 @@ the write back by pressing @key{C-a s} (@pxref{disk_images}).
1232 1232
 ETEXI
1233 1233
 
1234 1234
 DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev,
1235
-    "-fsdev fsdriver,id=id[,path=path,][security_model={mapped-xattr|mapped-file|passthrough|none}]\n"
1236
-    " [,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd][,fmode=fmode][,dmode=dmode]\n"
1235
+    "-fsdev local,id=id,path=path,security_model=mapped-xattr|mapped-file|passthrough|none\n"
1236
+    " [,writeout=immediate][,readonly][,fmode=fmode][,dmode=dmode]\n"
1237 1237
     " [[,throttling.bps-total=b]|[[,throttling.bps-read=r][,throttling.bps-write=w]]]\n"
1238 1238
     " [[,throttling.iops-total=i]|[[,throttling.iops-read=r][,throttling.iops-write=w]]]\n"
1239 1239
     " [[,throttling.bps-total-max=bm]|[[,throttling.bps-read-max=rm][,throttling.bps-write-max=wm]]]\n"
1240 1240
     " [[,throttling.iops-total-max=im]|[[,throttling.iops-read-max=irm][,throttling.iops-write-max=iwm]]]\n"
1241
-    " [[,throttling.iops-size=is]]\n",
1241
+    " [[,throttling.iops-size=is]]\n"
1242
+    "-fsdev proxy,id=id,socket=socket[,writeout=immediate][,readonly]\n"
1243
+    "-fsdev proxy,id=id,sock_fd=sock_fd[,writeout=immediate][,readonly]\n"
1244
+    "-fsdev synth,id=id\n",
1242 1245
     QEMU_ARCH_ALL)
1243 1246
 
1244 1247
 STEXI
1245 1248
 
1246
-@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}]
1249
+@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}[,...]]]
1250
+@itemx -fsdev proxy,id=@var{id},socket=@var{socket}[,writeout=@var{writeout}][,readonly]
1251
+@itemx -fsdev proxy,id=@var{id},sock_fd=@var{sock_fd}[,writeout=@var{writeout}][,readonly]
1252
+@itemx -fsdev synth,id=@var{id}[,readonly]
1247 1253
 @findex -fsdev
1248 1254
 Define a new file system device. Valid options are:
1249 1255
 @table @option
1250
-@item @var{fsdriver}
1251
-This option specifies the fs driver backend to use.
1252
-Currently "local" and "proxy" file system drivers are supported.
1256
+@item local
1257
+Accesses to the filesystem are done by QEMU.
1258
+@item proxy
1259
+Accesses to the filesystem are done by virtfs-proxy-helper(1).
1260
+@item synth
1261
+Synthetic filesystem, only used by QTests.
1253 1262
 @item id=@var{id}
1254
-Specifies identifier for this device
1263
+Specifies identifier for this device.
1255 1264
 @item path=@var{path}
1256 1265
 Specifies the export path for the file system device. Files under
1257 1266
 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
1279 1288
 read-write access is given.
1280 1289
 @item socket=@var{socket}
1281 1290
 Enables proxy filesystem driver to use passed socket file for communicating
1282
-with virtfs-proxy-helper
1291
+with virtfs-proxy-helper(1).
1283 1292
 @item sock_fd=@var{sock_fd}
1284 1293
 Enables proxy filesystem driver to use passed socket descriptor for
1285
-communicating with virtfs-proxy-helper. Usually a helper like libvirt
1286
-will create socketpair and pass one of the fds as sock_fd
1294
+communicating with virtfs-proxy-helper(1). Usually a helper like libvirt
1295
+will create socketpair and pass one of the fds as sock_fd.
1287 1296
 @item fmode=@var{fmode}
1288 1297
 Specifies the default mode for newly created files on the host. Works only
1289 1298
 with security models "mapped-xattr" and "mapped-file".
1290 1299
 @item dmode=@var{dmode}
1291 1300
 Specifies the default mode for newly created directories on the host. Works
1292 1301
 only with security models "mapped-xattr" and "mapped-file".
1302
+@item throttling.bps-total=@var{b},throttling.bps-read=@var{r},throttling.bps-write=@var{w}
1303
+Specify bandwidth throttling limits in bytes per second, either for all request
1304
+types or for reads or writes only.
1305
+@item throttling.bps-total-max=@var{bm},bps-read-max=@var{rm},bps-write-max=@var{wm}
1306
+Specify bursts in bytes per second, either for all request types or for reads
1307
+or writes only.  Bursts allow the guest I/O to spike above the limit
1308
+temporarily.
1309
+@item throttling.iops-total=@var{i},throttling.iops-read=@var{r}, throttling.iops-write=@var{w}
1310
+Specify request rate limits in requests per second, either for all request
1311
+types or for reads or writes only.
1312
+@item throttling.iops-total-max=@var{im},throttling.iops-read-max=@var{irm}, throttling.iops-write-max=@var{iwm}
1313
+Specify bursts in requests per second, either for all request types or for reads
1314
+or writes only.  Bursts allow the guest I/O to spike above the limit temporarily.
1315
+@item throttling.iops-size=@var{is}
1316
+Let every @var{is} bytes of a request count as a new request for iops
1317
+throttling purposes.
1293 1318
 @end table
1294 1319
 
1295
--fsdev option is used along with -device driver "virtio-9p-pci".
1296
-@item -device virtio-9p-pci,fsdev=@var{id},mount_tag=@var{mount_tag}
1297
-Options for virtio-9p-pci driver are:
1320
+-fsdev option is used along with -device driver "virtio-9p-...".
1321
+@item -device virtio-9p-@var{type},fsdev=@var{id},mount_tag=@var{mount_tag}
1322
+Options for virtio-9p-... driver are:
1298 1323
 @table @option
1324
+@item @var{type}
1325
+Specifies the variant to be used. Supported values are "pci", "ccw" or "device",
1326
+depending on the machine type.
1299 1327
 @item fsdev=@var{id}
1300
-Specifies the id value specified along with -fsdev option
1328
+Specifies the id value specified along with -fsdev option.
1301 1329
 @item mount_tag=@var{mount_tag}
1302
-Specifies the tag name to be used by the guest to mount this export point
1330
+Specifies the tag name to be used by the guest to mount this export point.
1303 1331
 @end table
1304 1332
 
1305 1333
 ETEXI
1306 1334
 
1307 1335
 DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs,
1308
-    "-virtfs local,path=path,mount_tag=tag,security_model=[mapped-xattr|mapped-file|passthrough|none]\n"
1309
-    "        [,id=id][,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd][,fmode=fmode][,dmode=dmode]\n",
1336
+    "-virtfs local,path=path,mount_tag=tag,security_model=mapped-xattr|mapped-file|passthrough|none\n"
1337
+    "        [,id=id][,writeout=immediate][,readonly][,fmode=fmode][,dmode=dmode]\n"
1338
+    "-virtfs proxy,mount_tag=tag,socket=socket[,id=id][,writeout=immediate][,readonly]\n"
1339
+    "-virtfs proxy,mount_tag=tag,sock_fd=sock_fd[,id=id][,writeout=immediate][,readonly]\n"
1340
+    "-virtfs synth,mount_tag=tag[,id=id][,readonly]\n",
1310 1341
     QEMU_ARCH_ALL)
1311 1342
 
1312 1343
 STEXI
1313 1344
 
1314
-@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}]
1345
+@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}]
1346
+@itemx -virtfs proxy,socket=@var{socket},mount_tag=@var{mount_tag} [,writeout=@var{writeout}][,readonly]
1347
+@itemx -virtfs proxy,sock_fd=@var{sock_fd},mount_tag=@var{mount_tag} [,writeout=@var{writeout}][,readonly]
1348
+@itemx -virtfs synth,mount_tag=@var{mount_tag}
1315 1349
 @findex -virtfs
1316 1350
 
1317
-The general form of a Virtual File system pass-through options are:
1351
+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:
1318 1352
 @table @option
1319
-@item @var{fsdriver}
1320
-This option specifies the fs driver backend to use.
1321
-Currently "local" and "proxy" file system drivers are supported.
1353
+@item local
1354
+Accesses to the filesystem are done by QEMU.
1355
+@item proxy
1356
+Accesses to the filesystem are done by virtfs-proxy-helper(1).
1357
+@item synth
1358
+Synthetic filesystem, only used by QTests.
1322 1359
 @item id=@var{id}
1323
-Specifies identifier for this device
1360
+Specifies identifier for the filesystem device
1324 1361
 @item path=@var{path}
1325 1362
 Specifies the export path for the file system device. Files under
1326 1363
 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
1348 1385
 read-write access is given.
1349 1386
 @item socket=@var{socket}
1350 1387
 Enables proxy filesystem driver to use passed socket file for
1351
-communicating with virtfs-proxy-helper. Usually a helper like libvirt
1352
-will create socketpair and pass one of the fds as sock_fd
1388
+communicating with virtfs-proxy-helper(1). Usually a helper like libvirt
1389
+will create socketpair and pass one of the fds as sock_fd.
1353 1390
 @item sock_fd
1354 1391
 Enables proxy filesystem driver to use passed 'sock_fd' as the socket
1355
-descriptor for interfacing with virtfs-proxy-helper
1392
+descriptor for interfacing with virtfs-proxy-helper(1).
1356 1393
 @item fmode=@var{fmode}
1357 1394
 Specifies the default mode for newly created files on the host. Works only
1358 1395
 with security models "mapped-xattr" and "mapped-file".
1359 1396
 @item dmode=@var{dmode}
1360 1397
 Specifies the default mode for newly created directories on the host. Works
1361 1398
 only with security models "mapped-xattr" and "mapped-file".
1399
+@item mount_tag=@var{mount_tag}
1400
+Specifies the tag name to be used by the guest to mount this export point.
1362 1401
 @end table
1363 1402
 ETEXI
1364 1403
 
@@ -1368,7 +1407,8 @@ DEF("virtfs_synth", 0, QEMU_OPTION_virtfs_synth,
1368 1407
 STEXI
1369 1408
 @item -virtfs_synth
1370 1409
 @findex -virtfs_synth
1371
-Create synthetic file system image
1410
+Create synthetic file system image. Note that this option is now deprecated.
1411
+Please use @code{-fsdev synth} and @code{-device virtio-9p-...} instead.
1372 1412
 ETEXI
1373 1413
 
1374 1414
 DEF("iscsi", HAS_ARG, QEMU_OPTION_iscsi,

+ 4
- 0
vl.c View File

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

Loading…
Cancel
Save