File 01079727-libvirtd-systemd-shutdown-target.patch of Package libvirt.8364

commit 01079727fe29dfeafac751a07e564e0d6bb53389
Author: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Date:   Fri Oct 14 10:13:48 2016 +0300

    libvirtd: systemd: add special target for system shutdown
    
    It is already discussed in "[RFC] daemon: remove hardcode dep on libvirt-guests" [1].
    
    Mgmt can use means to save/restore domains on system shutdown/boot other than
    libvirt-guests.service. Thus we need to specify appropriate ordering dependency between
    libvirtd, domains and save/restore service. This patch takes approach suggested
    in RFC and introduces a systemd target, so that ordering can be built next way:
    
    libvirtd -> domain -> virt-guest-shutdown.target -> save-restore.service.
    
    This way domains are decoupled from specific shutdown service via intermediate
    target.
    
    [1] https://www.redhat.com/archives/libvir-list/2016-September/msg01353.html

Index: libvirt-2.0.0/daemon/Makefile.am
===================================================================
--- libvirt-2.0.0.orig/daemon/Makefile.am
+++ libvirt-2.0.0/daemon/Makefile.am
@@ -67,6 +67,7 @@ EXTRA_DIST =						\
 	libvirt.rules					\
 	libvirtd.sasl					\
 	libvirtd.service.in				\
+	virt-guest-shutdown.target		\
 	libvirtd.sysconf				\
 	libvirtd.sysctl					\
 	libvirtd.aug                                    \
@@ -456,8 +457,11 @@ install-init-systemd: install-sysconfig
 	$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
 	$(INSTALL_DATA) libvirtd.service \
 	  $(DESTDIR)$(SYSTEMD_UNIT_DIR)/libvirtd.service
+	$(INSTALL_DATA) virt-guest-shutdown.target \
+	  $(DESTDIR)$(SYSTEMD_UNIT_DIR)/virt-guest-shutdown.target
 
 uninstall-init-systemd: uninstall-sysconfig
+	rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/virt-guest-shutdown.target
 	rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/libvirtd.service
 	rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || :
 else ! LIBVIRT_INIT_SCRIPT_SYSTEMD
Index: libvirt-2.0.0/daemon/virt-guest-shutdown.target
===================================================================
--- /dev/null
+++ libvirt-2.0.0/daemon/virt-guest-shutdown.target
@@ -0,0 +1,3 @@
+[Unit]
+Description=Libvirt guests shutdown
+Documentation=http://libvirt.org
Index: libvirt-2.0.0/libvirt.spec.in
===================================================================
--- libvirt-2.0.0.orig/libvirt.spec.in
+++ libvirt-2.0.0/libvirt.spec.in
@@ -1543,6 +1543,7 @@ exit 0
 
 %if %{with_systemd}
 %{_unitdir}/libvirtd.service
+%{_unitdir}/virt-guest-shutdown.target
 %{_unitdir}/virtlogd.service
 %{_unitdir}/virtlogd.socket
 %{_unitdir}/virtlockd.service
Index: libvirt-2.0.0/src/util/virsystemd.c
===================================================================
--- libvirt-2.0.0.orig/src/util/virsystemd.c
+++ libvirt-2.0.0/src/util/virsystemd.c
@@ -366,7 +366,7 @@ int virSystemdCreateMachine(const char *
                               3,
                               "Slice", "s", slicename,
                               "After", "as", 1, "libvirtd.service",
-                              "Before", "as", 1, "libvirt-guests.service") < 0)
+                              "Before", "as", 1, "virt-guest-shutdown.target") < 0)
             goto cleanup;
 
         if (error.level == VIR_ERR_ERROR) {
@@ -407,7 +407,7 @@ int virSystemdCreateMachine(const char *
                               3,
                               "Slice", "s", slicename,
                               "After", "as", 1, "libvirtd.service",
-                              "Before", "as", 1, "libvirt-guests.service") < 0)
+                              "Before", "as", 1, "virt-guest-shutdown.target") < 0)
             goto cleanup;
     }
 
Index: libvirt-2.0.0/tools/libvirt-guests.service.in
===================================================================
--- libvirt-2.0.0.orig/tools/libvirt-guests.service.in
+++ libvirt-2.0.0/tools/libvirt-guests.service.in
@@ -1,6 +1,8 @@
 [Unit]
 Description=Suspend Active Libvirt Guests
+Requires=virt-guest-shutdown.target
 After=network.target libvirtd.service time-sync.target
+After=virt-guest-shutdown.target
 Documentation=man:libvirtd(8)
 Documentation=http://libvirt.org
openSUSE Build Service is sponsored by