From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:36646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1EN3-000729-VT for qemu-devel@nongnu.org; Wed, 07 Sep 2011 05:24:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1EN3-0000MM-0w for qemu-devel@nongnu.org; Wed, 07 Sep 2011 05:24:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45887) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1EN2-0000Lz-Q6 for qemu-devel@nongnu.org; Wed, 07 Sep 2011 05:24:36 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p879OZcU016725 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 7 Sep 2011 05:24:35 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p879OXwu031983 for ; Wed, 7 Sep 2011 05:24:34 -0400 From: Avi Kivity Date: Wed, 7 Sep 2011 12:24:23 +0300 Message-Id: <1315387463-14623-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH] qcow2: make cache=unsafe usable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org Currently cache=unsafe is unsafe to the point of unusability - the caches are never written to disk except on exit so anything except an orderly exit -- including live migration -- leaves the disk image corrupted. Fix by interpreting flush requests and doing everything except flushing the underlying file. The contents of the metadata cache are transferred to the host pagecache, so that qemu aborts keep the disk in a consistent state, and live migration (on the same host, or if using a coherent filesystem) works. Signed-off-by: Avi Kivity --- Untested - is this the right approach? block/qcow2.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index bfff6cd..7ecd096 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -275,6 +275,13 @@ static int qcow2_open(BlockDriverState *bs, int flags) ret = -EINVAL; goto fail; } + /* + * Request flush callbask so that we can write metadata to the host + * pagecache. Flushes to bs->file will still be ignored. This keeps + * metadata consistent in host pagecache, so we're safe wrt unexpected + * exits, but avoids slow disk flushes (and is vulnerable to host crashes) + */ + bs->open_flags &= ~BDRV_O_NO_FLUSH; /* Initialise locks */ qemu_co_mutex_init(&s->lock); -- 1.7.6.1