[arch-commits] Commit in libvirt/repos (16 files)

Evangelos Foutras foutrelis at nymeria.archlinux.org
Sat May 11 10:51:05 EDT 2013


    Date: Saturday, May 11, 2013 @ 16:51:04
  Author: foutrelis
Revision: 90319

archrelease: copy trunk to community-staging-i686, community-staging-x86_64

Added:
  libvirt/repos/community-staging-i686/
  libvirt/repos/community-staging-i686/PKGBUILD
    (from rev 90317, libvirt/trunk/PKGBUILD)
  libvirt/repos/community-staging-i686/libvirt.install
    (from rev 90317, libvirt/trunk/libvirt.install)
  libvirt/repos/community-staging-i686/libvirt.tmpfiles.d
    (from rev 90317, libvirt/trunk/libvirt.tmpfiles.d)
  libvirt/repos/community-staging-i686/libvirtd-guests.conf.d
    (from rev 90317, libvirt/trunk/libvirtd-guests.conf.d)
  libvirt/repos/community-staging-i686/libvirtd-guests.rc.d
    (from rev 90317, libvirt/trunk/libvirtd-guests.rc.d)
  libvirt/repos/community-staging-i686/libvirtd.conf.d
    (from rev 90317, libvirt/trunk/libvirtd.conf.d)
  libvirt/repos/community-staging-i686/libvirtd.rc.d
    (from rev 90317, libvirt/trunk/libvirtd.rc.d)
  libvirt/repos/community-staging-x86_64/
  libvirt/repos/community-staging-x86_64/PKGBUILD
    (from rev 90317, libvirt/trunk/PKGBUILD)
  libvirt/repos/community-staging-x86_64/libvirt.install
    (from rev 90317, libvirt/trunk/libvirt.install)
  libvirt/repos/community-staging-x86_64/libvirt.tmpfiles.d
    (from rev 90317, libvirt/trunk/libvirt.tmpfiles.d)
  libvirt/repos/community-staging-x86_64/libvirtd-guests.conf.d
    (from rev 90317, libvirt/trunk/libvirtd-guests.conf.d)
  libvirt/repos/community-staging-x86_64/libvirtd-guests.rc.d
    (from rev 90317, libvirt/trunk/libvirtd-guests.rc.d)
  libvirt/repos/community-staging-x86_64/libvirtd.conf.d
    (from rev 90317, libvirt/trunk/libvirtd.conf.d)
  libvirt/repos/community-staging-x86_64/libvirtd.rc.d
    (from rev 90317, libvirt/trunk/libvirtd.rc.d)

-------------------------------------------------+
 community-staging-i686/PKGBUILD                 |   97 +++++++++++++
 community-staging-i686/libvirt.install          |   19 ++
 community-staging-i686/libvirt.tmpfiles.d       |    4 
 community-staging-i686/libvirtd-guests.conf.d   |   11 +
 community-staging-i686/libvirtd-guests.rc.d     |  161 ++++++++++++++++++++++
 community-staging-i686/libvirtd.conf.d          |    3 
 community-staging-i686/libvirtd.rc.d            |   66 +++++++++
 community-staging-x86_64/PKGBUILD               |   97 +++++++++++++
 community-staging-x86_64/libvirt.install        |   19 ++
 community-staging-x86_64/libvirt.tmpfiles.d     |    4 
 community-staging-x86_64/libvirtd-guests.conf.d |   11 +
 community-staging-x86_64/libvirtd-guests.rc.d   |  161 ++++++++++++++++++++++
 community-staging-x86_64/libvirtd.conf.d        |    3 
 community-staging-x86_64/libvirtd.rc.d          |   66 +++++++++
 14 files changed, 722 insertions(+)

Copied: libvirt/repos/community-staging-i686/PKGBUILD (from rev 90317, libvirt/trunk/PKGBUILD)
===================================================================
--- community-staging-i686/PKGBUILD	                        (rev 0)
+++ community-staging-i686/PKGBUILD	2013-05-11 14:51:04 UTC (rev 90319)
@@ -0,0 +1,97 @@
+# $Id$
+# Maintainer: Sergej Pupykin <pupykin.s+arch at gmail.com>
+# Contributor: Jonathan Wiersma <archaur at jonw dot org>
+
+pkgname=libvirt
+pkgver=1.0.5
+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' 'libnl' 'libx11' 'audit')
+makedepends=('pkgconfig' 'lvm2' 'linux-api-headers')
+optdepends=('bridge-utils: for briged networking (default)'
+	    'dnsmasq: for NAT/DHCP for guests'
+	    'kvm'
+	    'openbsd-netcat: for remote management over ssh'
+	    'qemu'
+	    'radvd'
+	    'dmidecode'
+	    'ebtables')
+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
+	libvirt.tmpfiles.d)
+md5sums=('91c4145f49bcf92e89470fa3fb28fff6'
+         'c43244c40a0437038c82089618e7beaa'
+         '3ed0e24f5b5e25bf553f5427d64915e6'
+         '0ee5b6c58590ff392a266f20f7928d1f'
+         '0a96ed876ffb1fcb9dff5a9b3a609c1e'
+         '020971887442ebbf1b6949e031c8dd3f')
+
+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
+
+  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 \
+	--with-init-script=systemd --with-audit \
+	--with-qemu-user=nobody --with-qemu-group=nobody \
+	--without-netcf --with-interface
+  make
+
+  sed -i 's|/etc/sysconfig/libvirtd|/etc/conf.d/libvirtd|' daemon/libvirtd.service
+  sed -i \
+    -e 's|/etc/sysconfig/libvirt-guests|/etc/conf.d/libvirtd-guests|' \
+    -e 's|/etc/init.d/libvirt-g|/etc/rc.d/libvirtd-g|g' \
+    -e 's|After=.*|After=syslog.target network.target libvirtd.service|' \
+    tools/libvirt-guests.service
+  sed -i 's|@sbindir@|/usr/sbin|g' src/virtlockd.service
+  sed -i 's|#group =.*|group="kvm"|' src/qemu/qemu.conf
+}
+
+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
+
+  # systemd stuff
+  install -D -m644 "$srcdir"/libvirt.tmpfiles.d "$pkgdir"/usr/lib/tmpfiles.d/libvirt.conf
+  mv "$pkgdir"/lib/* "$pkgdir"/usr/lib/
+
+
+  rm -rf \
+	"$pkgdir"/var/run \
+	"$pkgdir"/etc/sysconfig \
+	"$pkgdir"/etc/rc.d/init.d \
+	"$pkgdir"/lib \
+	"$pkgdir"/etc/sysctl.d
+}

Copied: libvirt/repos/community-staging-i686/libvirt.install (from rev 90317, libvirt/trunk/libvirt.install)
===================================================================
--- community-staging-i686/libvirt.install	                        (rev 0)
+++ community-staging-i686/libvirt.install	2013-05-11 14:51:04 UTC (rev 90319)
@@ -0,0 +1,19 @@
+_libvirt_setup() {
+  systemd-tmpfiles --create libvirt.conf
+}
+
+post_install() {
+  _libvirt_setup || return 1
+  echo ">>>  See https://wiki.archlinux.org/index.php/Libvirt for more info"
+}
+
+post_upgrade() {
+  _libvirt_setup || return 1
+  echo ">>> You may need to run 'rm -rf ~/.libvirt'"
+  echo ">>> libvirt runs qemu from nobody:nobody by default"
+  echo ">>> change it in /etc/libvirt/qemu.conf"
+}
+
+post_remove() {
+   rm -f /usr/lib/python[0-9].[0-9]/site-packages/libvirt.pyc
+}

Copied: libvirt/repos/community-staging-i686/libvirt.tmpfiles.d (from rev 90317, libvirt/trunk/libvirt.tmpfiles.d)
===================================================================
--- community-staging-i686/libvirt.tmpfiles.d	                        (rev 0)
+++ community-staging-i686/libvirt.tmpfiles.d	2013-05-11 14:51:04 UTC (rev 90319)
@@ -0,0 +1,4 @@
+d /run/libvirt/qemu 0755 root root -
+d /run/libvirt/lxc 0755 root root -
+d /run/libvirt/uml 0755 root root -
+d /run/libvirt/network 0755 root root -

Copied: libvirt/repos/community-staging-i686/libvirtd-guests.conf.d (from rev 90317, libvirt/trunk/libvirtd-guests.conf.d)
===================================================================
--- community-staging-i686/libvirtd-guests.conf.d	                        (rev 0)
+++ community-staging-i686/libvirtd-guests.conf.d	2013-05-11 14:51:04 UTC (rev 90319)
@@ -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=60

Copied: libvirt/repos/community-staging-i686/libvirtd-guests.rc.d (from rev 90317, libvirt/trunk/libvirtd-guests.rc.d)
===================================================================
--- community-staging-i686/libvirtd-guests.rc.d	                        (rev 0)
+++ community-staging-i686/libvirtd-guests.rc.d	2013-05-11 14:51:04 UTC (rev 90319)
@@ -0,0 +1,161 @@
+#!/bin/bash
+
+source /etc/conf.d/libvirtd-guests
+[ -f /etc/rc.conf ] && source /etc/rc.conf
+
+if [ -f /etc/rc.d/functions ]; then
+    . /etc/rc.d/functions
+else
+    stat_busy() {
+        echo "$*"
+    }
+
+    stat_fail() {
+        echo "FAIL"
+    }
+
+    stat_done() {
+        echo "DONE"
+    }
+
+    add_daemon() {
+        true
+    }
+
+    rm_daemon() {
+        true
+    }
+fi
+
+
+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

Copied: libvirt/repos/community-staging-i686/libvirtd.conf.d (from rev 90317, libvirt/trunk/libvirtd.conf.d)
===================================================================
--- community-staging-i686/libvirtd.conf.d	                        (rev 0)
+++ community-staging-i686/libvirtd.conf.d	2013-05-11 14:51:04 UTC (rev 90319)
@@ -0,0 +1,3 @@
+LIBVIRTD_CONFIG="/etc/libvirt/libvirtd.conf"
+LIBVIRTD_ARGS="-p /var/run/libvirtd.pid"
+KRB5_KTNAME="/etc/libvirt/krb5.tab"

Copied: libvirt/repos/community-staging-i686/libvirtd.rc.d (from rev 90317, libvirt/trunk/libvirtd.rc.d)
===================================================================
--- community-staging-i686/libvirtd.rc.d	                        (rev 0)
+++ community-staging-i686/libvirtd.rc.d	2013-05-11 14:51:04 UTC (rev 90319)
@@ -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

Copied: libvirt/repos/community-staging-x86_64/PKGBUILD (from rev 90317, libvirt/trunk/PKGBUILD)
===================================================================
--- community-staging-x86_64/PKGBUILD	                        (rev 0)
+++ community-staging-x86_64/PKGBUILD	2013-05-11 14:51:04 UTC (rev 90319)
@@ -0,0 +1,97 @@
+# $Id$
+# Maintainer: Sergej Pupykin <pupykin.s+arch at gmail.com>
+# Contributor: Jonathan Wiersma <archaur at jonw dot org>
+
+pkgname=libvirt
+pkgver=1.0.5
+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' 'libnl' 'libx11' 'audit')
+makedepends=('pkgconfig' 'lvm2' 'linux-api-headers')
+optdepends=('bridge-utils: for briged networking (default)'
+	    'dnsmasq: for NAT/DHCP for guests'
+	    'kvm'
+	    'openbsd-netcat: for remote management over ssh'
+	    'qemu'
+	    'radvd'
+	    'dmidecode'
+	    'ebtables')
+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
+	libvirt.tmpfiles.d)
+md5sums=('91c4145f49bcf92e89470fa3fb28fff6'
+         'c43244c40a0437038c82089618e7beaa'
+         '3ed0e24f5b5e25bf553f5427d64915e6'
+         '0ee5b6c58590ff392a266f20f7928d1f'
+         '0a96ed876ffb1fcb9dff5a9b3a609c1e'
+         '020971887442ebbf1b6949e031c8dd3f')
+
+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
+
+  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 \
+	--with-init-script=systemd --with-audit \
+	--with-qemu-user=nobody --with-qemu-group=nobody \
+	--without-netcf --with-interface
+  make
+
+  sed -i 's|/etc/sysconfig/libvirtd|/etc/conf.d/libvirtd|' daemon/libvirtd.service
+  sed -i \
+    -e 's|/etc/sysconfig/libvirt-guests|/etc/conf.d/libvirtd-guests|' \
+    -e 's|/etc/init.d/libvirt-g|/etc/rc.d/libvirtd-g|g' \
+    -e 's|After=.*|After=syslog.target network.target libvirtd.service|' \
+    tools/libvirt-guests.service
+  sed -i 's|@sbindir@|/usr/sbin|g' src/virtlockd.service
+  sed -i 's|#group =.*|group="kvm"|' src/qemu/qemu.conf
+}
+
+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
+
+  # systemd stuff
+  install -D -m644 "$srcdir"/libvirt.tmpfiles.d "$pkgdir"/usr/lib/tmpfiles.d/libvirt.conf
+  mv "$pkgdir"/lib/* "$pkgdir"/usr/lib/
+
+
+  rm -rf \
+	"$pkgdir"/var/run \
+	"$pkgdir"/etc/sysconfig \
+	"$pkgdir"/etc/rc.d/init.d \
+	"$pkgdir"/lib \
+	"$pkgdir"/etc/sysctl.d
+}

Copied: libvirt/repos/community-staging-x86_64/libvirt.install (from rev 90317, libvirt/trunk/libvirt.install)
===================================================================
--- community-staging-x86_64/libvirt.install	                        (rev 0)
+++ community-staging-x86_64/libvirt.install	2013-05-11 14:51:04 UTC (rev 90319)
@@ -0,0 +1,19 @@
+_libvirt_setup() {
+  systemd-tmpfiles --create libvirt.conf
+}
+
+post_install() {
+  _libvirt_setup || return 1
+  echo ">>>  See https://wiki.archlinux.org/index.php/Libvirt for more info"
+}
+
+post_upgrade() {
+  _libvirt_setup || return 1
+  echo ">>> You may need to run 'rm -rf ~/.libvirt'"
+  echo ">>> libvirt runs qemu from nobody:nobody by default"
+  echo ">>> change it in /etc/libvirt/qemu.conf"
+}
+
+post_remove() {
+   rm -f /usr/lib/python[0-9].[0-9]/site-packages/libvirt.pyc
+}

Copied: libvirt/repos/community-staging-x86_64/libvirt.tmpfiles.d (from rev 90317, libvirt/trunk/libvirt.tmpfiles.d)
===================================================================
--- community-staging-x86_64/libvirt.tmpfiles.d	                        (rev 0)
+++ community-staging-x86_64/libvirt.tmpfiles.d	2013-05-11 14:51:04 UTC (rev 90319)
@@ -0,0 +1,4 @@
+d /run/libvirt/qemu 0755 root root -
+d /run/libvirt/lxc 0755 root root -
+d /run/libvirt/uml 0755 root root -
+d /run/libvirt/network 0755 root root -

Copied: libvirt/repos/community-staging-x86_64/libvirtd-guests.conf.d (from rev 90317, libvirt/trunk/libvirtd-guests.conf.d)
===================================================================
--- community-staging-x86_64/libvirtd-guests.conf.d	                        (rev 0)
+++ community-staging-x86_64/libvirtd-guests.conf.d	2013-05-11 14:51:04 UTC (rev 90319)
@@ -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=60

Copied: libvirt/repos/community-staging-x86_64/libvirtd-guests.rc.d (from rev 90317, libvirt/trunk/libvirtd-guests.rc.d)
===================================================================
--- community-staging-x86_64/libvirtd-guests.rc.d	                        (rev 0)
+++ community-staging-x86_64/libvirtd-guests.rc.d	2013-05-11 14:51:04 UTC (rev 90319)
@@ -0,0 +1,161 @@
+#!/bin/bash
+
+source /etc/conf.d/libvirtd-guests
+[ -f /etc/rc.conf ] && source /etc/rc.conf
+
+if [ -f /etc/rc.d/functions ]; then
+    . /etc/rc.d/functions
+else
+    stat_busy() {
+        echo "$*"
+    }
+
+    stat_fail() {
+        echo "FAIL"
+    }
+
+    stat_done() {
+        echo "DONE"
+    }
+
+    add_daemon() {
+        true
+    }
+
+    rm_daemon() {
+        true
+    }
+fi
+
+
+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

Copied: libvirt/repos/community-staging-x86_64/libvirtd.conf.d (from rev 90317, libvirt/trunk/libvirtd.conf.d)
===================================================================
--- community-staging-x86_64/libvirtd.conf.d	                        (rev 0)
+++ community-staging-x86_64/libvirtd.conf.d	2013-05-11 14:51:04 UTC (rev 90319)
@@ -0,0 +1,3 @@
+LIBVIRTD_CONFIG="/etc/libvirt/libvirtd.conf"
+LIBVIRTD_ARGS="-p /var/run/libvirtd.pid"
+KRB5_KTNAME="/etc/libvirt/krb5.tab"

Copied: libvirt/repos/community-staging-x86_64/libvirtd.rc.d (from rev 90317, libvirt/trunk/libvirtd.rc.d)
===================================================================
--- community-staging-x86_64/libvirtd.rc.d	                        (rev 0)
+++ community-staging-x86_64/libvirtd.rc.d	2013-05-11 14:51:04 UTC (rev 90319)
@@ -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



More information about the arch-commits mailing list