[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH -V3 7/8] hw/9pfs: Add new virtfs option cache=none t
From: |
Aneesh Kumar K.V |
Subject: |
[Qemu-devel] [PATCH -V3 7/8] hw/9pfs: Add new virtfs option cache=none to skip host page cache |
Date: |
Sat, 5 Mar 2011 23:22:12 +0530 |
cache=none implies the file are opened in the host with O_SYNC open flag
Signed-off-by: Aneesh Kumar K.V <address@hidden>
---
fsdev/qemu-fsdev.c | 8 +++++++-
fsdev/qemu-fsdev.h | 1 +
hw/9pfs/virtio-9p.c | 17 ++++++++++++-----
hw/file-op-9p.h | 1 +
qemu-config.c | 6 ++++++
qemu-options.hx | 17 ++++++++++++-----
vl.c | 23 +++++++++++++++++++----
7 files changed, 58 insertions(+), 15 deletions(-)
diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c
index 0b33290..d803d47 100644
--- a/fsdev/qemu-fsdev.c
+++ b/fsdev/qemu-fsdev.c
@@ -33,6 +33,8 @@ int qemu_fsdev_add(QemuOpts *opts)
const char *fstype = qemu_opt_get(opts, "fstype");
const char *path = qemu_opt_get(opts, "path");
const char *sec_model = qemu_opt_get(opts, "security_model");
+ const char *cache = qemu_opt_get(opts, "cache");
+
if (!fsdev_id) {
fprintf(stderr, "fsdev: No id specified\n");
@@ -71,10 +73,14 @@ int qemu_fsdev_add(QemuOpts *opts)
fsle->fse.path = qemu_strdup(path);
fsle->fse.security_model = qemu_strdup(sec_model);
fsle->fse.ops = FsTypes[i].ops;
+ if (cache) {
+ fsle->fse.cache = qemu_strdup(cache);
+ } else {
+ fsle->fse.cache = NULL;
+ }
QTAILQ_INSERT_TAIL(&fstype_entries, fsle, next);
return 0;
-
}
FsTypeEntry *get_fsdev_fsentry(char *id)
diff --git a/fsdev/qemu-fsdev.h b/fsdev/qemu-fsdev.h
index a704043..d3a0fac 100644
--- a/fsdev/qemu-fsdev.h
+++ b/fsdev/qemu-fsdev.h
@@ -41,6 +41,7 @@ typedef struct FsTypeEntry {
char *fsdev_id;
char *path;
char *security_model;
+ char *cache;
FileOperations *ops;
} FsTypeEntry;
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 293a562..75df1a1 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -70,17 +70,18 @@ static int omode_to_uflags(int8_t mode)
return ret;
}
-static int get_dotl_openflags(int oflags)
+static int get_dotl_openflags(V9fsState *s, int oflags)
{
int flags;
/*
* Since we can share the fd between multiple fids,
* open the file in read write mode
*/
+ flags = s->ctx.open_flags;
if ((oflags & O_ACCMODE) != O_RDONLY) {
- flags = O_RDWR;
+ flags |= O_RDWR;
} else {
- flags = O_RDONLY;
+ flags |= O_RDONLY;
}
/*
* If the client asked for any of the below flags we
@@ -1856,7 +1857,7 @@ static void v9fs_open_post_lstat(V9fsState *s,
V9fsOpenState *vs, int err)
v9fs_open_post_opendir(s, vs, err);
} else {
if (s->proto_version == V9FS_PROTO_2000L) {
- flags = get_dotl_openflags(vs->mode);
+ flags = get_dotl_openflags(s, vs->mode);
} else {
flags = omode_to_uflags(vs->mode);
}
@@ -1987,7 +1988,7 @@ static void v9fs_lcreate(V9fsState *s, V9fsPDU *pdu)
v9fs_string_sprintf(&vs->fullname, "%s/%s", vs->fidp->fsmap.path.data,
vs->name.data);
- flags = get_dotl_openflags(flags);
+ flags = get_dotl_openflags(s, flags);
vs->fidp->fsmap.fs.fd = v9fs_do_open2(s, vs->fullname.data, vs->fidp->uid,
gid, flags | O_CREAT, mode);
vs->fidp->fsmap.open_flags = flags;
@@ -3912,6 +3913,12 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf
*conf)
exit(1);
}
+ if (fse->cache && !strcmp(fse->cache, "none")) {
+ s->ctx.open_flags = O_SYNC;
+ } else {
+ s->ctx.open_flags = 0;
+ }
+
s->ctx.fs_root = qemu_strdup(fse->path);
len = strlen(conf->tag);
if (len > MAX_TAG_LEN) {
diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h
index e306305..8577020 100644
--- a/hw/file-op-9p.h
+++ b/hw/file-op-9p.h
@@ -54,6 +54,7 @@ typedef struct FsContext
char *fs_root;
SecModel fs_sm;
uid_t uid;
+ int open_flags;
struct xattr_operations **xops;
} FsContext;
diff --git a/qemu-config.c b/qemu-config.c
index 965fa46..4d87a39 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -165,6 +165,9 @@ QemuOptsList qemu_fsdev_opts = {
}, {
.name = "security_model",
.type = QEMU_OPT_STRING,
+ }, {
+ .name = "cache",
+ .type = QEMU_OPT_STRING,
},
{ /*End of list */ }
},
@@ -187,6 +190,9 @@ QemuOptsList qemu_virtfs_opts = {
}, {
.name = "security_model",
.type = QEMU_OPT_STRING,
+ }, {
+ .name = "cache",
+ .type = QEMU_OPT_STRING,
},
{ /*End of list */ }
diff --git a/qemu-options.hx b/qemu-options.hx
index 898561d..ad27bf0 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -486,7 +486,8 @@ ETEXI
DEFHEADING(File system options:)
DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev,
- "-fsdev local,id=id,path=path,security_model=[mapped|passthrough|none]\n",
+ "-fsdev local,id=id,path=path,security_model=[mapped|passthrough|none]\n"
+ " [,cache=none]\n",
QEMU_ARCH_ALL)
STEXI
@@ -502,7 +503,7 @@ The specific Fstype will determine the applicable options.
Options to each backend are described below.
address@hidden -fsdev local ,address@hidden ,address@hidden ,address@hidden
address@hidden -fsdev local ,address@hidden ,address@hidden
,address@hidden,address@hidden
Create a file-system-"device" for local-filesystem.
@@ -513,13 +514,17 @@ Create a file-system-"device" for local-filesystem.
@option{security_model} specifies the security model to be followed.
@option{security_model} is required.
address@hidden specifies whether to skip the host page cache.
address@hidden is an optional argument.
+
@end table
ETEXI
DEFHEADING(Virtual File system pass-through options:)
DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs,
- "-virtfs
local,path=path,mount_tag=tag,security_model=[mapped|passthrough|none]\n",
+ "-virtfs
local,path=path,mount_tag=tag,security_model=[mapped|passthrough|none]\n"
+ " [,cache=none]\n",
QEMU_ARCH_ALL)
STEXI
@@ -535,7 +540,7 @@ The specific Fstype will determine the applicable options.
Options to each backend are described below.
address@hidden -virtfs local ,address@hidden ,address@hidden ,address@hidden
address@hidden -virtfs local ,address@hidden ,address@hidden
,address@hidden,address@hidden
Create a Virtual file-system-pass through for local-filesystem.
@@ -546,10 +551,12 @@ Create a Virtual file-system-pass through for
local-filesystem.
@option{security_model} specifies the security model to be followed.
@option{security_model} is required.
-
@option{mount_tag} specifies the tag with which the exported file is mounted.
@option{mount_tag} is required.
address@hidden specifies whether to skip the host page cache.
address@hidden is an optional argument.
+
@end table
ETEXI
diff --git a/vl.c b/vl.c
index 14255c4..5c76ece 100644
--- a/vl.c
+++ b/vl.c
@@ -2379,6 +2379,8 @@ int main(int argc, char **argv, char **envp)
}
break;
case QEMU_OPTION_virtfs: {
+ const char *cache;
+ char *arg_cache = NULL;
char *arg_fsdev = NULL;
char *arg_9p = NULL;
int len = 0;
@@ -2404,7 +2406,18 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
+ cache = qemu_opt_get(opts, "cache");
+ if (cache) {
+ len = strlen(",cache=");
+ len += strlen(cache);
+ arg_cache = qemu_malloc(len+1);
+ snprintf(arg_cache, (len+1), ",cache=%s", cache);
+ } else {
+ arg_cache = (char *)"";
+ }
+
len = strlen(",id=,path=,security_model=");
+ len += strlen(arg_cache);
len += strlen(qemu_opt_get(opts, "fstype"));
len += strlen(qemu_opt_get(opts, "mount_tag"));
len += strlen(qemu_opt_get(opts, "path"));
@@ -2412,20 +2425,22 @@ int main(int argc, char **argv, char **envp)
arg_fsdev = qemu_malloc((len + 1) * sizeof(*arg_fsdev));
snprintf(arg_fsdev, (len + 1) * sizeof(*arg_fsdev),
- "%s,id=%s,path=%s,security_model=%s",
+ "%s,id=%s,path=%s,security_model=%s%s",
qemu_opt_get(opts, "fstype"),
qemu_opt_get(opts, "mount_tag"),
qemu_opt_get(opts, "path"),
- qemu_opt_get(opts, "security_model"));
+ qemu_opt_get(opts, "security_model"),
+ arg_cache);
len = strlen("virtio-9p-pci,fsdev=,mount_tag=");
len += 2*strlen(qemu_opt_get(opts, "mount_tag"));
arg_9p = qemu_malloc((len + 1) * sizeof(*arg_9p));
snprintf(arg_9p, (len + 1) * sizeof(*arg_9p),
- "virtio-9p-pci,fsdev=%s,mount_tag=%s",
+ "virtio-9p-pci,fsdev=%s,mount_tag=%s%s",
+ qemu_opt_get(opts, "mount_tag"),
qemu_opt_get(opts, "mount_tag"),
- qemu_opt_get(opts, "mount_tag"));
+ arg_cache);
if (!qemu_opts_parse(qemu_find_opts("fsdev"), arg_fsdev, 1)) {
fprintf(stderr, "parse error [fsdev]: %s\n", optarg);
--
1.7.1
- [Qemu-devel] [PATCH -V3 4/8] hw/9pfs: Implement syncfs, (continued)
- [Qemu-devel] [PATCH -V3 4/8] hw/9pfs: Implement syncfs, Aneesh Kumar K.V, 2011/03/05
- [Qemu-devel] [PATCH -V3 5/8] hw/9pfs: Add open flag to fid, Aneesh Kumar K.V, 2011/03/05
- [Qemu-devel] [PATCH -V3 6/8] hw/9pfs: Add directory reclaim support, Aneesh Kumar K.V, 2011/03/05
- [Qemu-devel] [PATCH -V3 8/8] hw/9pfs: Skip file system sync if we have specified cache=none option, Aneesh Kumar K.V, 2011/03/05
- [Qemu-devel] [PATCH -V3 7/8] hw/9pfs: Add new virtfs option cache=none to skip host page cache,
Aneesh Kumar K.V <=
- Re: [Qemu-devel] [PATCH -V3 7/8] hw/9pfs: Add new virtfs option cache=none to skip host page cache, Stefan Hajnoczi, 2011/03/13
- Re: [Qemu-devel] [PATCH -V3 7/8] hw/9pfs: Add new virtfs option cache=none to skip host page cache, Stefan Hajnoczi, 2011/03/14
- Re: [Qemu-devel] [PATCH -V3 7/8] hw/9pfs: Add new virtfs option cache=none to skip host page cache, Aneesh Kumar K. V, 2011/03/15
- Re: [Qemu-devel] [PATCH -V3 7/8] hw/9pfs: Add new virtfs option cache=none to skip host page cache, Stefan Hajnoczi, 2011/03/15
- Re: [Qemu-devel] [PATCH -V3 7/8] hw/9pfs: Add new virtfs option cache=none to skip host page cache, Aneesh Kumar K. V, 2011/03/15
- Re: [Qemu-devel] [PATCH -V3 7/8] hw/9pfs: Add new virtfs option cache=none to skip host page cache, Stefan Hajnoczi, 2011/03/16
Re: [Qemu-devel] [PATCH -V3 1/8] hw/9pfs: Add V9fsfidmap in preparation for adding fd reclaim, Stefan Hajnoczi, 2011/03/13