qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] qemu-img: let qemu-img behave as the manual adverti


From: Liu Yuan
Subject: [Qemu-devel] [PATCH] qemu-img: let qemu-img behave as the manual advertise
Date: Wed, 11 Apr 2012 02:10:38 +0800

From: Liu Yuan <address@hidden>

The 'qemu-img convert -h' advertise that the default cache mode is
'writeback', while in fact it is 'unsafe'.

This patch 1) changes the cache mode as 'writeback' and 2) explicitly
calls bdrv_flush() to flush the dirty bits.

2) is needed because some backend storage doesn't have a self-flush
mechanism(for e.g., sheepdog), so we need to call bdrv_flush() to make
sure the image is really writen to the storage instead of hanging around
writeback cache forever.

Signed-off-by: Liu Yuan <address@hidden>
---
 qemu-img.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 6a61ca8..f96230b 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -644,7 +644,7 @@ static int img_convert(int argc, char **argv)
 
     fmt = NULL;
     out_fmt = "raw";
-    cache = "unsafe";
+    cache = "writeback";
     out_baseimg = NULL;
     compress = 0;
     for(;;) {
@@ -1036,6 +1036,9 @@ out:
     free_option_parameters(param);
     qemu_vfree(buf);
     if (out_bs) {
+        if (ret == 0) {
+            bdrv_flush(out_bs);
+       }
         bdrv_delete(out_bs);
     }
     if (bs) {
-- 
1.7.8.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]