Re: [systemd-devel] Cannot get Shutdown Script to Run (Libvirt Virtual Machine Shutdown)
Thanks for the reply :) The libvirt-guests.service was the very first thing I had tried. It, however, did absolutely nothing and I believe it to be broken in arch linux. I have given up on trying to get a shutdown/reboot script to run for now. On Tue, Sep 23, 2014 at 5:44 AM, Daniel P. Berrange wrote: > On Sun, Sep 21, 2014 at 11:40:03PM -0400, Alexander Groleau wrote: > > 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? > > Any reason you've created your own shutdown script instead of using the > libvirt-guests.service script that libvirt includes ? To get the ordering > right, we have a number of rules: > > - libvirtd.service contains "Before=libvirt-guests.service" > - libvirt-guests.service contains "After=libvirtd.service" > - The guest scope unit contain "After=libvirtd.service" and > "Before=libvirt-guests.service" > > It was the two rules aginst the .scope units that we found to be the key > part to making shutdown work, whereby guests get stopped gracefully before > the libvirtd daemon is stopped. > > The .scope units do not have any file on disk, they are generated on the > fly as libvirt talks to systemd-machined, so you've no way to alter them > to work with your custom shutdown script. Thus if you are not using the > standard libvirt-guests.service, then you should at least use the name > "libvirt-guests.service" for your own custom service. > > Regards, > Daniel > -- > |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ > :| > |: http://libvirt.org -o- http://virt-manager.org > :| > |: http://autobuild.org -o- http://search.cpan.org/~danberr/ > :| > |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc > :| > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Cannot get Shutdown Script to Run (Libvirt Virtual Machine Shutdown)
Thanks Tobias for all of the responses. Yes, I am using plain, unaliased jounalctl on Arch Linux with systemd 216. In fact, I see absolutely no "Starting" "Stopping" service messages outside of standard triggers. Is something wrong with my distro? :/ Was the logging changed in 216? -Alex On Mon, Sep 22, 2014 at 8:37 PM, Tobias Geerinckx-Rice < tobias.geerinckx.r...@gmail.com> wrote: > On 23 September 2014 01:10, Alexander Groleau wrote: > > Hmm, > > > > This is a fresh installation of arch linux with systemd. What else might > be > > terminating my daemons or how might I be able to figure that out? > > A cursory search linked that suspicious EOF error message to libvirtd > crashing. If that's what's happening here, libvirtd could already be > dead while systemd is correctly handling ExecStop=. Does this error > message appear when manually stopping or restarting just > libvirtd.service? > > There may be other hints somewhere in the logs. I just don't > understand why yours don't contain or show those "Stopping..." > messages that mine are full of [1]. You are using plain, unaliased > journalctl, right? > > Also, focus on getting "systemd {stop,start,restart} libvirt.service" > to work first, without all the extra complexity (and potential races, > and time) of a full shut-down. > > Regards, > > T G-R > > [1] Messages which are being fiercely attacked elsewhere on this list. > Hurry! ;-) > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Cannot get Shutdown Script to Run (Libvirt Virtual Machine Shutdown)
Hmm, This is a fresh installation of arch linux with systemd. What else might be terminating my daemons or how might I be able to figure that out? Thanks, Alex On Mon, Sep 22, 2014 at 10:52 AM, Tobias Geerinckx-Rice < tobias.geerinckx.r...@gmail.com> wrote: > On 22 September 2014 15:36, Mantas Mikulėnas wrote: > > >> [Nonsense] > > > > Neither Requires nor BindsTo imply any ordering though. So that might in > > fact *create* race conditions, if both A and B start at once, but A > already > > expects B to be available. > > [Indeed. That whole paragraph was hastily re-written and doesn't even > make sense as-is: manually ordering is what Before= and After= *do*. > They don't explicitly, uhm... imply dependencies, which is what I > failed at saying.] > > On Mon, Sep 22, 2014 at 7:40 AM, Alexander Groleau > wrote: > > > 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 > > My systems helpfully spam the life out of me when shutting down > services. I'd see a "Stopping " line between these, if > libvirtd were being stopped cleanly by systemd. Your logs don't > mention _any_ services, though. > > Regards, > > T G-R > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Cannot get Shutdown Script to Run (Libvirt Virtual Machine Shutdown)
I have tried the following script as well during my adventures with no success: [Unit] Description=Start/Stop Libvirt Windows Guest Documentation=man:libvirtd(8) Documentation=http://libvirt.org After=libvirtd.service [Service] ExecStart=/usr/bin/libvirt-windows.sh start ExecStop=/usr/bin/libvirt-windows.sh stop RemainAfterExit=yes Type=oneshot StandardOutput=journal+console [Install] WantedBy=multi-user.target This works for boot (my sh script is run right after libvirtd is started); however, the libvirtd daemon, started by libvirtd.service, is always terminated well before my sh is run on shutdown/reboot. The reverse order is not happening as it logically should. I will post the journal for this script shortly. So, still no luck :/ Thanks, Alex On Mon, Sep 22, 2014 at 1:49 AM, Andrei Borzenkov wrote: > On Mon, Sep 22, 2014 at 7:40 AM, Alexander Groleau > wrote: > > 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 > > > > Why? Do you have special reasons to avoid default dependencies? What > are these reasons? I suggest removing it - it is always better to > start with default configuration before customizing it. > > Also you do not specify any dependency to other services, so your > service and libvirtd service are stopped concurrently. To be stopped > before some other service it needs to be started *after* this service. > I.e. > > After=your-virtd.service > > > [Service] > > ExecStart=/usr/bin/libvirt-windows.sh stop > > That's usually does not work, at least when using default > dependencies. During shutdown services are stopped. And you cannot > tell it to wait for starting one service before stopping another > service (I wish it could). So try > > RemainAfterExit=true > ExecStop=/usr/bin/libvirt-windows.sh stop > > Not sure if ExecStart is mandatory; if yes, just use /usr/bin/true. > > > Type=oneshot > > StandardOutput=journal+console > > > > [Install] > > WantedBy=shutdown.target > > > > No, you must start it on on boot for above stopping on shutdown to work, > so use > > WantedBy=default.target (or multi-user.target or graphical.target > depending on your configuration) > > > 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]: 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]: 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]: 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 Tim
Re: [systemd-devel] Cannot get Shutdown Script to Run (Libvirt Virtual Machine Shutdown)
I have tried the traditional ExecStart, ExecStop all in one script with no luck (with RemainAfterExit=yes, etc.). I just can't seem to get it to run in this daemon SIGTERM section :(. I hate how on my system, libvirtd is literally the first thing to go down, making this quite tricky. What might I try to use for the WantedBy instead? I thought DefaultDependencies=no removed the standard conflict with shutdown.target. Thanks for your response. Any other suggestions? :) On Mon, Sep 22, 2014 at 1:31 AM, Tobias Geerinckx-Rice < tobias.geerinckx.r...@gmail.com> wrote: > On 22 September 2014 05:40, Alexander Groleau wrote: > > Hello systemd users, > > Oh good. That's me! > > > 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? > > "Weeks" makes one hesitant to ask: have you tried just popping a > > ExecStop=/usr/bin/libvirt-windows.sh stop > > snippet into /etc/systemd/system/.d/? > > > [Install] > > WantedBy=shutdown.target > > Either way, shutdown.target "conflicts with all system services" [1], > and is probably not what you want. > > Good luck, > > T G-R > > [1] > http://www.freedesktop.org/software/systemd/man/bootup.html#System%20Manager%20Shutdown > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] Cannot get Shutdown Script to Run (Libvirt Virtual Machine Shutdown)
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]: 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]: 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]: 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* ... ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel