summaryrefslogtreecommitdiff
path: root/repo/libvirt
diff options
context:
space:
mode:
Diffstat (limited to 'repo/libvirt')
-rw-r--r--repo/libvirt/libvirt-6.0.0-fix_paths_in_libvirt-guests_sh.patch35
-rw-r--r--repo/libvirt/libvirt-guests.confd68
-rw-r--r--repo/libvirt/libvirt-guests.initd237
-rw-r--r--repo/libvirt/libvirt.confd20
-rw-r--r--repo/libvirt/libvirt.initd40
-rwxr-xr-xrepo/libvirt/libvirt.post-install5
-rw-r--r--repo/libvirt/libvirt.xibuild54
-rw-r--r--repo/libvirt/musl-fix-includes.patch12
-rw-r--r--repo/libvirt/stderr-fix.patch13
-rw-r--r--repo/libvirt/virtlockd.initd24
-rw-r--r--repo/libvirt/virtlogd.initd24
11 files changed, 532 insertions, 0 deletions
diff --git a/repo/libvirt/libvirt-6.0.0-fix_paths_in_libvirt-guests_sh.patch b/repo/libvirt/libvirt-6.0.0-fix_paths_in_libvirt-guests_sh.patch
new file mode 100644
index 0000000..bf7a328
--- /dev/null
+++ b/repo/libvirt/libvirt-6.0.0-fix_paths_in_libvirt-guests_sh.patch
@@ -0,0 +1,35 @@
+From e97700d867ffa949c97f8a635a76b9ce510e806f Mon Sep 17 00:00:00 2001
+Message-Id: <e97700d867ffa949c97f8a635a76b9ce510e806f.1580460243.git.mprivozn@redhat.com>
+In-Reply-To: <5965f20fe0275b324c9b84ab7f48dd7db0494495.1580460243.git.mprivozn@redhat.com>
+References: <5965f20fe0275b324c9b84ab7f48dd7db0494495.1580460243.git.mprivozn@redhat.com>
+From: Michal Privoznik <mprivozn@redhat.com>
+Date: Fri, 31 Jan 2020 09:42:14 +0100
+Subject: [PATCH 2/3] Fix paths in libvirt-guests.sh.in
+
+Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
+---
+ tools/libvirt-guests.sh.in | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
+index a881f6266e..79d38b3e9a 100644
+--- a/tools/libvirt-guests.sh.in
++++ b/tools/libvirt-guests.sh.in
+@@ -39,11 +39,11 @@ START_DELAY=0
+ BYPASS_CACHE=0
+ SYNC_TIME=0
+
+-test -f "$sysconfdir"/sysconfig/libvirt-guests &&
+- . "$sysconfdir"/sysconfig/libvirt-guests
++test -f "$sysconfdir"/libvirt/libvirt-guests.conf &&
++ . "$sysconfdir"/libvirt/libvirt-guests.conf
+
+ LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests
+-VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests
++VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/libvirt-guests
+
+ RETVAL=0
+
+--
+2.24.1
+
diff --git a/repo/libvirt/libvirt-guests.confd b/repo/libvirt/libvirt-guests.confd
new file mode 100644
index 0000000..ed2ce58
--- /dev/null
+++ b/repo/libvirt/libvirt-guests.confd
@@ -0,0 +1,68 @@
+# /etc/conf.d/libvirtd
+
+# LIBVIRT_URIS
+# space separated list of libvirt URIs to communicate with to start/stop guests
+# Valid values are anything that can be passed to 'virsh connect'
+
+#LIBVIRT_URIS="qemu:///system"
+
+
+# LIBVIRT_SHUTDOWN
+# Valid options:
+# * managedsave - Performs a state save external to the VM (for hypervisors
+# supporting this operation). qemu-kvm will 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.
+#
+# * shutdown - Sends an ACPI shutdown (think of this as a request to
+# your guest to shutdown). There is no way to distinguish
+# between guests that are ignoring the shutdown request or
+# are stuck or are taking a long time to shutdown. We will
+# wait LIBVIRT_MAXWAIT seconds before yanking the power
+# out.
+#
+# * destroy - Immediately stop all running guests. Use with caution as
+# this can leave the guest in a corrupted state and might
+# lead to data loss.
+#
+
+#LIBVIRT_SHUTDOWN="managedsave"
+
+
+# LIBVIRT_MAXWAIT
+# Timeout in seconds until stopping a guest and "pulling the plug" on the
+# guest
+# Valid values are any integer over 0
+
+#LIBVIRT_MAXWAIT="500"
+
+
+# LIBVIRT_START
+# If this value is set to 'no', then guests and networks that were shutdown
+# by this script when it was stopped will not be started when it is started
+# back up.
+# Valid values are yes or no
+
+#LIBVIRT_START="yes"
+
+
+# LIBVIRT_IGNORE_AUTOSTART
+# If the VM is marked for autostart in its XML configuration then we won't
+# save its start when the init script is stopped. The result is that when
+# the init script starts back up, no attempt will be made to start the VM or
+# confirm it is started.
+# Valid values are yes or no
+
+#LIBVIRT_IGNORE_AUTOSTART="no"
+
+
+# LIBVIRT_NET_SHUTDOWN
+# If libvirtd created networks for you (e.g. NATed networks) then this init
+# script will shut them down for you if this is set to 'yes'. Otherwise,
+# the networks will be left running. For this option to be useful you must
+# have enabled the 'virt-network' USE flag and have had libvirt create a
+# NATed network for you. Valid values: 'yes' or 'no'
+
+#LIBVIRT_NET_SHUTDOWN="yes"
diff --git a/repo/libvirt/libvirt-guests.initd b/repo/libvirt/libvirt-guests.initd
new file mode 100644
index 0000000..b29f04c
--- /dev/null
+++ b/repo/libvirt/libvirt-guests.initd
@@ -0,0 +1,237 @@
+#!/sbin/openrc-run
+
+description="Virtual Machine Management (libvirt) Guests"
+
+depend() {
+ use libvirtd
+}
+
+# set the default to QEMU
+[ -z "${LIBVIRT_URIS}" ] && LIBVIRT_URIS="qemu:///system"
+
+# default to suspending the VM via managedsave
+case "${LIBVIRT_SHUTDOWN}" in
+ managedsave|shutdown|destroy) ;;
+ *) LIBVIRT_SHUTDOWN="managedsave" ;;
+esac
+
+# default to 500 seconds
+[ -z ${LIBVIRT_MAXWAIT} ] && LIBVIRT_MAXWAIT=500
+
+gueststatefile="/var/lib/libvirt/libvirt-guests.state"
+netstatefile="/var/lib/libvirt/libvirt-net.state"
+
+do_virsh() {
+ local hvuri=$1
+ shift
+
+ # if unset, default to qemu
+ [ -z ${hvuri} ] && hvuri="qemu:///system"
+ # if only qemu was supplied then correct the value
+ [ "xqemu" = x${hvuri} ] && hvuri="qemu:///system"
+
+ # Silence errors because virsh always throws an error about
+ # not finding the hypervisor version when connecting to libvirtd
+ # lastly strip the blank line at the end
+ LC_ALL=C virsh -c ${hvuri} "$@" 2>/dev/null | head -n -1
+}
+
+libvirtd_dom_list() {
+ # Only work with domains by their UUIDs
+ local hvuri=$1
+ shift
+
+ # The grep is to remove dom0 for xen domains. Otherwise we never hit 0
+ do_virsh "${hvuri}" list --uuid $@ | grep -v 00000000-0000-0000-0000-000000000000
+}
+
+libvirtd_dom_count() {
+ local hvuri=$1
+ shift
+
+ libvirtd_dom_list "${hvuri}" $@ | wc -l
+}
+
+libvirtd_net_list() {
+ # Only work with networks by their UUIDs
+ local hvuri=$1
+ shift
+
+ do_virsh "${hvuri}" net-list --uuid $@
+}
+
+libvirtd_net_count() {
+ local hvuri=$1
+ shift
+
+ libvirtd_net_list "${hvuri}" $@ | wc -l
+}
+
+libvirtd_dom_stop() {
+ # stops all persistent or transient domains for a given URI
+ # $1 - uri
+ # $2 - persisent/transient
+
+ local uri=$1
+ local persist=$2
+ local shutdown_type=${LIBVIRT_SHUTDOWN}
+ local counter=${LIBVIRT_MAXWAIT}
+ local dom_name=
+ local dom_as=
+ local dom_ids=
+ local uuid=
+ local dom_count=
+
+ [ "${persist}" = "--transient" ] && shutdown_type="shutdown"
+ [ -n "${counter}" ] || counter=500
+
+ einfo " Shutting down domain(s) ..."
+
+ # grab all persistent or transient domains running
+ dom_ids=$(libvirtd_dom_list ${uri} ${persist})
+
+ for uuid in ${dom_ids}; do
+ # Get the name
+ dom_name=$(do_virsh ${uri} domname ${uuid})
+ einfo " ${dom_name}"
+ # Get autostart state
+ dom_as=$(do_virsh ${uri} dominfo ${uuid} | \
+ awk '$1 == "Autostart:" { print $2 }')
+
+ if [ "${persist}" = "--persistent" ]; then
+ # Save our running state only if LIBVIRT_IGNORE_AUTOSTART != yes
+ if [ "x${LIBVIRT_IGNORE_AUTOSTART}" = "xyes" ] && \
+ [ ${dom_as} = "enabled" ]; then
+ :
+ else
+ echo "${uri} ${uuid}" >> ${gueststatefile}
+ fi
+
+ fi
+
+ # Now let's stop it
+ do_virsh "${uri}" ${shutdown_type} ${uuid} > /dev/null
+
+ done
+
+ dom_count="$(libvirtd_dom_count ${uri} ${persist})"
+ while [ ${dom_count} -gt 0 ] && [ ${counter} -gt 0 ] ; do
+ dom_count="$(libvirtd_dom_count ${uri} ${persist})"
+ sleep 1
+ if [ "${shutdown_type}" = "shutdown" ]; then
+ counter=$((${counter} - 1))
+ fi
+ printf "."
+ done
+
+ if [ "${shutdown_type}" = "shutdown" ]; then
+ # grab all domains still running
+ dom_ids=$(libvirtd_dom_list ${uri} ${persist})
+ for uuid in ${dom_ids}; do
+ dom_name=$(do_virsh ${uri} domname ${uuid})
+ eerror " ${dom_name} forcibly stopped"
+ do_virsh "${uri}" destroy ${uuid} > /dev/null
+ done
+ fi
+}
+
+libvirtd_net_stop() {
+ # stops all persistent or transient domains for a given URI
+ # $1 - uri
+ # $2 - persisent/transient
+
+ local uri=$1
+ local persist=$2
+ local uuid=
+ local net_name=
+
+ if [ "${LIBVIRT_NET_SHUTDOWN}" != "no" ]; then
+
+ einfo " Shutting down network(s):"
+ for uuid in $(libvirtd_net_list ${uri} ${persist}); do
+ net_name=$(do_virsh ${uri} net-name ${uuid})
+ einfo " ${net_name}"
+
+ if [ "${persist}" = "--persistent" ]; then
+ # Save our running state
+ echo "${uri} ${uuid}" >> ${netstatefile}
+
+ fi
+
+ # Actually stop the network
+ do_virsh qemu net-destroy ${uuid} > /dev/null
+ done
+
+ fi
+}
+
+start() {
+ local uri=
+ local uuid=
+ local name=
+
+ for uri in ${LIBVIRT_URIS}; do
+ do_virsh "${uri}" connect
+ if [ $? -ne 0 ]; then
+ eerror "Failed to connect to '${uri}'. Domains may not start."
+ fi
+ done
+
+ [ ! -e "${netstatefile}" ] && touch "${netstatefile}"
+ [ ! -e "${gueststatefile}" ] && touch "${gueststatefile}"
+
+ # if the user didn't want to start any guests up then respect their wish
+ [ "x${LIBVIRT_START}" = "xno" ] && return 0
+
+ # start networks
+ ebegin "Starting libvirt networks"
+ while read -r uri uuid
+ do
+ # ignore trash
+ [ -z "${uri}" ] || [ -z "${uuid}" ] && continue
+
+ name=$(do_virsh "${uri}" net-name ${uuid})
+ einfo " ${name}"
+ do_virsh "${uri}" net-start ${uuid} > /dev/null
+ done <"${netstatefile}"
+ eend 0
+
+ # start domains
+ ebegin "Starting libvirt domains"
+ while read -r uri uuid
+ do
+ # ignore trash
+ [ -z "${uri}" ] || [ -z "${uuid}" ] && continue
+
+ name=$(do_virsh "${uri}" domname ${uuid})
+ einfo " ${name}"
+ do_virsh "${uri}" start ${uuid} > /dev/null
+ do_virsh "${uri}" domtime --sync ${uuid} > /dev/null
+ done <"${gueststatefile}"
+ eend 0
+}
+
+stop() {
+ local counter=
+ local dom_name=
+ local net_name=
+ local dom_ids=
+ local uuid=
+ local dom_count=
+
+ rm -f "${gueststatefile}"
+ [ $? -ne 0 ] && eerror "Unable to save domain state"
+ rm -f "${netstatefile}"
+ [ $? -ne 0 ] && eerror "Unable to save net state"
+
+ for uri in ${LIBVIRT_URIS}; do
+ einfo "Stopping libvirt domains and networks for ${uri}"
+
+ libvirtd_dom_stop "${uri}" "--persistent"
+ libvirtd_dom_stop "${uri}" "--transient"
+ libvirtd_net_stop "${uri}" "--persistent"
+ libvirtd_net_stop "${uri}" "--transient"
+
+ einfo "Done stopping domains and networks for ${uri}"
+ done
+}
diff --git a/repo/libvirt/libvirt.confd b/repo/libvirt/libvirt.confd
new file mode 100644
index 0000000..de5af86
--- /dev/null
+++ b/repo/libvirt/libvirt.confd
@@ -0,0 +1,20 @@
+# /etc/conf.d/libvirtd
+
+# /etc/conf.d/libvirtd
+
+# Startup dependency
+# libvirtd typically requires all networks to be up and settled which
+# is what rc_need="net" provides. However if you only use specific networks
+# for libvirtd, you may override this. Or if you only use libvirtd locally.
+rc_need="net"
+
+# The termination timeout (start-stop-daemon parameter "retry") ensures
+# that the service will be terminated within a given time (25 + 5 seconds
+# per default) when you are stopping the service.
+#LIBVIRTD_TERMTIMEOUT="TERM/25/KILL/5"
+
+# LIBVIRTD_OPTS
+# 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"
diff --git a/repo/libvirt/libvirt.initd b/repo/libvirt/libvirt.initd
new file mode 100644
index 0000000..3d93b6b
--- /dev/null
+++ b/repo/libvirt/libvirt.initd
@@ -0,0 +1,40 @@
+#!/sbin/openrc-run
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+description="Virtual Machine Management daemon (libvirt)"
+
+LIBVIRTD_OPTS=${LIBVIRTD_OPTS:-"${LIBVIRTD_OPTS}"}
+LIBVIRTD_TIMEOUT=${LIBVIRTD_TERMTIMEOUT:-"TERM/25/KILL/5"}
+
+command="/usr/sbin/libvirtd"
+command_args="${LIBVIRTD_OPTS}"
+start_stop_daemon_args="-b --env KRB5_KTNAME=/etc/libvirt/krb5.tab"
+pidfile="/run/libvirtd.pid"
+retry="${LIBVIRTD_TERMTIMEOUT}"
+
+extra_started_commands="reload"
+
+depend() {
+ need virtlogd
+ use ceph dbus iscsid virtlockd
+ after cgconfig corosync ebtables iptables ip6tables nfs nfsmount ntp-client ntpdportmap rpc.statd sanlock xenconsoled
+}
+
+start_pre() {
+ # Test configuration directories in /etc/libvirt/ to be either not
+ # present or a directory, i.e. not a regular file, bug #532892
+
+ checkpath --directory /etc/libvirt/lxc || return 1
+ checkpath --directory /etc/libvirt/nwfilter || return 1
+ [ -L /etc/libvirt/qemu ] ||
+ checkpath --directory /etc/libvirt/qemu || return 1
+ [ -L /etc/libvirt/storage ] ||
+ checkpath --directory /etc/libvirt/storage || return 1
+}
+
+reload() {
+ ebegin "Reloading $RC_SVCNAME"
+ start-stop-daemon --signal HUP --exec "$command" --pidfile "$pidfile"
+ eend $?
+}
diff --git a/repo/libvirt/libvirt.post-install b/repo/libvirt/libvirt.post-install
new file mode 100755
index 0000000..a747701
--- /dev/null
+++ b/repo/libvirt/libvirt.post-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+addgroup -S libvirt 2>/dev/null
+
+exit 0
diff --git a/repo/libvirt/libvirt.xibuild b/repo/libvirt/libvirt.xibuild
new file mode 100644
index 0000000..849deab
--- /dev/null
+++ b/repo/libvirt/libvirt.xibuild
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+NAME="libvirt"
+DESC="A virtualization API for several hypervisor and container systems"
+
+MAKEDEPS="augeas libsasl device-mapper e2fsprogs gnutls libcap-ng libgpg-error netcf libnl libxml2 libxslt libtasn1 lvm2 lxc libgcrypt parted perl pkg-config eudev zlib yajl libpcap curl libpciaccess polkit readline linux-headers jansson libtirpc perl-xml-xpath fuse util-linux bash-completion bridge-utils dmidecode dnsmasq iptables pm-utils netcat rpcsvc-proto python-docutils meson ninja"
+
+PKG_VER=8.2.0
+SOURCE="https://libvirt.org/sources/libvirt-$PKG_VER.tar.xz"
+
+ADDITIONAL="
+libvirt-6.0.0-fix_paths_in_libvirt-guests_sh.patch
+libvirt-guests.confd
+libvirt-guests.initd
+libvirt.confd
+libvirt.initd
+libvirt.post-install
+musl-fix-includes.patch
+stderr-fix.patch
+virtlockd.initd
+virtlogd.initd
+"
+
+build() {
+ export ac_cv_path_QEMU_BRIDGE_HELPER="/usr/lib/qemu/qemu-bridge-helper"
+ meson --prefix=/usr \
+ --libexec=/usr/lib/libvirt \
+ . output
+
+ meson configure output
+ meson compile ${JOBS:+-j ${JOBS}} -C output
+}
+
+check() {
+ meson test --no-rebuild -v -C output
+}
+
+package() {
+ DESTDIR="$PKG_DEST" ninja -C output install
+ install -Dm755 $BUILD_ROOT/libvirt.initd $PKG_DEST/etc/init.d/libvirtd
+ install -Dm644 $BUILD_ROOT/libvirt.confd $PKG_DEST/etc/conf.d/libvirtd
+ install -Dm755 $BUILD_ROOT/libvirt-guests.initd $PKG_DEST/etc/init.d/libvirt-guests
+ install -Dm644 $BUILD_ROOT/libvirt-guests.confd $PKG_DEST/etc/conf.d/libvirt-guests
+
+ install -Dm755 $BUILD_ROOT/virtlogd.initd $PKG_DEST/etc/init.d/virtlogd
+ install -Dm755 $BUILD_ROOT/virtlockd.initd $PKG_DEST/etc/init.d/virtlockd
+
+ install -d "$PKG_DEST"/lib/modules-load.d
+ echo "tun" > "$PKG_DEST"/lib/modules-load.d/libvirt.conf
+
+ rm -rf "$PKG_DEST"/etc/sysconfig
+ rm -rf "$PKG_DEST"/usr/lib/charset.alias
+ rmdir -p "$PKG_DEST"/usr/lib 2>/dev/null || true
+}
diff --git a/repo/libvirt/musl-fix-includes.patch b/repo/libvirt/musl-fix-includes.patch
new file mode 100644
index 0000000..6b7cee9
--- /dev/null
+++ b/repo/libvirt/musl-fix-includes.patch
@@ -0,0 +1,12 @@
+diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
+index 0837443..0954e11 100644
+--- a/src/storage/storage_backend_fs.c
++++ b/src/storage/storage_backend_fs.c
+@@ -26,6 +26,7 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
++#include <paths.h>
+
+ #include "virerror.h"
+ #include "storage_backend_fs.h"
diff --git a/repo/libvirt/stderr-fix.patch b/repo/libvirt/stderr-fix.patch
new file mode 100644
index 0000000..9d26721
--- /dev/null
+++ b/repo/libvirt/stderr-fix.patch
@@ -0,0 +1,13 @@
+--- a/src/qemu/qemu_process.c 2019-03-07 18:52:23.722271821 +0100
++++ b/src/qemu/qemu_process.c 2019-03-07 18:53:53.129064501 +0100
+@@ -92,6 +92,10 @@
+
+ VIR_LOG_INIT("qemu.qemu_process");
+
++#ifdef stderr
++# undef stderr
++#endif
++
+ /**
+ * qemuProcessRemoveDomainStatus
+ *
diff --git a/repo/libvirt/virtlockd.initd b/repo/libvirt/virtlockd.initd
new file mode 100644
index 0000000..792ce6b
--- /dev/null
+++ b/repo/libvirt/virtlockd.initd
@@ -0,0 +1,24 @@
+#!/sbin/openrc-run
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+description="libvirt virtual machine lock manager"
+command="/usr/sbin/virtlockd"
+start_stop_daemon_args="-b"
+pidfile="/run/virtlockd.pid"
+
+extra_started_commands="reload"
+description_reload="re-exec the daemon, while maintaining locks and clients"
+
+
+depend() {
+ after ntp-client ntpd nfs nfsmount corosync
+}
+
+reload() {
+ ebegin "re-exec() virtlockd"
+
+ start-stop-daemon --signal SIGUSR1 \
+ --exec "${command}" --pidfile "${pidfile}"
+}
+
diff --git a/repo/libvirt/virtlogd.initd b/repo/libvirt/virtlogd.initd
new file mode 100644
index 0000000..0d0ad67
--- /dev/null
+++ b/repo/libvirt/virtlogd.initd
@@ -0,0 +1,24 @@
+#!/sbin/openrc-run
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+description="libvirt virtual machine logging manager"
+command="/usr/sbin/virtlogd"
+start_stop_daemon_args="-b"
+pidfile="/run/virtlogd.pid"
+
+extra_started_commands="reload"
+description_reload="re-exec the daemon, while maintaining open connections"
+
+
+depend() {
+ after ntp-client ntpd nfs nfsmount corosync
+}
+
+reload() {
+ ebegin "re-exec() virtlogd"
+
+ start-stop-daemon --signal SIGUSR1 \
+ --exec "${command}" --pidfile "${pidfile}"
+}
+