[systemd-devel] Cannot get Shutdown Script to Run (Libvirt Virtual Machine Shutdown)

Alexander Groleau awgneo at xbetanet.com
Sun Sep 21 20:40:03 PDT 2014


Hello systemd users,

I have been trying desperately for weeks to get my simple shutdown script
for a Libvirt guest to run before libvirtd is shut down, without success.
Essentially, I need the libvirt-windows.sh script to run before the
libvirtd service is terminated (which occurs right after systemd-logind
outputs its reboot message). How can I get my script into this initial
section of daemon shutdowns, at the top?

Thanks so much. <3

-Alex

*Here is my shutdown systemd service configuration:*

[Unit]
Description=Stop Libvirt Windows Guest
Documentation=man:libvirtd(8)
Documentation=http://libvirt.org
Before=shutdown.target
DefaultDependencies=no

[Service]
ExecStart=/usr/bin/libvirt-windows.sh stop
Type=oneshot
StandardOutput=journal+console

[Install]
WantedBy=shutdown.target

*Here is my journalctl log:*

Sep 21 23:14:53 Xerxes9 systemd-logind[340]: System is rebooting.
*Sep 21 23:14:53 Xerxes9 libvirtd[605]: End of file while reading data:
Input/output error // HERE IS LIBVIRTD TERMINATING*
Sep 21 23:14:53 Xerxes9 systemd[1]: Failed to reset devices.list on
/system.slice: Invalid argument
Sep 21 23:14:53 Xerxes9 bluetoothd[458]: Terminating
Sep 21 23:14:53 Xerxes9 avahi-daemon[335]: Got SIGTERM, quitting.
Sep 21 23:14:53 Xerxes9 ntpd[606]: ntpd exiting on signal 15 (Terminated)
Sep 21 23:14:53 Xerxes9 avahi-daemon[335]: Leaving mDNS multicast group on
interface virbr0.IPv4 with address 192.168.122.1.
Sep 21 23:14:53 Xerxes9 ModemManager[338]: <info>  Caught signal, shutting
down...
Sep 21 23:14:53 Xerxes9 avahi-daemon[335]: Leaving mDNS multicast group on
interface br0.IPv4 with address 192.168.1.2.
Sep 21 23:14:53 Xerxes9 NetworkManager[334]: <info> ModemManager
disappeared from bus
Sep 21 23:14:53 Xerxes9 bluetoothd[458]: Stopping SDP server
Sep 21 23:14:53 Xerxes9 bluetoothd[458]: Exit
Sep 21 23:14:53 Xerxes9 ModemManager[338]: <info>  ModemManager is shut down
Sep 21 23:14:53 Xerxes9 avahi-daemon[335]: avahi-daemon 0.6.31 exiting.
Sep 21 23:14:53 Xerxes9 systemd[681]: Stopping Default.
Sep 21 23:14:53 Xerxes9 systemd[681]: Stopped target Default.
Sep 21 23:14:53 Xerxes9 systemd[681]: Stopping Basic System.
Sep 21 23:14:53 Xerxes9 systemd[681]: Stopped target Basic System.
Sep 21 23:14:53 Xerxes9 systemd[681]: Stopping Paths.
Sep 21 23:14:53 Xerxes9 systemd[681]: Stopped target Paths.
Sep 21 23:14:53 Xerxes9 systemd[681]: Stopping Timers.
Sep 21 23:14:53 Xerxes9 systemd[681]: Stopped target Timers.
Sep 21 23:14:53 Xerxes9 systemd[681]: Stopping Sockets.
Sep 21 23:14:53 Xerxes9 systemd[681]: Stopped target Sockets.
Sep 21 23:14:53 Xerxes9 systemd[681]: Starting Shutdown.
Sep 21 23:14:53 Xerxes9 systemd[681]: Reached target Shutdown.
Sep 21 23:14:53 Xerxes9 systemd[419]: Stopping Default.
Sep 21 23:14:53 Xerxes9 systemd[681]: Starting Exit the Session...
Sep 21 23:14:53 Xerxes9 systemd[419]: Stopped target Default.
Sep 21 23:14:53 Xerxes9 systemd[419]: Stopping Basic System.
Sep 21 23:14:53 Xerxes9 systemd[419]: Stopped target Basic System.
Sep 21 23:14:53 Xerxes9 systemd[419]: Stopping Paths.
Sep 21 23:14:53 Xerxes9 systemd[419]: Stopped target Paths.
Sep 21 23:14:53 Xerxes9 systemd[419]: Stopping Timers.
Sep 21 23:14:53 Xerxes9 systemd[419]: Stopped target Timers.
Sep 21 23:14:53 Xerxes9 systemd[419]: Stopping Sockets.
Sep 21 23:14:53 Xerxes9 systemd[419]: Stopped target Sockets.
Sep 21 23:14:53 Xerxes9 systemd[419]: Starting Shutdown.
Sep 21 23:14:53 Xerxes9 systemd[419]: Reached target Shutdown.
Sep 21 23:14:53 Xerxes9 systemd[419]: Starting Exit the Session...
Sep 21 23:14:53 Xerxes9 systemd[419]: Received SIGRTMIN+24 from PID 1202
(kill).
Sep 21 23:14:53 Xerxes9 systemd[681]: Received SIGRTMIN+24 from PID 1197
(kill).
Sep 21 23:14:53 Xerxes9 systemd[682]: pam_unix(systemd-user:session):
session closed for user awgneo
Sep 21 23:14:53 Xerxes9 systemd[420]: pam_unix(systemd-user:session):
session closed for user lightdm
Sep 21 23:14:53 Xerxes9 systemd[1]: pulseaudio.service: main process
exited, code=exited, status=1/FAILURE
Sep 21 23:14:53 Xerxes9 systemd[1]: Unit pulseaudio.service entered failed
state.
*Sep 21 23:14:53 Xerxes9 libvirt-windows.sh[1195]: error: failed to connect
to the hypervisor  // HERE IS MY SCRIPT FAILING*
*Sep 21 23:14:53 Xerxes9 libvirt-windows.sh[1195]: error: Failed to connect
socket to '/var/run/libvirt/libvirt-sock': No such file or directory*
...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20140921/bc1e4cf2/attachment-0001.html>


More information about the systemd-devel mailing list