diff options
author | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-11-30 19:12:49 +0000 |
---|---|---|
committer | aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-11-30 19:12:49 +0000 |
commit | 137519ce2e269915de0f67a13ac32b67605cad72 (patch) | |
tree | 0ba6e3dda0eae5d50e96992cfecd073d71acb713 /qemu-img.c | |
parent | b8dbdddc9edda7d64352a837aa77c077c5dc960f (diff) |
qemu-img: open files with cache=writeback
Data integrity is not important in qemu-img, so open the files with
cache=writeback. This fixes the performance regression seen with qemu-img
since revision 5485, and most particularly with the qcow2 format.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5839 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'qemu-img.c')
-rw-r--r-- | qemu-img.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/qemu-img.c b/qemu-img.c index 70c2403872..207535f4f7 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -30,6 +30,9 @@ #include <windows.h> #endif +/* Default to cache=writeback as data integrity is not important for qemu-tcg. */ +#define BRDV_O_FLAGS BDRV_O_CACHE_WB + static void __attribute__((noreturn)) error(const char *fmt, ...) { va_list ap; @@ -186,7 +189,7 @@ static BlockDriverState *bdrv_new_open(const char *filename, } else { drv = NULL; } - if (bdrv_open2(bs, filename, 0, drv) < 0) { + if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { error("Could not open '%s'", filename); } if (bdrv_is_encrypted(bs)) { @@ -317,7 +320,7 @@ static int img_commit(int argc, char **argv) } else { drv = NULL; } - if (bdrv_open2(bs, filename, 0, drv) < 0) { + if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { error("Could not open '%s'", filename); } ret = bdrv_commit(bs); @@ -691,7 +694,7 @@ static int img_info(int argc, char **argv) } else { drv = NULL; } - if (bdrv_open2(bs, filename, 0, drv) < 0) { + if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { error("Could not open '%s'", filename); } bdrv_get_format(bs, fmt_name, sizeof(fmt_name)); |