aboutsummaryrefslogtreecommitdiff
path: root/block-raw-win32.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-10-14 14:42:54 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-10-14 14:42:54 +0000
commit9f7965c7e965c8b80da27048017a360b3c57c4af (patch)
tree9a7b218b7a7b590fe926f1c282dfa0916f19092c /block-raw-win32.c
parenteeb438c1b84468e8faa7e69bec86b78b45f2347f (diff)
Expand cache= option and use write-through caching by default
This patch changes the cache= option to accept none, writeback, or writethough to control the host page cache behavior. By default, writethrough caching is now used which internally is implemented by using O_DSYNC to open the disk images. When using -snapshot, writeback is used by default since data integrity it not at all an issue. cache=none has the same behavior as cache=off previously. The later syntax is still supported by now deprecated. I also cleaned up the O_DIRECT implementation to avoid many of the #ifdefs. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5485 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block-raw-win32.c')
-rw-r--r--block-raw-win32.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/block-raw-win32.c b/block-raw-win32.c
index fd4a9e3a4c..892f2d1e5a 100644
--- a/block-raw-win32.c
+++ b/block-raw-win32.c
@@ -104,8 +104,10 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
#else
overlapped = FILE_ATTRIBUTE_NORMAL;
#endif
- if (flags & BDRV_O_DIRECT)
+ if ((flags & BDRV_O_NOCACHE))
overlapped |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
+ else if (!(flags & BDRV_O_CACHE_WB))
+ overlapped |= FILE_FLAG_WRITE_THROUGH;
s->hfile = CreateFile(filename, access_flags,
FILE_SHARE_READ, NULL,
create_flags, overlapped, NULL);
@@ -440,8 +442,10 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
#else
overlapped = FILE_ATTRIBUTE_NORMAL;
#endif
- if (flags & BDRV_O_DIRECT)
+ if ((flags & BDRV_O_NOCACHE))
overlapped |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
+ else if (!(flags & BDRV_O_CACHE_WB))
+ overlapped |= FILE_FLAG_WRITE_THROUGH;
s->hfile = CreateFile(filename, access_flags,
FILE_SHARE_READ, NULL,
create_flags, overlapped, NULL);