From 51af5f0eb4cddbe6aa7953717873691d77aae9ff Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Wed, 10 Jul 2019 23:40:16 +0100 Subject: gentoo resync : 11.07.2019 --- .../libvirt-3.10.0-r2-fix_paths_for_apparmor.patch | 77 ------- .../files/libvirt-4.5.0-do_not_use_sysconf.patch | 216 ------------------- .../libvirt-5.0.0-fix-paths-for-apparmor.patch | 10 +- .../libvirt-5.2.0-fix-paths-for-apparmor.patch | 116 ++++++++++ app-emulation/libvirt/files/libvirt-guests.init-r4 | 237 +++++++++++++++++++++ app-emulation/libvirt/files/libvirtd.init-r16 | 34 --- app-emulation/libvirt/files/libvirtd.init-r18 | 33 +++ 7 files changed, 394 insertions(+), 329 deletions(-) delete mode 100644 app-emulation/libvirt/files/libvirt-3.10.0-r2-fix_paths_for_apparmor.patch delete mode 100644 app-emulation/libvirt/files/libvirt-4.5.0-do_not_use_sysconf.patch create mode 100644 app-emulation/libvirt/files/libvirt-5.2.0-fix-paths-for-apparmor.patch create mode 100644 app-emulation/libvirt/files/libvirt-guests.init-r4 delete mode 100644 app-emulation/libvirt/files/libvirtd.init-r16 create mode 100644 app-emulation/libvirt/files/libvirtd.init-r18 (limited to 'app-emulation/libvirt/files') diff --git a/app-emulation/libvirt/files/libvirt-3.10.0-r2-fix_paths_for_apparmor.patch b/app-emulation/libvirt/files/libvirt-3.10.0-r2-fix_paths_for_apparmor.patch deleted file mode 100644 index f1360ae4e4e9..000000000000 --- a/app-emulation/libvirt/files/libvirt-3.10.0-r2-fix_paths_for_apparmor.patch +++ /dev/null @@ -1,77 +0,0 @@ -diff --git a/examples/Makefile.am b/examples/Makefile.am -index ef2f79db3..d8cdb9b3f 100644 ---- a/examples/Makefile.am -+++ b/examples/Makefile.am -@@ -23,7 +23,7 @@ EXTRA_DIST = \ - apparmor/TEMPLATE.lxc \ - apparmor/libvirt-qemu \ - apparmor/libvirt-lxc \ -- apparmor/usr.lib.libvirt.virt-aa-helper \ -+ apparmor/usr.libexec.virt-aa-helper \ - apparmor/usr.sbin.libvirtd \ - lxcconvert/virt-lxc-convert \ - polkit/libvirt-acl.rules \ -@@ -70,7 +70,7 @@ admin_logging_SOURCES = admin/logging.c - if WITH_APPARMOR_PROFILES - apparmordir = $(sysconfdir)/apparmor.d/ - apparmor_DATA = \ -- apparmor/usr.lib.libvirt.virt-aa-helper \ -+ apparmor/usr.libexec.virt-aa-helper \ - apparmor/usr.sbin.libvirtd \ - $(NULL) - -diff --git a/examples/apparmor/libvirt-qemu b/examples/apparmor/libvirt-qemu -index d4fad85a1..0b22009e5 100644 ---- a/examples/apparmor/libvirt-qemu -+++ b/examples/apparmor/libvirt-qemu -@@ -86,6 +86,8 @@ - /usr/share/AAVMF/** r, - /usr/share/qemu-efi/** r, - /usr/share/slof/** r, -+ /usr/share/seavgabios/** r, -+ /usr/share/edk2-ovmf/** r, - - # access PKI infrastructure - /etc/pki/libvirt-vnc/** r, -diff --git a/examples/apparmor/usr.lib.libvirt.virt-aa-helper b/examples/apparmor/usr.libexec.virt-aa-helper -similarity index 92% -rename from examples/apparmor/usr.lib.libvirt.virt-aa-helper -rename to examples/apparmor/usr.libexec.virt-aa-helper -index bd6181d00..4086f140a 100644 ---- a/examples/apparmor/usr.lib.libvirt.virt-aa-helper -+++ b/examples/apparmor/usr.libexec.virt-aa-helper -@@ -1,7 +1,7 @@ - # Last Modified: Mon Apr 5 15:10:27 2010 - #include - --profile virt-aa-helper /usr/{lib,lib64}/libvirt/virt-aa-helper { -+profile virt-aa-helper /usr/libexec/virt-aa-helper { - #include - - # needed for searching directories -@@ -32,7 +32,7 @@ profile virt-aa-helper /usr/{lib,lib64}/libvirt/virt-aa-helper { - deny /dev/mapper/ r, - deny /dev/mapper/* r, - -- /usr/{lib,lib64}/libvirt/virt-aa-helper mr, -+ /usr/libexec/virt-aa-helper mr, - /{usr/,}sbin/apparmor_parser Ux, - - /etc/apparmor.d/libvirt/* r, -diff --git a/examples/apparmor/usr.sbin.libvirtd b/examples/apparmor/usr.sbin.libvirtd -index 8d61d154e..656a5595b 100644 ---- a/examples/apparmor/usr.sbin.libvirtd -+++ b/examples/apparmor/usr.sbin.libvirtd -@@ -84,8 +84,10 @@ - audit deny /sys/kernel/security/apparmor/.* rwxl, - /sys/kernel/security/apparmor/profiles r, - /usr/{lib,lib64}/libvirt/* PUxr, -- /usr/{lib,lib64}/libvirt/libvirt_parthelper ix, -- /usr/{lib,lib64}/libvirt/libvirt_iohelper ix, -+ /usr/libexec/virt-aa-helper PUxr, -+ /usr/libexec/libvirt_lxc PUxr, -+ /usr/libexec/libvirt_parthelper ix, -+ /usr/libexec/libvirt_iohelper ix, - /etc/libvirt/hooks/** rmix, - /etc/xen/scripts/** rmix, - diff --git a/app-emulation/libvirt/files/libvirt-4.5.0-do_not_use_sysconf.patch b/app-emulation/libvirt/files/libvirt-4.5.0-do_not_use_sysconf.patch deleted file mode 100644 index 3e430cba1d2f..000000000000 --- a/app-emulation/libvirt/files/libvirt-4.5.0-do_not_use_sysconf.patch +++ /dev/null @@ -1,216 +0,0 @@ -From a365e2d5b4af1ab2be743773412fe265579a9a0b Mon Sep 17 00:00:00 2001 -Message-Id: -From: Michal Privoznik -Date: Tue, 26 Jun 2018 06:51:06 +0200 -Subject: [PATCH] gentoo: do not use sysconf - -Signed-off-by: Michal Privoznik ---- - src/Makefile.am | 29 ++++++----------------------- - src/locking/virtlockd.service.in | 3 +-- - src/logging/virtlogd.service.in | 3 +-- - src/remote/libvirtd.service.in | 3 +-- - tools/Makefile.am | 17 ++++------------- - tools/libvirt-guests.service.in | 2 +- - tools/libvirt-guests.sysconf | 7 +++++++ - 7 files changed, 21 insertions(+), 43 deletions(-) - -diff --git a/src/Makefile.am b/src/Makefile.am -index db8c8ebd1a..63d7a9ca46 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -757,23 +757,6 @@ endif WITH_SETUID_RPC_CLIENT - - EXTRA_DIST += $(SYSCONF_FILES) - --install-sysconfig: -- $(MKDIR_P) $(DESTDIR)$(sysconfdir)/sysconfig -- for f in $(SYSCONF_FILES:%.sysconf=%) ; \ -- do \ -- tgt=`basename $$f`; \ -- $(INSTALL_DATA) $(srcdir)/$$f.sysconf \ -- $(DESTDIR)$(sysconfdir)/sysconfig/$$tgt; \ -- done -- --uninstall-sysconfig: -- for f in $(SYSCONF_FILES:%.sysconf=%) ; \ -- do \ -- tgt=`basename $$f`; \ -- rm -f $(DESTDIR)$(sysconfdir)/sysconfig/$$tgt; \ -- done -- rmdir $(DESTDIR)$(sysconfdir)/sysconfig || : -- - SYSVINIT_FILES_IN += \ - locking/virtlockd.init.in \ - $(NULL) -@@ -814,14 +797,14 @@ uninstall-logrotate: - endif ! WITH_LIBVIRTD - - if LIBVIRT_INIT_SCRIPT_RED_HAT --install-init:: $(SYSVINIT_FILES) install-sysconfig -+install-init:: $(SYSVINIT_FILES) - $(MKDIR_P) $(DESTDIR)$(sysconfdir)/rc.d/init.d - for f in $(SYSVINIT_FILES:%.init=%) ; \ - do \ - $(INSTALL_SCRIPT) $$f.init $(DESTDIR)$(sysconfdir)/rc.d/init.d/$$f; \ - done - --uninstall-init:: uninstall-sysconfig -+uninstall-init:: - rm -f $(SYSVINIT_FILES:%.init=$(DESTDIR)$(sysconfdir)/rc.d/init.d/%) - rmdir $(DESTDIR)$(sysconfdir)/rc.d/init.d || : - -@@ -859,14 +842,14 @@ SYSTEMD_UNIT_FILES = $(notdir $(SYSTEMD_UNIT_FILES_IN:%.in=%)) - BUILT_SOURCES += $(SYSTEMD_UNIT_FILES) - DISTCLEANFILES += $(SYSTEMD_UNIT_FILES) - --install-systemd: $(SYSTEMD_UNIT_FILES) install-sysconfig -+install-systemd: $(SYSTEMD_UNIT_FILES) - $(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR) - for f in $(SYSTEMD_UNIT_FILES); \ - do \ - $(INSTALL_DATA) $$f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/ ; \ - done - --uninstall-systemd: uninstall-sysconfig -+uninstall-systemd: - rm -f $(SYSTEMD_UNIT_FILES:%=$(DESTDIR)$(SYSTEMD_UNIT_DIR)/%) - rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || : - else ! LIBVIRT_INIT_SCRIPT_SYSTEMD -@@ -884,7 +867,7 @@ EXTRA_DIST += $(UPSTART_FILES) - if WITH_LIBVIRTD - if LIBVIRT_INIT_SCRIPT_UPSTART - --install-upstart: install-sysconfig -+install-upstart: - $(MKDIR_P) $(DESTDIR)$(sysconfdir)/event.d - for f in $(UPSTART_FILES:%.upstart=%); \ - do \ -@@ -893,7 +876,7 @@ install-upstart: install-sysconfig - $(DESTDIR)$(sysconfdir)/event.d/$$tgt ; \ - done - --uninstall-upstart: uninstall-sysconfig -+uninstall-upstart: - for f in $(UPSTART_FILES:%.upstart=%); \ - do \ - tgt=`basename $$f` ; \ -diff --git a/src/locking/virtlockd.service.in b/src/locking/virtlockd.service.in -index 3c9d587032..2449b201d9 100644 ---- a/src/locking/virtlockd.service.in -+++ b/src/locking/virtlockd.service.in -@@ -7,8 +7,7 @@ Documentation=man:virtlockd(8) - Documentation=https://libvirt.org - - [Service] --EnvironmentFile=-/etc/sysconfig/virtlockd --ExecStart=@sbindir@/virtlockd $VIRTLOCKD_ARGS -+ExecStart=@sbindir@/virtlockd - ExecReload=/bin/kill -USR1 $MAINPID - # Loosing the locks is a really bad thing that will - # cause the machine to be fenced (rebooted), so make -diff --git a/src/logging/virtlogd.service.in b/src/logging/virtlogd.service.in -index 3d9ae36150..43736191d5 100644 ---- a/src/logging/virtlogd.service.in -+++ b/src/logging/virtlogd.service.in -@@ -7,8 +7,7 @@ Documentation=man:virtlogd(8) - Documentation=https://libvirt.org - - [Service] --EnvironmentFile=-/etc/sysconfig/virtlogd --ExecStart=@sbindir@/virtlogd $VIRTLOGD_ARGS -+ExecStart=@sbindir@/virtlogd - ExecReload=/bin/kill -USR1 $MAINPID - # Loosing the logs is a really bad thing that will - # cause the machine to be fenced (rebooted), so make -diff --git a/src/remote/libvirtd.service.in b/src/remote/libvirtd.service.in -index 7f689e08a8..239beeced9 100644 ---- a/src/remote/libvirtd.service.in -+++ b/src/remote/libvirtd.service.in -@@ -22,8 +22,7 @@ Documentation=https://libvirt.org - - [Service] - Type=notify --EnvironmentFile=-/etc/sysconfig/libvirtd --ExecStart=@sbindir@/libvirtd $LIBVIRTD_ARGS -+ExecStart=@sbindir@/libvirtd - ExecReload=/bin/kill -HUP $MAINPID - KillMode=process - Restart=on-failure -diff --git a/tools/Makefile.am b/tools/Makefile.am -index 1452d984a0..cef08741cb 100644 ---- a/tools/Makefile.am -+++ b/tools/Makefile.am -@@ -336,15 +336,6 @@ install-data-local: install-init install-systemd install-nss \ - uninstall-local: uninstall-init uninstall-systemd uninstall-nss \ - uninstall-bash-completion - --install-sysconfig: -- $(MKDIR_P) $(DESTDIR)$(sysconfdir)/sysconfig -- $(INSTALL_DATA) $(srcdir)/libvirt-guests.sysconf \ -- $(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests -- --uninstall-sysconfig: -- rm -f $(DESTDIR)$(sysconfdir)/sysconfig/libvirt-guests -- rmdir $(DESTDIR)$(sysconfdir)/sysconfig ||: -- - EXTRA_DIST += libvirt-guests.sh.in libvirt-guests.init.in - - install-initscript: libvirt-guests.init -@@ -359,8 +350,8 @@ uninstall-initscript: - - if LIBVIRT_INIT_SCRIPT_RED_HAT - BUILT_SOURCES += libvirt-guests.init --install-init: install-sysconfig install-initscript --uninstall-init: uninstall-sysconfig uninstall-initscript -+install-init: install-initscript -+uninstall-init: uninstall-initscript - else ! LIBVIRT_INIT_SCRIPT_RED_HAT - install-init: - uninstall-init: -@@ -391,12 +382,12 @@ EXTRA_DIST += libvirt-guests.service.in - SYSTEMD_UNIT_DIR = $(prefix)/lib/systemd/system - - if LIBVIRT_INIT_SCRIPT_SYSTEMD --install-systemd: libvirt-guests.service install-sysconfig libvirt-guests.sh -+install-systemd: libvirt-guests.service libvirt-guests.sh - $(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR) - $(INSTALL_DATA) libvirt-guests.service \ - $(DESTDIR)$(SYSTEMD_UNIT_DIR)/libvirt-guests.service - --uninstall-systemd: uninstall-sysconfig -+uninstall-systemd: - rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/libvirt-guests.service - rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) ||: - -diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in -index 491ca62138..f0f417bffb 100644 ---- a/tools/libvirt-guests.service.in -+++ b/tools/libvirt-guests.service.in -@@ -10,7 +10,7 @@ Documentation=man:libvirtd(8) - Documentation=https://libvirt.org - - [Service] --EnvironmentFile=-/etc/sysconfig/libvirt-guests -+EnvironmentFile=-/etc/libvirt/libvirt-guests.conf - # Hack just call traditional service until we factor - # out the code - ExecStart=@libexecdir@/libvirt-guests.sh start -diff --git a/tools/libvirt-guests.sysconf b/tools/libvirt-guests.sysconf -index 669b046507..45b0b9ea46 100644 ---- a/tools/libvirt-guests.sysconf -+++ b/tools/libvirt-guests.sysconf -@@ -1,3 +1,10 @@ -+# -+# Warning: This configuration file is only sourced by the systemd -+# libvirt-guests.service unit. The coresponding openrc facility is in -+# /etc/init.d/libvirtd and /etc/conf.d/libvirtd -+# -+ -+ - # URIs to check for running guests - # example: URIS='default xen:///system vbox+tcp://host/system lxc:///system' - #URIS=default --- -2.16.4 - diff --git a/app-emulation/libvirt/files/libvirt-5.0.0-fix-paths-for-apparmor.patch b/app-emulation/libvirt/files/libvirt-5.0.0-fix-paths-for-apparmor.patch index ca9f952a8234..866c6357b6e4 100644 --- a/app-emulation/libvirt/files/libvirt-5.0.0-fix-paths-for-apparmor.patch +++ b/app-emulation/libvirt/files/libvirt-5.0.0-fix-paths-for-apparmor.patch @@ -79,7 +79,7 @@ index de9436872c..99ab4ea527 100644 #include # needed for searching directories -@@ -33,7 +33,7 @@ profile virt-aa-helper /usr/{lib,lib64}/libvirt/virt-aa-helper { +@@ -36,7 +36,7 @@ deny /dev/mapper/ r, deny /dev/mapper/* r, @@ -88,6 +88,13 @@ index de9436872c..99ab4ea527 100644 /{usr/,}sbin/apparmor_parser Ux, /etc/apparmor.d/libvirt/* r, +@@ -66,5 +66,5 @@ + /**.[iI][sS][oO] r, + /**/disk{,.*} r, + +- #include ++ #include + } diff --git a/src/security/apparmor/usr.sbin.libvirtd b/src/security/apparmor/usr.sbin.libvirtd index f0ffc53008..8a402bd6ec 100644 --- a/src/security/apparmor/usr.sbin.libvirtd @@ -107,4 +114,3 @@ index f0ffc53008..8a402bd6ec 100644 -- 2.19.2 - diff --git a/app-emulation/libvirt/files/libvirt-5.2.0-fix-paths-for-apparmor.patch b/app-emulation/libvirt/files/libvirt-5.2.0-fix-paths-for-apparmor.patch new file mode 100644 index 000000000000..866c6357b6e4 --- /dev/null +++ b/app-emulation/libvirt/files/libvirt-5.2.0-fix-paths-for-apparmor.patch @@ -0,0 +1,116 @@ +From 563706143779166624812b3faf498d869f5dd383 Mon Sep 17 00:00:00 2001 +Message-Id: <563706143779166624812b3faf498d869f5dd383.1547196492.git.mprivozn@redhat.com> +From: Michal Privoznik +Date: Fri, 11 Jan 2019 09:41:06 +0100 +Subject: [PATCH] gentoo: fix paths for apparmor + +Signed-off-by: Michal Privoznik +--- + src/security/Makefile.inc.am | 10 +++++----- + src/security/apparmor/libvirt-qemu | 2 ++ + ...bvirt.virt-aa-helper => usr.libexec.virt-aa-helper} | 4 ++-- + src/security/apparmor/usr.sbin.libvirtd | 6 ++++-- + 4 files changed, 13 insertions(+), 9 deletions(-) + rename src/security/apparmor/{usr.lib.libvirt.virt-aa-helper => usr.libexec.virt-aa-helper} (93%) + +diff --git a/src/security/Makefile.inc.am b/src/security/Makefile.inc.am +index b24cdfd083..ae8e979b84 100644 +--- a/src/security/Makefile.inc.am ++++ b/src/security/Makefile.inc.am +@@ -36,7 +36,7 @@ EXTRA_DIST += \ + security/apparmor/TEMPLATE.lxc \ + security/apparmor/libvirt-qemu \ + security/apparmor/libvirt-lxc \ +- security/apparmor/usr.lib.libvirt.virt-aa-helper \ ++ security/apparmor/usr.libexec.virt-aa-helper \ + security/apparmor/usr.sbin.libvirtd \ + $(NULL) + +@@ -90,7 +90,7 @@ endif WITH_SECDRIVER_APPARMOR + if WITH_APPARMOR_PROFILES + apparmordir = $(sysconfdir)/apparmor.d/ + apparmor_DATA = \ +- security/apparmor/usr.lib.libvirt.virt-aa-helper \ ++ security/apparmor/usr.libexec.virt-aa-helper \ + security/apparmor/usr.sbin.libvirtd \ + $(NULL) + +@@ -110,11 +110,11 @@ APPARMOR_LOCAL_DIR = "$(DESTDIR)$(apparmordir)/local" + install-apparmor-local: + $(MKDIR_P) "$(APPARMOR_LOCAL_DIR)" + echo "# Site-specific additions and overrides for \ +- 'usr.lib.libvirt.virt-aa-helper'" \ +- >"$(APPARMOR_LOCAL_DIR)/usr.lib.libvirt.virt-aa-helper" ++ 'usr.libexec.virt-aa-helper'" \ ++ >"$(APPARMOR_LOCAL_DIR)/usr.libexec.virt-aa-helper" + + uninstall-apparmor-local: +- rm -f "$(APPARMOR_LOCAL_DIR)/usr.lib.libvirt.virt-aa-helper" ++ rm -f "$(APPARMOR_LOCAL_DIR)/usr.libexec.virt-aa-helper" + rmdir "$(APPARMOR_LOCAL_DIR)" || : + + INSTALL_DATA_LOCAL += install-apparmor-local +diff --git a/src/security/apparmor/libvirt-qemu b/src/security/apparmor/libvirt-qemu +index eaa5167525..9be50bbbe0 100644 +--- a/src/security/apparmor/libvirt-qemu ++++ b/src/security/apparmor/libvirt-qemu +@@ -87,6 +87,8 @@ + /usr/share/AAVMF/** r, + /usr/share/qemu-efi/** r, + /usr/share/slof/** r, ++ /usr/share/seavgabios/** r, ++ /usr/share/edk2-ovmf/** r, + + # pki for libvirt-vnc and libvirt-spice (LP: #901272, #1690140) + /etc/pki/CA/ r, +diff --git a/src/security/apparmor/usr.lib.libvirt.virt-aa-helper b/src/security/apparmor/usr.libexec.virt-aa-helper +similarity index 93% +rename from src/security/apparmor/usr.lib.libvirt.virt-aa-helper +rename to src/security/apparmor/usr.libexec.virt-aa-helper +index de9436872c..99ab4ea527 100644 +--- a/src/security/apparmor/usr.lib.libvirt.virt-aa-helper ++++ b/src/security/apparmor/usr.libexec.virt-aa-helper +@@ -1,7 +1,7 @@ + # Last Modified: Mon Apr 5 15:10:27 2010 + #include + +-profile virt-aa-helper /usr/{lib,lib64}/libvirt/virt-aa-helper { ++profile virt-aa-helper /usr/libexec/virt-aa-helper { + #include + + # needed for searching directories +@@ -36,7 +36,7 @@ + deny /dev/mapper/ r, + deny /dev/mapper/* r, + +- /usr/{lib,lib64}/libvirt/virt-aa-helper mr, ++ /usr/libexec/virt-aa-helper mr, + /{usr/,}sbin/apparmor_parser Ux, + + /etc/apparmor.d/libvirt/* r, +@@ -66,5 +66,5 @@ + /**.[iI][sS][oO] r, + /**/disk{,.*} r, + +- #include ++ #include + } +diff --git a/src/security/apparmor/usr.sbin.libvirtd b/src/security/apparmor/usr.sbin.libvirtd +index f0ffc53008..8a402bd6ec 100644 +--- a/src/security/apparmor/usr.sbin.libvirtd ++++ b/src/security/apparmor/usr.sbin.libvirtd +@@ -98,8 +98,10 @@ + audit deny /sys/kernel/security/apparmor/.* rwxl, + /sys/kernel/security/apparmor/profiles r, + /usr/{lib,lib64}/libvirt/* PUxr, +- /usr/{lib,lib64}/libvirt/libvirt_parthelper ix, +- /usr/{lib,lib64}/libvirt/libvirt_iohelper ix, ++ /usr/libexec/virt-aa-helper PUxr, ++ /usr/libexec/libvirt_lxc PUxr, ++ /usr/libexec/libvirt_parthelper ix, ++ /usr/libexec/libvirt_iohelper ix, + /etc/libvirt/hooks/** rmix, + /etc/xen/scripts/** rmix, + +-- +2.19.2 diff --git a/app-emulation/libvirt/files/libvirt-guests.init-r4 b/app-emulation/libvirt/files/libvirt-guests.init-r4 new file mode 100644 index 000000000000..b29f04c24a54 --- /dev/null +++ b/app-emulation/libvirt/files/libvirt-guests.init-r4 @@ -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/app-emulation/libvirt/files/libvirtd.init-r16 b/app-emulation/libvirt/files/libvirtd.init-r16 deleted file mode 100644 index 2a3fb52696ab..000000000000 --- a/app-emulation/libvirt/files/libvirtd.init-r16 +++ /dev/null @@ -1,34 +0,0 @@ -#!/sbin/openrc-run -# Copyright 1999-2019 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="-d ${LIBVIRTD_OPTS}" -start_stop_daemon_args="--env KRB5_KTNAME=/etc/libvirt/krb5.tab" -pidfile="/run/libvirtd.pid" -retry="${LIBVIRTD_TERMTIMEOUT}" - -depend() { - need virtlogd - use dbus virtlockd - after ntp-client ntpd nfs nfsmount portmap rpc.statd iptables ip6tables ebtables corosync sanlock cgconfig xenconsoled - USE_FLAG_FIREWALLD - USE_FLAG_AVAHI - USE_FLAG_ISCSI - USE_FLAG_RBD -} - -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 - checkpath --directory /etc/libvirt/qemu || return 1 - checkpath --directory /etc/libvirt/storage || return 1 -} diff --git a/app-emulation/libvirt/files/libvirtd.init-r18 b/app-emulation/libvirt/files/libvirtd.init-r18 new file mode 100644 index 000000000000..5e9efc83e2f9 --- /dev/null +++ b/app-emulation/libvirt/files/libvirtd.init-r18 @@ -0,0 +1,33 @@ +#!/sbin/openrc-run +# Copyright 1999-2019 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="-d ${LIBVIRTD_OPTS}" +start_stop_daemon_args="--env KRB5_KTNAME=/etc/libvirt/krb5.tab" +pidfile="/run/libvirtd.pid" +retry="${LIBVIRTD_TERMTIMEOUT}" + +depend() { + need virtlogd + use ceph dbus iscsid virtlockd + after cgconfig corosync ebtables iptables ip6tables nfs nfsmount ntp-client ntpdportmap rpc.statd sanlock xenconsoled + USE_FLAG_FIREWALLD +} + +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 +} -- cgit v1.2.3