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.
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 FRONTEND= 'noninteractive ' apt-get -y dist-upgrade ####### ####### ####### ####### ####### ####### ####### ####### #####
sleep 5s
apt-get update
DEBIAN_
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" trusty- amd64
virsh start forhallyn-
sleep 20s
while [ 1 ]; do
virsh list | grep -q forhallyn || break
sleep 20s
done
# guest has updated. check the image file and fs here trusty- amd64.img trusty- amd64.img
qemu-img check forhallyn-
if [ $? -ne 0 ]; then
echo "image check failed after shutdown"
exit 1
fi
qemu-nbd -c /dev/nbd0 forhallyn-
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 trusty- amd64 pristine --children trusty- amd64 pristine "uvt snapshot"
virsh snapshot-delete forhallyn-
virsh snapshot-create-as forhallyn-
# and check the image file and fs again trusty- amd64.img trusty- amd64.img
qemu-img check forhallyn-
if [ $? -ne 0 ]; then
echo "image check failed after snapshot remove/create"
exit 1
fi
qemu-nbd -c /dev/nbd0 forhallyn-
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.