Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/gkurz/tags/9p-next-2019-10-10' …
Browse files Browse the repository at this point in the history
…into staging

The most notable change is that we now detect cross-device setups in the
host since it may cause inode number collision and mayhem in the guest.
A new fsdev property is added for the user to choose the appropriate
policy to handle that: either remap all inode numbers or fail I/Os to
another host device or just print out a warning (default behaviour).

This is also my last PR as _active_ maintainer of 9pfs.

# gpg: Signature made Thu 10 Oct 2019 12:14:07 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/9p-next-2019-10-10:
  MAINTAINERS: Downgrade status of virtio-9p to "Odd Fixes"
  9p: Use variable length suffixes for inode remapping
  9p: stat_to_qid: implement slow path
  9p: Added virtfs option 'multidevs=remap|forbid|warn'
  9p: Treat multiple devices on one export as an error
  fsdev: Add return value to fsdev_throttle_parse_opts()
  9p: Simplify error path of v9fs_device_realize_common()
  9p: unsigned type for type, version, path

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Oct 14, 2019
2 parents 088d670 + e410bbc commit c8b2bc5
Show file tree
Hide file tree
Showing 14 changed files with 639 additions and 61 deletions.
2 changes: 1 addition & 1 deletion MAINTAINERS
Expand Up @@ -1517,7 +1517,7 @@ F: tests/virtio-balloon-test.c

virtio-9p
M: Greg Kurz <groug@kaod.org>
S: Supported
S: Odd Fixes
F: hw/9pfs/
X: hw/9pfs/xen-9p*
F: fsdev/
Expand Down
6 changes: 3 additions & 3 deletions fsdev/9p-marshal.h
Expand Up @@ -9,9 +9,9 @@ typedef struct V9fsString

typedef struct V9fsQID
{
int8_t type;
int32_t version;
int64_t path;
uint8_t type;
uint32_t version;
uint64_t path;
} V9fsQID;

typedef struct V9fsStat
Expand Down
5 changes: 5 additions & 0 deletions fsdev/file-op-9p.h
Expand Up @@ -59,6 +59,11 @@ typedef struct ExtendedOps {
#define V9FS_RDONLY 0x00000040
#define V9FS_PROXY_SOCK_FD 0x00000080
#define V9FS_PROXY_SOCK_NAME 0x00000100
/*
* multidevs option (either one of the two applies exclusively)
*/
#define V9FS_REMAP_INODES 0x00000200
#define V9FS_FORBID_MULTIDEVS 0x00000400

#define V9FS_SEC_MASK 0x0000003C

Expand Down
7 changes: 6 additions & 1 deletion fsdev/qemu-fsdev-opts.c
Expand Up @@ -31,7 +31,9 @@ static QemuOptsList qemu_fsdev_opts = {
}, {
.name = "readonly",
.type = QEMU_OPT_BOOL,

}, {
.name = "multidevs",
.type = QEMU_OPT_STRING,
}, {
.name = "socket",
.type = QEMU_OPT_STRING,
Expand Down Expand Up @@ -75,6 +77,9 @@ static QemuOptsList qemu_virtfs_opts = {
}, {
.name = "readonly",
.type = QEMU_OPT_BOOL,
}, {
.name = "multidevs",
.type = QEMU_OPT_STRING,
}, {
.name = "socket",
.type = QEMU_OPT_STRING,
Expand Down
4 changes: 2 additions & 2 deletions fsdev/qemu-fsdev-throttle.c
Expand Up @@ -31,7 +31,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque)
qemu_co_enter_next(&fst->throttled_reqs[true], NULL);
}

void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp)
int fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp)
{
throttle_config_init(&fst->cfg);
fst->cfg.buckets[THROTTLE_BPS_TOTAL].avg =
Expand Down Expand Up @@ -75,7 +75,7 @@ void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error **errp)
fst->cfg.op_size =
qemu_opt_get_number(opts, "throttling.iops-size", 0);

throttle_is_valid(&fst->cfg, errp);
return throttle_is_valid(&fst->cfg, errp) ? 0 : -1;
}

void fsdev_throttle_init(FsThrottle *fst)
Expand Down
2 changes: 1 addition & 1 deletion fsdev/qemu-fsdev-throttle.h
Expand Up @@ -26,7 +26,7 @@ typedef struct FsThrottle {
CoQueue throttled_reqs[2];
} FsThrottle;

void fsdev_throttle_parse_opts(QemuOpts *, FsThrottle *, Error **);
int fsdev_throttle_parse_opts(QemuOpts *, FsThrottle *, Error **);

void fsdev_throttle_init(FsThrottle *);

Expand Down
1 change: 1 addition & 0 deletions fsdev/qemu-fsdev.c
Expand Up @@ -58,6 +58,7 @@ static FsDriverTable FsDrivers[] = {
"writeout",
"fmode",
"dmode",
"multidevs",
"throttling.bps-total",
"throttling.bps-read",
"throttling.bps-write",
Expand Down
28 changes: 26 additions & 2 deletions hw/9pfs/9p-local.c
Expand Up @@ -1465,6 +1465,10 @@ static void local_cleanup(FsContext *ctx)
{
LocalData *data = ctx->private;

if (!data) {
return;
}

close(data->mountfd);
g_free(data);
}
Expand All @@ -1479,6 +1483,7 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
{
const char *sec_model = qemu_opt_get(opts, "security_model");
const char *path = qemu_opt_get(opts, "path");
const char *multidevs = qemu_opt_get(opts, "multidevs");
Error *local_err = NULL;

if (!sec_model) {
Expand All @@ -1502,13 +1507,32 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
return -1;
}

if (multidevs) {
if (!strcmp(multidevs, "remap")) {
fse->export_flags &= ~V9FS_FORBID_MULTIDEVS;
fse->export_flags |= V9FS_REMAP_INODES;
} else if (!strcmp(multidevs, "forbid")) {
fse->export_flags &= ~V9FS_REMAP_INODES;
fse->export_flags |= V9FS_FORBID_MULTIDEVS;
} else if (!strcmp(multidevs, "warn")) {
fse->export_flags &= ~V9FS_FORBID_MULTIDEVS;
fse->export_flags &= ~V9FS_REMAP_INODES;
} else {
error_setg(&local_err, "invalid multidevs property '%s'",
multidevs);
error_append_hint(&local_err, "Valid options are: multidevs="
"[remap|forbid|warn]\n");
error_propagate(errp, local_err);
return -1;
}
}

if (!path) {
error_setg(errp, "path property not set");
return -1;
}

fsdev_throttle_parse_opts(opts, &fse->fst, &local_err);
if (local_err) {
if (fsdev_throttle_parse_opts(opts, &fse->fst, &local_err)) {
error_propagate_prepend(errp, local_err,
"invalid throttle configuration: ");
return -1;
Expand Down
4 changes: 4 additions & 0 deletions hw/9pfs/9p-proxy.c
Expand Up @@ -1185,6 +1185,10 @@ static void proxy_cleanup(FsContext *ctx)
{
V9fsProxy *proxy = ctx->private;

if (!proxy) {
return;
}

g_free(proxy->out_iovec.iov_base);
g_free(proxy->in_iovec.iov_base);
if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) {
Expand Down

0 comments on commit c8b2bc5

Please sign in to comment.