[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qemu-img: let qemu-img behave as the manual adv
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] qemu-img: let qemu-img behave as the manual advertise |
Date: |
Tue, 10 Apr 2012 21:40:53 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 |
Il 10/04/2012 20:10, Liu Yuan ha scritto:
> 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.
Shouldn't the close method do that then?
Paolo
> 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) {