From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qoyme-00012J-Um for qemu-devel@nongnu.org; Thu, 04 Aug 2011 10:20:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qoymd-0005vh-4b for qemu-devel@nongnu.org; Thu, 04 Aug 2011 10:20:24 -0400 Received: from mail.univention.de ([82.198.197.8]:2647) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qoymc-0005vK-H3 for qemu-devel@nongnu.org; Thu, 04 Aug 2011 10:20:22 -0400 From: Philipp Hahn Date: Thu, 4 Aug 2011 16:20:08 +0200 MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2989076.PWI9o2b4Zd"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201108041620.13687.hahn@univention.de> Subject: [Qemu-devel] [BUG] Qcow2 corruption on snapshot revert List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, kvm@vger.kernel.org, Stefan Gohmann --nextPart2989076.PWI9o2b4Zd Content-Type: multipart/mixed; boundary="Boundary-01=_YqqOO5O1+o9Zsk0" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_YqqOO5O1+o9Zsk0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello, it seems like I have discovered a bug in qemu-0.14.1 which corrupts Qcow2=20 image files when using internal snapshots. I tied this both on an amd64 host running our Debian bases UCS distribution= =20 (using pure qemu-kvm_0.14 and pure qemu-kvm_0.14.1) and also on a pure Debi= an=20 i386 sid installation (patched qemu-kvm_0.14.1). I can reproducte this every time doing the following steps: 0. Create and install VM 1. Shut down VM 2. Create offline snapshot using "qemu-img snapshot -c Off image.qcow2" 3. Start VM 4. Create online snapshot using "savevm On" 5. Shut down VM 6. Revert to snapshot using "qemu-img snapshot -a Off image.qcow2" Repeat step 6 three or more times and the Image is destroyed. My guess is that this is a but in qemu-img, which is related to having an=20 online snapshot (VM running) while reverting to an offline snapshot (VM=20 stopped), because I wasn't able to reproduce this using only offline=20 snapshots or only online snapshots. I have attached a shell script to reproduce this bug on all my runs. * It both happens with kvm-0.14.1 and also with qemu-0.14.1. * The cache stragtegy "writethrough" vs. "writeback" is irrelevant. The script needs an image nameded "pmh_squeeze-0.qcow.bak2" of an VM where = you=20 can login via serial console using "root" for login and "univention" for=20 password. You can use other images as well, as long as you modify the block= =20 device from within the VM. You get get it from=20 There you will also find the beginning of a small Python program=20 called "qcow2.py" which can be used to dump the structure of an qcow2 file = in=20 some more human readable format with some consistency checking. Related links: Any help is appreciated. Sincerely Philipp Hahn =2D-=20 Philipp Hahn Open Source Software Engineer hahn@univention.de Univention GmbH Linux for Your Business fon: +49 421 22 232- 0 Mary-Somerville-Str.1 D-28359 Bremen fax: +49 421 22 232-99 http://www.univention.de/ --Boundary-01=_YqqOO5O1+o9Zsk0 Content-Type: application/x-shellscript; name="22221_qemu_qcow2_bug.test" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="22221_qemu_qcow2_bug.test" #!/bin/sh # Show Qcow2 image corruption bug set -e -x trap 'set +e ; kill $pid_kvm $pid_monitor $pid_console ; rm -f ./{monitor,console}.{in,out}' EXIT # Restore image from backup test -f pmh_squeeze-0.qcow2.bak2 && dd bs=1M if=pmh_squeeze-0.qcow2.bak2 of=pmh_squeeze-0.qcow2 # Create offline snapshot qemu-img snapshot -c Off pmh_squeeze-0.qcow2 # Run VM test -p ./monitor.in || mkfifo ./monitor.in test -p ./monitor.out || mkfifo ./monitor.out test -p ./console.in || mkfifo ./console.in test -p ./console.out || mkfifo ./console.out kvm -M pc-0.14 -cpu kvm32 -enable-kvm -m 512 -smp 1,sockets=1,cores=1,threads=1 -nodefconfig -nodefaults \ -chardev pipe,id=monitor,path=monitor,server,nowait -mon chardev=monitor,mode=readline \ -rtc base=utc \ -boot c \ -drive file=/var/lib/libvirt/images/pmh_squeeze-0.qcow2,if=none,id=drive-virtio-disk0,boot=on,format=qcow2,cache=writethrough -device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0 \ -chardev pipe,id=serial0,path=console -device isa-serial,chardev=serial0 -nographic & pid_kvm=$! exec 3>./monitor.in # qemu monitor cat ./monitor.out & pid_monitor=$! exec 4>./console.in # vm console cat ./console.out & pid_console=$! # Wait for VM to boot sleep 10 # Login echo root >&4 echo univention >&4 # Create online snapshot echo savevm On >&3 # qemu monitor echo info snapshots >&3 # qemu monitor # [Optional] Create modified clusters echo dd if=/dev/zero bs=1M count=1k of=/dev/vda >&4 echo sync >&4 echo touch /boom >&4 # Quit qemu echo quit >&3 # qemu monitor wait # Revert to offline snapshot while qemu-img check pmh_squeeze-0.qcow2 do qemu-img snapshot -a Off pmh_squeeze-0.qcow2 done --Boundary-01=_YqqOO5O1+o9Zsk0-- --nextPart2989076.PWI9o2b4Zd Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAk46qpgACgkQYPlgoZpUDjnnMACcCVY0+mvwsLjklPrFueYEc+4H aFcAn0EQLKeaS7kSb9yo6A/hIlql8MNB =r1tw -----END PGP SIGNATURE----- --nextPart2989076.PWI9o2b4Zd--