From patchwork Fri Apr 20 09:10:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Yuan X-Patchwork-Id: 153973 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6E1D4B70BF for ; Fri, 20 Apr 2012 19:11:27 +1000 (EST) Received: from localhost ([::1]:38015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SL9sD-0000tn-0b for incoming@patchwork.ozlabs.org; Fri, 20 Apr 2012 05:11:25 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SL9s2-0000tO-L2 for qemu-devel@nongnu.org; Fri, 20 Apr 2012 05:11:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SL9rw-00070H-4p for qemu-devel@nongnu.org; Fri, 20 Apr 2012 05:11:14 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:61226) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SL9rv-000702-Rw for qemu-devel@nongnu.org; Fri, 20 Apr 2012 05:11:08 -0400 Received: by dadz9 with SMTP id z9so14723500dad.33 for ; Fri, 20 Apr 2012 02:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=hRTv1WLJh59wl1AW++HYZLAJPj7y5Ud9DcAWOb0BgHk=; b=uhzY3N76pGGzGicWt5WszV21e25Cvqbs3Rd+Rmf0qxOl/CIMlV1/z410eNhSZHblrW hPOm7R/aY4CN8dnNMqutwWUK32dqgrpNgqG1TNLHY3WLBJ/kxaynO99ITVSSMJZ8Cz6N dkvqeuIPt+iuMjV3olYpkYUTmMmrtePW0OB+WeQK7BUCRGs9W0IDNpHI35srP/K7NOwl rUQPWQ+yAW/um0mBD6BiQ3TDPKAWkZ9P12XHHnH9VbQpJxjqJ75xLUjdXthLqQFg6TpG HkLoONGByjlUzID9ji8uYRjgMRD/DVbSix/qqcRkGRKGXf1E7Dr1KQ69gCDid2Ckdu53 e+KQ== Received: by 10.68.236.132 with SMTP id uu4mr11813665pbc.11.1334913065911; Fri, 20 Apr 2012 02:11:05 -0700 (PDT) Received: from taobao.taobao.ali.com ([182.92.247.2]) by mx.google.com with ESMTPS id na8sm3382037pbc.7.2012.04.20.02.11.02 (version=SSLv3 cipher=OTHER); Fri, 20 Apr 2012 02:11:04 -0700 (PDT) From: Liu Yuan To: qemu-devel@nongnu.org Date: Fri, 20 Apr 2012 17:10:56 +0800 Message-Id: <1334913056-7183-1-git-send-email-namei.unix@gmail.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <4F91219A.7080104@redhat.com> References: <4F91219A.7080104@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.46 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH v4] qemu-img: let 'qemu-img convert' flush data X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Liu Yuan The 'qemu-img convert -h' advertise that the default cache mode is 'writeback', while in fact it is 'unsafe'. This patch 1) fix the help manual and 2) let bdrv_close() call bdrv_flush() 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 --- block.c | 1 + qemu-img.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index c0c90f0..1ee2bf0 100644 --- a/block.c +++ b/block.c @@ -812,6 +812,7 @@ unlink_and_fail: void bdrv_close(BlockDriverState *bs) { + bdrv_flush(bs); if (bs->drv) { if (bs->job) { block_job_cancel_sync(bs->job); diff --git a/qemu-img.c b/qemu-img.c index 6a61ca8..0ae543c 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -66,8 +66,8 @@ static void help(void) " 'filename' is a disk image filename\n" " 'fmt' is the disk image format. It is guessed automatically in most cases\n" " 'cache' is the cache mode used to write the output disk image, the valid\n" - " options are: 'none', 'writeback' (default), 'writethrough', 'directsync'\n" - " and 'unsafe'\n" + " options are: 'none', 'writeback' (default, except for convert), 'writethrough',\n" + " 'directsync' and 'unsafe' (default for convert)\n" " 'size' is the disk image size in bytes. Optional suffixes\n" " 'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M)\n" " and T (terabyte, 1024G) are supported. 'b' is ignored.\n"