summaryrefslogtreecommitdiff
path: root/community-testing
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2012-05-18 00:02:20 +0000
committerroot <root@rshg054.dnsready.net>2012-05-18 00:02:20 +0000
commit2f104ecf78d6a93ba8d67273b76364cb1365a6cf (patch)
treec93787a9c08d8cb41a424644dc09fc529dfd63f1 /community-testing
parentf675762300c4ee2717e029975bb3f94312245276 (diff)
Fri May 18 00:02:20 UTC 2012
Diffstat (limited to 'community-testing')
-rw-r--r--community-testing/libvirt/PKGBUILD77
-rw-r--r--community-testing/libvirt/libvirt.install38
-rw-r--r--community-testing/libvirt/libvirtd-guests.conf.d11
-rw-r--r--community-testing/libvirt/libvirtd-guests.rc.d137
-rw-r--r--community-testing/libvirt/libvirtd.conf.d3
-rw-r--r--community-testing/libvirt/libvirtd.rc.d66
-rw-r--r--community-testing/libvirt/openbsd-netcat-default.patch36
7 files changed, 368 insertions, 0 deletions
diff --git a/community-testing/libvirt/PKGBUILD b/community-testing/libvirt/PKGBUILD
new file mode 100644
index 000000000..d2ac57345
--- /dev/null
+++ b/community-testing/libvirt/PKGBUILD
@@ -0,0 +1,77 @@
+# $Id: PKGBUILD 70775 2012-05-16 15:03:54Z spupykin $
+# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
+# Contributor: Jonathan Wiersma <archaur at jonw dot org>
+
+pkgname=libvirt
+pkgver=0.9.12
+pkgrel=2
+pkgdesc="API for controlling virtualization engines (openvz,kvm,qemu,virtualbox,xen,etc)"
+arch=('i686' 'x86_64')
+url="http://libvirt.org/"
+license=('LGPL')
+depends=('e2fsprogs' 'gnutls' 'iptables' 'libxml2' 'parted' 'polkit' 'python2'
+ 'avahi' 'yajl' 'libpciaccess' 'udev' 'dbus-core' 'libxau' 'libxdmcp' 'libpcap'
+ 'curl' 'libsasl' 'libgcrypt' 'libgpg-error' 'openssl' 'libxcb' 'gcc-libs'
+ 'iproute2' 'netcf' 'libnl1')
+makedepends=('pkgconfig' 'lvm2')
+optdepends=('bridge-utils: for briged networking (default)'
+ 'dnsmasq: for NAT/DHCP for guests'
+ 'kvm'
+ 'openbsd-netcat: for remote management over ssh'
+ 'qemu'
+ 'radvd'
+ 'dmidecode')
+options=('emptydirs' '!libtool')
+backup=('etc/conf.d/libvirtd'
+ 'etc/conf.d/libvirtd-guests'
+ 'etc/libvirt/libvirtd.conf'
+ 'etc/libvirt/libvirt.conf'
+ 'etc/libvirt/qemu.conf'
+ 'etc/sasl2/libvirt.conf')
+install="libvirt.install"
+source=("http://libvirt.org/sources/$pkgname-$pkgver.tar.gz"
+ libvirtd.rc.d
+ libvirtd.conf.d
+ libvirtd-guests.rc.d
+ libvirtd-guests.conf.d
+ openbsd-netcat-default.patch)
+md5sums=('5e842bc55733ceba60c64767580ff3e4'
+ 'c43244c40a0437038c82089618e7beaa'
+ '3ed0e24f5b5e25bf553f5427d64915e6'
+ '8297b1be794a24cc77f66af9380ace59'
+ 'bc2971dacdbac967fc3474e50affc345'
+ 'b0be50eb9dfe4d133decf23b60880f7d')
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ # python2 fix
+ export PYTHON=`which python2`
+ for file in $(find . -name '*.py' -print); do
+ sed -i 's_#!.*/usr/bin/python_#!/usr/bin/python2_' $file
+ sed -i 's_#!.*/usr/bin/env.*python_#!/usr/bin/env python2_' $file
+ done
+
+ [ $NOEXTRACT -eq 1 ] || patch -Np1 -i "$srcdir"/openbsd-netcat-default.patch
+
+ export LDFLAGS=-lX11
+ export RADVD=/usr/sbin/radvd
+ [ -f Makefile ] || ./configure --prefix=/usr --libexec=/usr/lib/"$pkgname" \
+ --with-storage-lvm --without-xen --with-udev --without-hal --disable-static
+ find -name Makefile -exec sed -i 's#-L /usr#-L/usr#' {} \;
+ make -j1
+}
+
+package() {
+ cd "$srcdir/$pkgname-$pkgver"
+
+ make DESTDIR="$pkgdir" install
+
+ install -D -m755 "$srcdir"/libvirtd.rc.d "$pkgdir"/etc/rc.d/libvirtd
+ install -D -m644 "$srcdir"/libvirtd.conf.d "$pkgdir"/etc/conf.d/libvirtd
+
+ install -D -m755 "$srcdir"/libvirtd-guests.rc.d "$pkgdir"/etc/rc.d/libvirtd-guests
+ install -D -m644 "$srcdir"/libvirtd-guests.conf.d "$pkgdir"/etc/conf.d/libvirtd-guests
+
+ rm -rf $pkgdir/var/run
+}
diff --git a/community-testing/libvirt/libvirt.install b/community-testing/libvirt/libvirt.install
new file mode 100644
index 000000000..3881386d2
--- /dev/null
+++ b/community-testing/libvirt/libvirt.install
@@ -0,0 +1,38 @@
+_libvirt_setup() {
+ rm -f /usr/lib/python?.?/site-packages/libvirt.pyc
+ echo ">>> To use libvirt as a non-root user:"
+ echo ">>> Use polkit to grant access."
+ echo ">>> ...or change the access model in /etc/libvirt/libvirtd.conf."
+ echo ">>> (see unixperms.patch in PKGBUILD for help)"
+ echo ""
+}
+
+post_install() {
+ _libvirt_setup || return 1
+ echo ">>> Be sure to see optdepends as you may find some of them helpfull."
+ echo ">>> Especially: bridge-utils, dnsmasq, and hal."
+ echo ""
+ echo ">>> To start libvirtd run: '/etc/rc.d/libvirtd start' as root."
+ echo ">>> Add 'libvirtd' to daemons in /etc/rc.conf if you want it to load upon"
+ echo ">>> booting."
+ echo ""
+ /bin/true
+}
+
+post_upgrade() {
+ _libvirt_setup || return 1
+ echo ">>> To finish the upgrade, restart libvirtd by running the command:"
+ echo ">>> '/etc/rc.d/libvirtd restart' as root or rebooting."
+ echo ">>> You may also need to run 'rm -rf ~/.libvirt'"
+ echo ""
+ /bin/true
+}
+
+post_remove() {
+ rm -f /usr/lib/python[0-9].[0-9]/site-packages/libvirt.pyc
+ echo ">>> You may wish to delete the group 'libvirt' if it still exists."
+ echo ">>> It can be removed by running 'groupdel libvirt' as root."
+ echo ""
+ depmod -a
+ /bin/true
+}
diff --git a/community-testing/libvirt/libvirtd-guests.conf.d b/community-testing/libvirt/libvirtd-guests.conf.d
new file mode 100644
index 000000000..02a933715
--- /dev/null
+++ b/community-testing/libvirt/libvirtd-guests.conf.d
@@ -0,0 +1,11 @@
+LIBVIRTD_STOP_ACTION=suspend
+
+#LIBVIRTD_URI="-c qemu+ssh://user@host/system"
+LIBVIRTD_URI=""
+
+#LIBVIRTD_BYPASS_CACHE="--bypass-cache"
+LIBVIRTD_BYPASS_CACHE=""
+
+LIBVIRTD_START_DELAY=0
+
+LIBVIRTD_SHUTDOWN_TIMEOUT=3
diff --git a/community-testing/libvirt/libvirtd-guests.rc.d b/community-testing/libvirt/libvirtd-guests.rc.d
new file mode 100644
index 000000000..670b5431a
--- /dev/null
+++ b/community-testing/libvirt/libvirtd-guests.rc.d
@@ -0,0 +1,137 @@
+#!/bin/bash
+
+. /etc/conf.d/libvirtd-guests
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+LIBVIRTD_LISTFILE="/var/state/libvirtd/vm-list"
+
+# get guest state by name
+libvirt_get_guest_state()
+{
+ virsh $LIBVIRTD_URI dominfo "$1" | grep -E '^State:' | awk '{print $2}'
+}
+
+# list IDs of running guests
+libvirt_list()
+{
+
+ list=$(virsh $LIBVIRTD_URI list)
+
+ if [ $? -ne 0 ]; then
+ RETVAL=1
+ return 1
+ fi
+
+ uuids=
+ for id in $(echo "$list" | awk 'NR > 2 {print $1}'); do
+ uuid=$(virsh $LIBVIRTD_UTI dominfo $id | awk '/^UUID:/{print $2}')
+ if [ -z "$uuid" ]; then
+ RETVAL=1
+ return 1
+ fi
+ uuids="$uuids $uuid"
+ done
+
+ echo $uuids
+
+}
+
+libvirt_domname()
+{
+ uuid=$1
+ name=$(virsh $LIBVIRTD_URI dominfo $uuid | awk 'NR == 2 {$1=""; print}')
+
+ echo $name
+}
+
+# suspend guest by name
+libvirt_suspend()
+{
+ virsh $LIBVIRTD_URI $LIBVIRTD_BYPASS_CACHE managedsave "$1" >/dev/null
+ timeout=$LIBVIRTD_SHUTDOWN_TIMEOUT
+ while [ "$timeout" -gt 0 ]; do
+ sleep 1
+ timeout=$((timeout - 1))
+ state=`libvirt_get_guest_state "$1"`
+ [ "x$state" == "xshut" ] && return 0
+ done
+ return 1
+}
+
+# shutdown guest by name
+libvirt_shutdown()
+{
+ virsh $LIBVIRTD_URI shutdown "$1" >/dev/null
+ timeout=$LIBVIRTD_SHUTDOWN_TIMEOUT
+ while [ "$timeout" -gt 0 ]; do
+ sleep 1
+ timeout=$((timeout - 1))
+ state=`libvirt_get_guest_state "$1"`
+ [ "x$state" == "xshut" ] && return 0
+ done
+ return 1
+}
+
+# start guest by name
+libvirt_start()
+{
+ virsh $LIBVIRTD_URI $LIBVIRTD_BYPASS_CACHE start "$1" >/dev/null
+}
+
+# stop all guests
+libvirt_stop_all()
+{
+ mkdir -p `dirname $LIBVIRTD_LISTFILE`
+ echo -n >$LIBVIRTD_LISTFILE
+
+ for i in `libvirt_list`; do
+ name=`libvirt_domname $i`
+ if [ "x$LIBVIRTD_STOP_ACTION" == "xsuspend" ]; then
+ stat_busy "Suspending libvirtd/$name guest"
+ libvirt_suspend "$i"
+ else
+ stat_busy "Shutting libvirtd/$i guest down"
+ libvirt_shutdown "$i"
+ fi
+ [ $? -eq 0 ] && stat_done || stat_fail
+ echo $i >>$LIBVIRTD_LISTFILE
+ done
+}
+
+# start all guests
+libvirt_start_all()
+{
+ if [ -f $LIBVIRTD_LISTFILE ]; then
+ for i in `cat $LIBVIRTD_LISTFILE`; do
+ name='libvirt_domname $i'
+ stat_busy "Starting/resuming libvirtd/$name guest"
+ libvirt_start "$i"
+ [ $? -eq 0 ] && { sleep $LIBVIRTD_START_DELAY; stat_done; } || stat_fail
+ done
+ fi
+ rm -f $LIBVIRTD_LISTFILE
+}
+
+# main
+LC_ALL=C
+LANG=C
+case "$1" in
+ start)
+ libvirt_start_all
+ add_daemon libvirtd-guests
+ ;;
+ stop)
+ libvirt_stop_all
+ rm_daemon libvirtd-guests
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart}"
+ ;;
+esac
+exit 0
diff --git a/community-testing/libvirt/libvirtd.conf.d b/community-testing/libvirt/libvirtd.conf.d
new file mode 100644
index 000000000..d4d25b47a
--- /dev/null
+++ b/community-testing/libvirt/libvirtd.conf.d
@@ -0,0 +1,3 @@
+LIBVIRTD_CONFIG="/etc/libvirt/libvirtd.conf"
+LIBVIRTD_ARGS="-p /var/run/libvirtd.pid"
+KRB5_KTNAME="/etc/libvirt/krb5.tab"
diff --git a/community-testing/libvirt/libvirtd.rc.d b/community-testing/libvirt/libvirtd.rc.d
new file mode 100644
index 000000000..193bffa9c
--- /dev/null
+++ b/community-testing/libvirt/libvirtd.rc.d
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/conf.d/libvirtd
+. /etc/rc.d/functions
+
+LIBVIRTD_CONFIG_ARGS=
+if [ -n "$LIBVIRTD_CONFIG" ]
+then
+ LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG"
+fi
+
+PID=`pidof -o %PPID /usr/sbin/libvirtd`
+case "$1" in
+ start)
+ stat_busy "Starting libvirtd"
+ export RADVD=/usr/sbin/radvd
+ for i in /var/run/libvirt/qemu /var/run/libvirt/lxc /var/run/libvirt/uml /var/run/libvirt/network; do
+ [ -d $i ] || mkdir -p $i
+ done
+ [ -z "$PID" ] && (
+ mkdir -p /var/{cache,run}/libvirt
+ rm -rf /var/cache/libvirt/*
+ KRB5_KTNAME=$KRB5_KTNAME \
+ /usr/sbin/libvirtd --daemon $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
+ )
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ add_daemon libvirtd
+ stat_done
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping libvirtd"
+ [ ! -z "$PID" ] && (
+ kill $PID &> /dev/null
+ rm -rf /var/cache/libvirt/*
+ rm -f /var/run/libvirtd.pid
+ )
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ rm_daemon libvirtd
+ stat_done
+ fi
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ reload)
+ stat_busy "Reloading libvirtd configuration"
+ [ ! -z "$PID" ] && kill -HUP $PID &> /dev/null
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ stat_done
+ fi
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload}"
+ ;;
+esac
+exit 0
diff --git a/community-testing/libvirt/openbsd-netcat-default.patch b/community-testing/libvirt/openbsd-netcat-default.patch
new file mode 100644
index 000000000..a01b4f14e
--- /dev/null
+++ b/community-testing/libvirt/openbsd-netcat-default.patch
@@ -0,0 +1,36 @@
+diff -wbBur libvirt-0.9.7/src/qemu/qemu_migration.c libvirt-0.9.7.my/src/qemu/qemu_migration.c
+--- libvirt-0.9.7/src/qemu/qemu_migration.c 2011-10-31 07:46:04.000000000 +0400
++++ libvirt-0.9.7.my/src/qemu/qemu_migration.c 2011-11-08 15:46:10.000000000 +0400
+@@ -1589,7 +1589,7 @@
+ spec->dest.unix_socket.file);
+ } else {
+ const char *args[] = {
+- "nc", "-U", spec->dest.unix_socket.file, NULL
++ "nc.openbsd", "-U", spec->dest.unix_socket.file, NULL
+ };
+ ret = qemuMonitorMigrateToCommand(priv->mon, migrate_flags, args);
+ }
+diff -wbBur libvirt-0.9.7/src/remote/remote_driver.c libvirt-0.9.7.my/src/remote/remote_driver.c
+--- libvirt-0.9.7/src/remote/remote_driver.c 2011-11-08 07:53:30.000000000 +0400
++++ libvirt-0.9.7.my/src/remote/remote_driver.c 2011-11-08 15:46:10.000000000 +0400
+@@ -614,7 +614,7 @@
+ username,
+ !tty,
+ !verify,
+- netcat ? netcat : "nc",
++ netcat ? netcat : "nc.openbsd",
+ keyfile,
+ sockname)))
+ goto failed;
+diff -wbBur libvirt-0.9.7/src/rpc/virnetsocket.c libvirt-0.9.7.my/src/rpc/virnetsocket.c
+--- libvirt-0.9.7/src/rpc/virnetsocket.c 2011-11-08 07:53:30.000000000 +0400
++++ libvirt-0.9.7.my/src/rpc/virnetsocket.c 2011-11-08 15:46:31.000000000 +0400
+@@ -642,7 +642,7 @@
+ virCommandAddArgList(cmd, "-o", "StrictHostKeyChecking=no", NULL);
+
+ if (!netcat)
+- netcat = "nc";
++ netcat = "nc.openbsd";
+
+ virCommandAddArgList(cmd, nodename, "sh", "-c", NULL);
+