aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorLeonardo Arena <rnalrd@gmail.com>2011-05-16 13:59:53 +0000
committerLeonardo Arena <rnalrd@gmail.com>2011-05-16 14:00:58 +0000
commitd44c14790917243e49797896a79c6fefc9a9b94d (patch)
tree37dd46ddaf26c9c2d68002a7b711f0503c22c3e6 /main
parentd95f46d8f7ee391376b9870c16918227a7311b90 (diff)
downloadaports-d44c14790917243e49797896a79c6fefc9a9b94d.tar.bz2
aports-d44c14790917243e49797896a79c6fefc9a9b94d.tar.xz
testing/libvirt: move to main
Diffstat (limited to 'main')
-rw-r--r--main/libvirt/APKBUILD47
-rw-r--r--main/libvirt/fix_undefined_symbol_error_when_macvtap_support_is_disabled.patch117
-rw-r--r--main/libvirt/libvirt.confd27
-rw-r--r--main/libvirt/libvirt.initd87
4 files changed, 278 insertions, 0 deletions
diff --git a/main/libvirt/APKBUILD b/main/libvirt/APKBUILD
new file mode 100644
index 0000000000..7b708a57ba
--- /dev/null
+++ b/main/libvirt/APKBUILD
@@ -0,0 +1,47 @@
+# Maintainer: Leonardo Arena <rnalrd@gmail.com>
+pkgname=libvirt
+pkgver=0.9.1
+pkgrel=1
+pkgdesc="A virtualization API for several hypervisor and container systems"
+url="http://libvirt.org/"
+arch="all"
+license="LGPL"
+depends="netcat-openbsd python"
+makedepends="augeas-dev bridge-utils-dev device-mapper e2fsprogs-dev gnutls-dev
+ libcap-ng-dev libgpg-error-dev libnetcf-dev libnl-dev libxml2-dev
+ libxslt-dev libtasn1-dev lvm2-dev gnutls-dev open-iscsi parted-dev perl
+ pkgconfig udev-dev zlib-dev"
+install=
+subpackages="$pkgname-dev $pkgname-doc"
+source="http://libvirt.org/sources/$pkgname-$pkgver.tar.gz
+ libvirt.confd
+ libvirt.initd"
+
+_builddir="$srcdir"/$pkgname-$pkgver
+
+prepare() {
+ cd "$_builddir"
+# patch -p1 < ../fix_undefined_symbol_error_when_macvtap_support_is_disabled.patch || return 1
+ return 0
+}
+
+build() {
+ cd "$_builddir"
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --libexec=/usr/lib/"$pkgname"
+ make || return 1
+}
+
+package() {
+ cd "$_builddir"
+ make DESTDIR="$pkgdir" install
+ install -D -m755 $srcdir/$pkgname.initd $pkgdir/etc/init.d/libvirtd
+ install -D -m755 $srcdir/$pkgname.confd $pkgdir/etc/conf.d/libvirtd
+}
+
+md5sums="4182dbe290cca4344a5387950dc06433 libvirt-0.9.1.tar.gz
+1c84a7baeafe0a7f4e9d7ae5180311b7 libvirt.confd
+3d32c12642cb9a84baf019c7b0971755 libvirt.initd"
diff --git a/main/libvirt/fix_undefined_symbol_error_when_macvtap_support_is_disabled.patch b/main/libvirt/fix_undefined_symbol_error_when_macvtap_support_is_disabled.patch
new file mode 100644
index 0000000000..c00d38bd1f
--- /dev/null
+++ b/main/libvirt/fix_undefined_symbol_error_when_macvtap_support_is_disabled.patch
@@ -0,0 +1,117 @@
+diff --git a/src/libvirt_macvtap.syms b/src/libvirt_macvtap.syms
+index 107b7da..b48565b 100644
+--- a/src/libvirt_macvtap.syms
++++ b/src/libvirt_macvtap.syms
+@@ -1,9 +1,10 @@
+ #
++# These symbols are dependent on WITH_MACVTAP.
++#
++
+
+ # macvtap.h
+ delMacvtap;
+ openMacvtapTap;
+-virVMOperationTypeFromString;
+-virVMOperationTypeToString;
+ vpAssociatePortProfileId;
+ vpDisassociatePortProfileId;
+diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
+index 310d8f4..3c1c823 100644
+--- a/src/libvirt_private.syms
++++ b/src/libvirt_private.syms
+@@ -504,6 +504,11 @@ virLogStartup;
+ virLogUnlock;
+
+
++# macvtap.h
++virVMOperationTypeFromString;
++virVMOperationTypeToString;
++
++
+ # memory.h
+ virAlloc;
+ virAllocN;
+diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
+index fcb90a3..aa3478f 100644
+--- a/src/qemu/qemu_driver.c
++++ b/src/qemu/qemu_driver.c
+@@ -11879,6 +11879,7 @@ cleanup:
+ return ret;
+ }
+
++#if WITH_MACVTAP
+ static void
+ qemudVPAssociatePortProfiles(virDomainDefPtr def) {
+ int i;
+@@ -11913,6 +11914,7 @@ err_exit:
+ }
+ }
+ }
++#endif /* WITH_MACVTAP */
+
+ /* Finish is the third and final step, and it runs on the destination host. */
+ static virDomainPtr
+@@ -11974,7 +11976,9 @@ qemudDomainMigrateFinish2 (virConnectPtr dconn,
+ goto cleanup;
+ }
+
++#if WITH_MACVTAP
+ qemudVPAssociatePortProfiles(vm->def);
++#endif /* WITH_MACVTAP */
+
+ if (flags & VIR_MIGRATE_PERSIST_DEST) {
+ if (vm->persistent)
+diff --git a/src/util/macvtap.h b/src/util/macvtap.h
+index 389d1fd..3ae2c24 100644
+--- a/src/util/macvtap.h
++++ b/src/util/macvtap.h
+@@ -57,11 +57,6 @@ struct _virVirtualPortProfileParams {
+ } u;
+ };
+
+-
+-# if defined(WITH_MACVTAP)
+-
+-# include "internal.h"
+-
+ enum virVMOperationType {
+ VIR_VM_OP_CREATE,
+ VIR_VM_OP_SAVE,
+@@ -75,6 +70,10 @@ enum virVMOperationType {
+ VIR_VM_OP_LAST
+ };
+
++# if WITH_MACVTAP
++
++# include "internal.h"
++
+ int openMacvtapTap(const char *ifname,
+ const unsigned char *macaddress,
+ const char *linkdev,
+@@ -90,11 +89,9 @@ void delMacvtap(const char *ifname,
+ const char *linkdev,
+ virVirtualPortProfileParamsPtr virtPortProfile);
+
+-# endif /* WITH_MACVTAP */
+-
+-# define MACVTAP_MODE_PRIVATE_STR "private"
+-# define MACVTAP_MODE_VEPA_STR "vepa"
+-# define MACVTAP_MODE_BRIDGE_STR "bridge"
++# define MACVTAP_MODE_PRIVATE_STR "private"
++# define MACVTAP_MODE_VEPA_STR "vepa"
++# define MACVTAP_MODE_BRIDGE_STR "bridge"
+
+ int vpAssociatePortProfileId(const char *macvtap_ifname,
+ const unsigned char *macvtap_macaddr,
+@@ -109,6 +106,8 @@ int vpDisassociatePortProfileId(const char *macvtap_ifname,
+ const virVirtualPortProfileParamsPtr virtPort,
+ enum virVMOperationType vmOp);
+
++# endif /* WITH_MACVTAP */
++
+ VIR_ENUM_DECL(virVirtualPort)
+ VIR_ENUM_DECL(virVMOperation)
+
+--
+1.7.0.4
+
diff --git a/main/libvirt/libvirt.confd b/main/libvirt/libvirt.confd
new file mode 100644
index 0000000000..d51bdb99d1
--- /dev/null
+++ b/main/libvirt/libvirt.confd
@@ -0,0 +1,27 @@
+# /etc/conf.d/libvirtd
+
+# You may want to add '--listen' to have libvirtd listen for tcp/ip connections
+# if you want to use libvirt for remote control
+
+# Please consult 'libvirtd --help' for more options
+
+#LIBVIRTD_OPTS="--listen"
+
+# Valid options:
+# * shutdown - Sends an ACPI shutdown (think when you tap the power button
+# on your machine and it begins a graceful shutdown). If your
+# VM ignores this, it will have the power yanked out from under
+# it in LIBVIRTD_KVM_SHUTDOWN_MAXWAIT seconds.
+# * managedsave - Performs a state save external to the VM. qemu-kvm will stop
+# stop the CPU and save off all state to a separate file. When
+# the machine is started again, it will resume like nothing ever
+# happened. This is guarenteed to always successfully stop your
+# machine and restart it. However it may take some time to finish.
+# * none - No attempts will be made to stop any VMs. If you are restarting your
+# machine the qemu-kvm process will be simply killed, which may result
+# in your VMs having disk corruption.
+LIBVIRTD_KVM_SHUTDOWN="managedsave"
+
+# Timeout in seconds until stopping libvirtd and "pulling the plug" on the
+# remaining VM's still in a running state
+#LIBVIRTD_KVM_SHUTDOWN_MAXWAIT="500"
diff --git a/main/libvirt/libvirt.initd b/main/libvirt/libvirt.initd
new file mode 100644
index 0000000000..d0b9d34a01
--- /dev/null
+++ b/main/libvirt/libvirt.initd
@@ -0,0 +1,87 @@
+#!/sbin/runscript
+
+opts="start stop status reload restart"
+
+depend() {
+ need net
+ after firewall
+}
+
+libvirtd_virsh() {
+ # Silence errors because virsh always throws an error about
+ # not finding the hypervisor version when connecting to libvirtd
+ LC_ALL=C virsh -c qemu:///system "$@" 2>/dev/null
+}
+
+libvirtd_dom_list() {
+ # Make sure that it wouldn't be confused if the domain name
+ # contains the word running.
+ libvirtd_virsh list | awk '$3 == "running" { print $1 }'
+}
+
+libvirtd_dom_count() {
+ # Make sure that it wouldn't be confused if the domain name
+ # contains the word running.
+ libvirtd_virsh list | awk 'BEGIN { count = 0 } \
+ $3 == "running" { count++ } \
+ END { print count }'
+}
+
+start() {
+ ebegin "Starting libvirtd"
+ start-stop-daemon --start \
+ --env KRB5_KTNAME=/etc/libvirt/krb5.tab \
+ --exec /usr/sbin/libvirtd -- -d ${LIBVIRTD_OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping libvirtd"
+ # try to shutdown all (KVM/Qemu) domains
+ DOM_COUNT="$(libvirtd_dom_count)"
+ if [ "${LIBVIRTD_KVM_SHUTDOWN}" != "none" ] \
+ && [ "${DOM_COUNT}" != "0" ] ; then
+
+ einfo " Shutting down domain(s):"
+ for DOM_ID in $(libvirtd_dom_list) ; do
+ NAME="$(libvirtd_virsh domname ${DOM_ID} | head -n 1)"
+ einfo " ${NAME}"
+ libvirtd_virsh ${LIBVIRTD_KVM_SHUTDOWN} ${DOM_ID} > /dev/null
+ done
+
+ if [ -n "${LIBVIRTD_KVM_SHUTDOWN_MAXWAIT}" ] ; then
+ COUNTER="${LIBVIRTD_KVM_SHUTDOWN_MAXWAIT}"
+ else
+ COUNTER=500
+ fi
+
+ if [ "${LIBVIRTD_KVM_SHUTDOWN}" = "shutdown" ]; then
+ einfo " Waiting ${COUNTER} seconds while domains shutdown ..."
+ DOM_COUNT="$(libvirtd_dom_count)"
+ while [ ${DOM_COUNT} -gt 0 ] && [ ${COUNTER} -gt 0 ] ; do
+ DOM_COUNT="$(libvirtd_dom_count)"
+ sleep 1
+ COUNTER=$((${COUNTER} - 1))
+ echo -n "."
+ done
+ fi
+
+ DOM_COUNT="$(libvirtd_dom_count)"
+ if [ "${DOM_COUNT}" != "0" ] ; then
+ eerror " !!! Some guests are still running, stopping anyways"
+ fi
+
+ fi
+ start-stop-daemon --stop --quiet --exec /usr/sbin/libvirtd --pidfile=/var/run/libvirtd.pid
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading libvirtd without shutting down your VMs"
+ start-stop-daemon --stop --quiet --exec /usr/sbin/libvirtd --pidfile=/var/run/libvirtd.pid
+ if [ $? -ne 0 ]; then
+ eend $?
+ fi
+ start-stop-daemon --start --quiet --exec /usr/sbin/libvirtd -- -d ${LIBVIRTD_OPTS}
+ eend $?
+}