Comment 10 for bug 1292234

Revision history for this message
Serge Hallyn (serge-hallyn) wrote : Re: qcow2 image corruption in trusty (qemu 1.7 and 2.0 candidate)

I have a clean install of trusty on an intel laptop. I added the following upstart job in the forhallyn-trusty-amd64.img root partition:

####################################################################
description "update and shutdown"
author "Serge Hallyn <email address hidden>"

start on runlevel [2345]

script
 sleep 5s
 apt-get update
 DEBIAN_FRONTEND='noninteractive' apt-get -y dist-upgrade
 sleep 5s
 shutdown -h now
end script
####################################################################

Then on the host I run this script:

####################################################################
#!/bin/bash

cp orig-with-upstart/forhallyn-trusty-amd64.img .

virsh snapshot-create-as forhallyn-trusty-amd64 pristine "uvt snapshot"
virsh start forhallyn-trusty-amd64
sleep 20s
while [ 1 ]; do
 virsh list | grep -q forhallyn || break
 sleep 20s
done

# guest has updated. check the image file and fs here
qemu-img check forhallyn-trusty-amd64.img
if [ $? -ne 0 ]; then
    echo "image check failed after shutdown"
    exit 1
fi
qemu-nbd -c /dev/nbd0 forhallyn-trusty-amd64.img
fsck -a /dev/nbd0p1
if [ $? -ne 0 ]; then
    echo "fs bad after shutdown"
    qemu-nbd -d /dev/nbd0
    exit 1
fi
qemu-nbd -d /dev/nbd0

# now tweak the snapshots
virsh snapshot-delete forhallyn-trusty-amd64 pristine --children
virsh snapshot-create-as forhallyn-trusty-amd64 pristine "uvt snapshot"

# and check the image file and fs again
qemu-img check forhallyn-trusty-amd64.img
if [ $? -ne 0 ]; then
    echo "image check failed after snapshot remove/create"
    exit 1
fi
qemu-nbd -c /dev/nbd0 forhallyn-trusty-amd64.img
fsck -a /dev/nbd0p1
if [ $? -ne 0 ]; then
    echo "fs bad after snapshot remove/create"
    qemu-nbd -d /dev/nbd0
    exit 1
fi
qemu-nbd -d /dev/nbd0

# all seems well
exit 0
####################################################################

I'll run that in a loop and see if it fails after 10 tries.

If you see anything there that I am NOT doing which would help to reproduce,
please let me know.