Skip to content

Commit

Permalink
Add a script to create libvirt external snapshots in a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
kashyapc committed Jun 26, 2014
1 parent 583040f commit 0df7f11
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions libvirt-live-snapshots-stress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# Purpose: For a given libvirt guest, create 100 external live-snapshots
# i.e. each snapshot is stored in a unique QCOW2 file

#set -x

PROGNAME=`basename $0`

DOMAIN=$1

SNAPSHOTS_DIR=/export/vmimages

# Create external snapshots
create_external_snapshot() {
let i=0
while [ $i -lt 100 ];do
echo "Creating $DOMAIN-snap$i"
virsh snapshot-create-as --domain $DOMAIN \
--name snap-$i \
--description snap$i-desc \
--disk-only \
--diskspec hda,snapshot=external,file=$SNAPSHOTS_DIR/$DOMAIN-snap$i.qcow2 \
--atomic
let i=i+1
done
}

# main ()
{

# Check if min no. of arguments are 1
if [ "$#" != 1 ]; then
echo "Provide the libvirt guest name."
echo "e.g. $PROGNAME f20vm1"
exit 255
fi


create_external_snapshot

}

0 comments on commit 0df7f11

Please sign in to comment.