Hello community,
here is the log from the commit of package virt-utils for openSUSE:Factory
checked in at Fri Nov 27 16:29:58 CET 2009.
--------
New Changes file:
--- /dev/null 2009-09-30 08:50:26.000000000 +0200
+++ /mounts/work_src_done/STABLE/virt-utils/virt-utils.changes 2009-11-19 04:21:34.000000000 +0100
@@ -0,0 +1,5 @@
+-------------------------------------------------------------------
+Wed Nov 18 23:30:47 UTC 2009 - brogers@novell.com
+
+- Initial checkin of package split from xen package. See FATE#305328
+
calling whatdependson for head-i586
New:
----
qemu-xen-unstable.tar.bz2
virt-utils.changes
virt-utils.spec
vm-snapshot-disk
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ virt-utils.spec ++++++
#
# spec file for package virt-utils (Version 1.0.0)
#
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
%define qemu_utils 1
%define internal_utils 1
Name: virt-utils
ExclusiveArch: %ix86 x86_64
BuildRequires: zlib-devel
Version: 1.0.0
Release: 1
License: GPLv2
Group: System/Kernel
Summary: Virtualization Utilities
Source0: qemu-xen-unstable.tar.bz2
Source1: vm-snapshot-disk
Url: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Various virtualization solutions have a common need for ancillary utilities which manage storage, snapshotting, monitoring, etc.
Both KVM and Xen derive their device and machine model from qemu and inherit a lot from it's approach to emulation/virtualization. This package is hence a good place to have qemu related tools reside. Additionally, any other utilities which have use across the various virtualization solutions available have a home here.
Authors:
--------
Fabrice Bellard
Ian Pratt
Keir Fraser
Christian Limpach
Mark Williamson
Ewan Mellor
...
%prep
%if %{?qemu_utils}0
%setup -q -n qemu-xen-unstable
%endif
%build
%if %{?qemu_utils}0
./configure --disable-sdl --disable-gfx-check --disable-slirp
make qemu-img
make qemu-nbd
%endif
%install
%if %{?qemu_utils}0
mkdir -p %{buildroot}%{_bindir}
install -m 755 qemu-img %{buildroot}%_bindir/qemu-img
ln -s %{buildroot}%_bindir/qemu-img qemu-img-xen
install -m 755 qemu-nbd %{buildroot}%_bindir/qemu-nbd
ln -s %{buildroot}%_bindir/qemu-img qemu-nbd-xen
%endif
%if %{?internal_utils}0
install -m 755 %SOURCE1 $RPM_BUILD_ROOT/usr/bin
%endif
%files
%defattr(-, root, root)
%if %{?qemu_utils}0
/usr/bin/qemu-img
/usr/bin/qemu-nbd
%endif
%if %{?internal_utils}0
/usr/bin/vm-snapshot-disk
%endif
%post
%preun
%postun
%clean
%changelog
++++++ vm-snapshot-disk ++++++
#!/bin/bash
#============================================================================
# vm-snapshot-disk
#
# Version = 0.2.1
# Date = 2009-07-28
#
# Copyright - Ron Terry
# License - GPL
#
# Maintainer(s) = Ron Terry - roncterry (at) gmail (dot) com
#
# The latest version can be found at:
#
# http://pronetworkconsulting.com/linux/scripts/virt-tools.html
#
# Description:
# This script creates and manages snapshots of qcow2 virtual disks.
#
# Individual snapshots and snapshot trees are supported. The names
# of the snapshots in the snapshot tree are stored in the actual
# filenames of the snapshots themselves. Descriptions of each
# snapshot can be provided and will be stored in a file named
# .$DISK.snap_descriptions
#
# The following operations can be performed:
#
# create -creates a new snapshot from the current position in the
# snapshot tree
# delete -deletes the specified snapshot and all linked snapshots
# from the snapshot tree
# branch -creates a new branch of the snapshot tree from the
# specified snapshot
# revert -reverts to the specified snapshot and deletes all linked
# snapshots from the snapshot tree
# help -displays the description and usage
#
#============================================================================
###################################################################################
# Read config files and set variables
###################################################################################
if which qemu-img > /dev/null 2>&1
then
QEMU_IMG_CMD=qemu-img
elif which qemu-img-xen > /dev/null 2>&1
then
QEMU_IMG_CMD=qemu-img-xen
fi
###################################################################################
# Script Functions
###################################################################################
########## Function: description ###############################
description() {
echo "
================================================================================
Description:
This script creates and manages snapshots of qcow2 virtual disks
Individual snapshots and snapshot trees are supported. The names
of the snapshots in the snapshot tree are stored in the actual
filenames of the snapshots themselves. Descriptions of each
snapshot can be provided and will be stored in a file named
.\$DISK.snap_descriptions
The following operations can be performed:
create -creates a new snapshot from the current position in the
snapshot tree
delete -deletes the specified snapshot and all linked snapshots
from the snapshot tree
branch -creates a new branch of the snapshot tree from the
specified snapshot
revert -reverts to the specified snapshot and deletes all linked
snapshots from the snapshot tree
help -displays the description and usage
================================================================================
"
}
########## Function: usage ###########################################
usage() {
echo
echo "Usage: vm-snapshot-disk [create|branch|revert|delete|help] options"
echo
echo "Examples:"
echo " vm-snapshot-disk create disk= [snapname= snapdescr=]"
echo " vm-snapshot-disk branch disk= snapname="
echo " vm-snapshot-disk revert disk= snapname="
echo " vm-snapshot-disk help"
echo
}
########## Function: get_options #####################################
get_options() {
case "$1" in
create|branch|revert|delete|help)
MODE="$1"
;;
*)
echo
echo "ERROR: You must provide a valid mode!"
usage
exit 1
;;
esac
if echo "$*" | grep -q "disk="
then
DISK_IMAGE=`echo "$*" | grep -o "disk=.*" | cut -d '=' -f 2 | cut -d ' ' -f 1`
fi
if echo $* | grep -q "snapname="
then
SNAPSHOT_NAME=`echo $* | grep -o "snapname=.*" | cut -d '=' -f 2 | cut -d ' ' -f 1`
fi
if echo $* | grep -q "snapdescr="
then
SNAPSHOT_DESCR=`echo $* | grep -o "snapdescr=.*" | cut -d '=' -f 2 | cut -d ' ' -f 1`
fi
if [ -z "$DISK_IMAGE" ]
then
case "$MODE" in
help|-h)
MODE=help
description
usage
exit 99
;;
*)
echo
echo "ERROR: You must supply a disk image!"
usage
exit 1
esac
fi
}
########## Function: test_disk ###########################################
test_disk() {
local DISK="$1"
if ! [ -e "$DISK" ]
then
echo
echo "ERROR: The specified disk \"$DISK\" does not exist!"
echo
exit 2
fi
if ! ($QEMU_IMG_CMD info $DISK | grep "file format" | cut -d ' ' -f 3 | grep -q qcow2) 2> /dev/null
then
echo
echo "ERROR: The specified disk \"$DISK\" does not appear to be of type qcow2"
echo " You cannot snpashot this disk!"
exit 3
fi
}
########## Function: get_backing_disk #####################################
get_backing_disk() {
"$QEMU_IMG_CMD" info "$1" | grep "backing file" | cut -d : -f 3 | sed 's/^ *//g' | sed 's/)//g'
}
########## Function: create_snapshot ######################################
create_snapshot() {
local DISK="$1"
local SNAPNAME="$2"
local SNAP_DESCR="$3"
#echo "Testing for base disk image file"
if ! [ -e "$DISK".base ]
then
local BDISK="$DISK".base
mv "$DISK" "$BDISK"
elif [ -L "$DISK" ]
then
#local BDISK=`ls -l "$DISK" |cut -d " " -f 10`
local BDISK=`ls -l "$DISK" |cut -d ">" -f 2 | sed 's/^ *//g'`
rm -f "$DISK"
fi
# find unused snap named
if [ -z "$SNAPNAME" ]
then
#echo "Finding and unused snap name"
SNAMECOUNT=1
SNAPNAME=snap"$SNAMECOUNT"
until ! ls "$DISK".* | grep -q snap"$SNAMECOUNT"
do
((SNAMECOUNT++))
SNAPNAME=snap"$SNAMECOUNT"
done
fi
#echo "$QEMU_IMG_CMD" create -f qcow2 -b "$BDISK" "$BDISK"."$SNAPNAME";read
echo " Creating new snapshot: $BDISK.$SNAPNAME"
echo "*****************************************************************"
"$QEMU_IMG_CMD" create -f qcow2 -b "$BDISK" "$BDISK"."$SNAPNAME"
ln -s "$BDISK"."$SNAPNAME" "$DISK"
# add snapshot description
echo "$BDISK.$SNAPNAME=$SNAP_DESCR" >> ."$DISK".snap_descriptions
}
########## Function: branch_at_snapshot #####################################
branch_at_snapshot() {
local DISK="$1"
local SNAPNAME="$2"
local SNAP_DESCR="$3"
if [ -z "$SNAPNAME" ]
then
echo
echo "ERROR: You must supply a snapshot name to branch from!"
echo
exit 4
fi
if ! ls "$DISK".* | grep -q "$SNAPNAME$"
then
echo
echo "ERROR: The specified snapshot \"$SNAPNAME\" does not appear to exist!"
echo
exit 5
fi
local SNAP_POINT=`ls "$DISK".* | grep "$SNAPNAME$"`
#echo "Finding and unused snap name"
local SNAMECOUNT=1
until ! ls "$DISK".* | grep -q "$SNAPNAME"-"$SNAMECOUNT"$
do
((SNAMECOUNT++))
done
SUB_SNAPNAME="$SNAPNAME"-"$SNAMECOUNT"
echo "*****************************************************************"
echo " Branching from snapshot: $SNAP_POINT"
rm -f "$DISK"
ln -s $SNAP_POINT $DISK
create_snapshot $DISK $SUB_SNAPNAME $SNAP_DESCR
}
########## Function: revert_to_snapshot #####################################
revert_to_snapshot() {
local DISK="$1"
local SNAPNAME="$2"
local SNAP_DESCR="$3"
if [ -z "$SNAPNAME" ]
then
echo
echo "ERROR: You must supply a snapshot name to revert to!"
echo
exit 4
fi
if ! ls "$DISK".* | grep -q "$SNAPNAME$"
then
echo
echo "ERROR: The specified snapshot \"$SNAPNAME\" does not appear to exist!"
echo
exit 5
fi
local SNAP_POINT=`ls "$DISK".* | grep "$SNAPNAME$"`
echo "*****************************************************************"
echo " Reverting to snapshot: $SNAP_POINT"
echo "*****************************************************************"
rm -f "$DISK"
ln -s $SNAP_POINT $DISK
rm -f $SNAP_POINT.*
# remove snapshot description
sed -i "/$SNAP_POINT\..*/d" ."$DISK".snap_descriptions
}
########## Function: delete_snapshot #####################################
delete_snapshot() {
local DISK="$1"
local SNAPNAME="$2"
local SNAP_DESC="$3"
if [ -z "$SNAPNAME" ]
then
echo
echo "ERROR: You must supply a snapshot name to delete!"
echo
exit 4
fi
if ! ls "$DISK".* | grep -q "$SNAPNAME$"
then
echo
echo "ERROR: The specified snapshot \"$SNAPNAME\" does not appear to exist!"
echo
exit 5
fi
if [ "$DISK.$SNAPNAME" = "$DISK.base" ]
then
echo
echo "ERROR: You cannot delete the base image!"
echo
exit 6
fi
local SNAP_DEL=`ls "$DISK".* | grep "$SNAPNAME$"`
local SNAP_POINT=`echo $SNAP_DEL | sed "s/\.$SNAPNAME$//g"`
if [ "$SNAP_POINT" = "$DISK.base" ]
then
echo > /dev/null
#echo "Guess its the base"
#continue
elif ls "$SNAP_POINT".* > /dev/null 2>&1
then
#echo "SNAP_POINT=$SNAP_POINT, looking for end of snap train"
local SNAP_POINT_OPTIONS=`ls "$SNAP_POINT".*`
#echo "My choices are: $SNAP_POINT_OPTIONS"
if ! [ "$SNAP_POINT_OPTIONS" = "$SNAP_DEL" ]
then
for SP in $SNAP_POINT_OPTIONS
do
if ! ls "$SP".* > /dev/null 2>&1
then
if ! [ "$SP" = "$SNAP_DEL" ]
then
SNAP_POINT="$SP"
fi
fi
done
#else
# echo "Oops. guess I don't need to look after all"
fi
elif [ "$SNAP_POINT" = "$SNAP_DEL" ]
then
#echo "Opps. Del point = Snap point. trying to fix..."
local FCOUNT=`echo $SNAP_POINT | grep -o "\." | wc -l`
((FCOUNT++))
LAST_FLD=`echo $SNAP_POINT | cut -d '.' -f $FCOUNT`
SNAP_POINT=`echo $SNAP_POINT | sed "s/\.$LAST_FLD//g"`
fi
echo "*****************************************************************"
echo " Deleting snapshot: $SNAP_DEL"
echo " Reverting to snapshot: $SNAP_POINT"
echo "*****************************************************************"
if [ -L "$DISK" ]
then
rm -f "$DISK"
fi
rm -f "$SNAP_DEL"*
ln -s "$SNAP_POINT" "$DISK"
# remove snapshot description
sed -i "/$SNAP_DEL.*/d" ."$DISK".snap_descriptions
}
###################################################################################
# Main Code Body
###################################################################################
get_options $*
test_disk "$DISK_IMAGE"
case "$MODE" in
create)
echo "*****************************************************************"
create_snapshot "$DISK_IMAGE" "$SNAPSHOT_NAME" "$SNAPSHOT_DESCR"
;;
branch)
branch_at_snapshot "$DISK_IMAGE" "$SNAPSHOT_NAME" "$SNAPSHOT_DESCR"
;;
revert)
revert_to_snapshot "$DISK_IMAGE" "$SNAPSHOT_NAME" "$SNAPSHOT_DESCR"
;;
delete)
delete_snapshot "$DISK_IMAGE" "$SNAPSHOT_NAME" "$SNAPSHOT_DESCR"
;;
esac
exit 0
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org