From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HXN37-0008Bn-N9 for qemu-devel@nongnu.org; Fri, 30 Mar 2007 15:46:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HXN36-00089j-AE for qemu-devel@nongnu.org; Fri, 30 Mar 2007 15:46:12 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HXN36-00089Y-6q for qemu-devel@nongnu.org; Fri, 30 Mar 2007 14:46:12 -0500 Received: from kurt.tools.de ([192.76.135.70]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HXN0M-00016c-Ci for qemu-devel@nongnu.org; Fri, 30 Mar 2007 15:43:22 -0400 Received: from imap.tools.intra (imap.tools.intra [172.20.0.17]) by kurt.TooLs.DE (Postfix) with ESMTP id E1846C643 for ; Fri, 30 Mar 2007 21:43:17 +0200 (MEST) Received: from tiger2.tools.intra (tiger2.tools.intra [172.20.0.11]) by imap.tools.intra (8.13.6+Sun/8.13.6) with SMTP id l2UJhFGl021103 for ; Fri, 30 Mar 2007 21:43:15 +0200 (CEST) Message-Id: <200703301943.l2UJhFGl021103@imap.tools.intra> Date: Fri, 30 Mar 2007 21:43:15 +0200 (CEST) From: Juergen Keil MIME-Version: 1.0 Content-Type: MULTIPART/mixed; BOUNDARY=Drift_of_Hogs_667_000 Subject: [Qemu-devel] PATCH: qcow2 image corruption Reply-To: Juergen Keil , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Drift_of_Hogs_667_000 Content-Type: TEXT/plain; charset=us-ascii Content-MD5: 5GWrjGNcZ4dHUrbPAnnusQ== There have been several reports recently that qemu qcow2 images get corrupted when they grow to ~ 4 gbytes. I've been able to reproduce this using an opensolaris (build 60) install into an 8GB qcow2 image. Installing from dvd works and fills the qcow2 image to ~ 4GB; fsck of the installed qcow2 hdd is OK; but during the first boot from the newly installed hdd there are all sorts of file system corruption messages by the solaris kernel. And with the second boot attempt the qcow2 image has become unbootable. As far as I understand it, the corruption happens when the qcow2 "refcount_table" needs to grow, in function grow_refcount_table(). The qcow2 on-disk position of the grown refcount_table is updated, but the in-core offset of the new refcount_table isn't ! Apparently this results in qcow2 image corruption when update_cluster_refcount() is used the next time, and it writes the offset of a newly allocated refount cluster to the *old* location of the refcount_table. I've tried to fix this with the attached patch. I've repeated the opensolaris (build 60) install experiment with a fresh 8G qcow2 image, and so far, there's no more qcow2 image corruption. --Drift_of_Hogs_667_000 Content-Type: TEXT/plain; name="qcow2.patch"; charset=us-ascii Content-Description: qcow2.patch Content-MD5: cO7AbtBsaktP7aei+KpdOw== Index: block-qcow2.c =================================================================== RCS file: /cvsroot/qemu/qemu/block-qcow2.c,v retrieving revision 1.4 diff -u -B -r1.4 block-qcow2.c --- block-qcow2.c 7 Aug 2006 02:38:06 -0000 1.4 +++ block-qcow2.c 30 Mar 2007 19:19:41 -0000 @@ -1933,6 +1941,7 @@ qemu_free(s->refcount_table); s->refcount_table = new_table; s->refcount_table_size = new_table_size; + s->refcount_table_offset = table_offset; update_refcount(bs, table_offset, new_table_size2, 1); return 0; --Drift_of_Hogs_667_000--