mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
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
This commit is contained in:
parent
29dc9a52d7
commit
01079727fe
@ -67,6 +67,7 @@ EXTRA_DIST = \
|
|||||||
libvirt.rules \
|
libvirt.rules \
|
||||||
libvirtd.sasl \
|
libvirtd.sasl \
|
||||||
libvirtd.service.in \
|
libvirtd.service.in \
|
||||||
|
virt-guest-shutdown.target \
|
||||||
libvirtd.sysconf \
|
libvirtd.sysconf \
|
||||||
libvirtd.sysctl \
|
libvirtd.sysctl \
|
||||||
libvirtd.aug \
|
libvirtd.aug \
|
||||||
@ -456,8 +457,11 @@ install-init-systemd: install-sysconfig libvirtd.service
|
|||||||
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
|
$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
|
||||||
$(INSTALL_DATA) libvirtd.service \
|
$(INSTALL_DATA) libvirtd.service \
|
||||||
$(DESTDIR)$(SYSTEMD_UNIT_DIR)/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
|
uninstall-init-systemd: uninstall-sysconfig
|
||||||
|
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/virt-guest-shutdown.target
|
||||||
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/libvirtd.service
|
rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/libvirtd.service
|
||||||
rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || :
|
rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || :
|
||||||
else ! LIBVIRT_INIT_SCRIPT_SYSTEMD
|
else ! LIBVIRT_INIT_SCRIPT_SYSTEMD
|
||||||
|
3
daemon/virt-guest-shutdown.target
Normal file
3
daemon/virt-guest-shutdown.target
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Libvirt guests shutdown
|
||||||
|
Documentation=http://libvirt.org
|
@ -1589,6 +1589,7 @@ exit 0
|
|||||||
|
|
||||||
%if %{with_systemd}
|
%if %{with_systemd}
|
||||||
%{_unitdir}/libvirtd.service
|
%{_unitdir}/libvirtd.service
|
||||||
|
%{_unitdir}/virt-guest-shutdown.target
|
||||||
%{_unitdir}/virtlogd.service
|
%{_unitdir}/virtlogd.service
|
||||||
%{_unitdir}/virtlogd.socket
|
%{_unitdir}/virtlogd.socket
|
||||||
%{_unitdir}/virtlockd.service
|
%{_unitdir}/virtlockd.service
|
||||||
|
@ -370,7 +370,7 @@ int virSystemdCreateMachine(const char *name,
|
|||||||
3,
|
3,
|
||||||
"Slice", "s", slicename,
|
"Slice", "s", slicename,
|
||||||
"After", "as", 1, "libvirtd.service",
|
"After", "as", 1, "libvirtd.service",
|
||||||
"Before", "as", 1, "libvirt-guests.service") < 0)
|
"Before", "as", 1, "virt-guest-shutdown.target") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (error.level == VIR_ERR_ERROR) {
|
if (error.level == VIR_ERR_ERROR) {
|
||||||
@ -411,7 +411,7 @@ int virSystemdCreateMachine(const char *name,
|
|||||||
3,
|
3,
|
||||||
"Slice", "s", slicename,
|
"Slice", "s", slicename,
|
||||||
"After", "as", 1, "libvirtd.service",
|
"After", "as", 1, "libvirtd.service",
|
||||||
"Before", "as", 1, "libvirt-guests.service") < 0)
|
"Before", "as", 1, "virt-guest-shutdown.target") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Suspend/Resume Running libvirt Guests
|
Description=Suspend/Resume Running libvirt Guests
|
||||||
Wants=libvirtd.service
|
Wants=libvirtd.service
|
||||||
|
Requires=virt-guest-shutdown.target
|
||||||
After=network.target
|
After=network.target
|
||||||
After=time-sync.target
|
After=time-sync.target
|
||||||
After=libvirtd.service
|
After=libvirtd.service
|
||||||
|
After=virt-guest-shutdown.target
|
||||||
Documentation=man:libvirtd(8)
|
Documentation=man:libvirtd(8)
|
||||||
Documentation=http://libvirt.org
|
Documentation=http://libvirt.org
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user