Re: [systemd-devel] Cannot get Shutdown Script to Run (Libvirt Virtual Machine Shutdown)
On 10/10/2014 09:20 AM, Lennart Poettering wrote: rule that if two units are ordered against each other, and one is started and one is stopped the stop will always be executed first, the start second, regardless if the actual ordering is After= or Before= Yeah sure but there is a different between units that have been run ( thus started and or stopped either at boot up, by specific custom target and or manually ) and those that have never been run ( which for example is the case with all the units that are tied to the shutdown.target ) If I add shutdown-test.service to the After= line of the httpd.service it still does not get executed in the right order at shutdown And If I add Before=httpd.service to the shutdown-test.unit it still is not execuded in the right order at shutdown. From my perception the logic and thus the brokeness in the design seems to be due the fact that the ordering ( After=, Before= ) of units which have never been run are not being taken into account when atleast the shutdown.target is being run. ( Have not tested this with custom targets to see if those are affected as well ) . Now, this means unless you want to run your code only after some other service shut down, everything is good. But if you want your code to run before some other unit is shut down, then you cannot express this with a service that is started at shutdown. ... Thus the recommended way to implement services that are execute right at the appropriate place in the shutdown order is to make it a service that is a NOP at start, and only contains ExecStop=. To me this is a workaround which should not be needed or necessary and is due to what I consider the brokeness of the design ( or the implementation of that design ). It's not particularly pretty, but not that bad either. And better than the other options we saw... You do realize that at this point in time and given how far we have come, you and those we which I assume consist of individuals of yourself dubbed systemd cabal which you deliberately with those words elevated those individual above everyone else in the community by creating the notion of an A team ( as opposed to simply name those individuals without setting an label on them ), will need to start doing better job of communicating thus for example sharing design discussions that that team has etc. with the community ( which consist of ever growing members from wide variety of distribution and embedded space ) so everyone can participate in those discussion as well as being aware and thus informed of what has been discussed and why those things have to be ( designed ) that way as well as considered the ideas of that self dubbed systemd cabal is not absolute and other ideas from the community might lead to a better implementation or design or different approach even something that cabal did not think of. Just bear the above in mind. JBG ___ 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)
On Fri, 10.10.14 11:55, Jóhann B. Guðmundsson (johan...@gmail.com) wrote: On 10/10/2014 09:20 AM, Lennart Poettering wrote: rule that if two units are ordered against each other, and one is started and one is stopped the stop will always be executed first, the start second, regardless if the actual ordering is After= or Before= Yeah sure but there is a different between units that have been run ( thus started and or stopped either at boot up, by specific custom target and or manually ) and those that have never been run ( which for example is the case with all the units that are tied to the shutdown.target ) If I add shutdown-test.service to the After= line of the httpd.service it still does not get executed in the right order at shutdown And If I add Before=httpd.service to the shutdown-test.unit it still is not execuded in the right order at shutdown. Not following here. Ordering deps and requirement deps are fully orthogonal in systemd. If you want to pull something in, it needs to be pulled in explicitly, just the ordering won't have any effect on its own. And this is good that way, because otherwise enabling/disabling would have no effect on this. From my perception the logic and thus the brokeness in the design seems to be due the fact that the ordering ( After=, Before= ) of units which have never been run are not being taken into account when atleast the shutdown.target is being run. ( Have not tested this with custom targets to see if those are affected as well ) . Now, this means unless you want to run your code only after some other service shut down, everything is good. But if you want your code to run before some other unit is shut down, then you cannot express this with a service that is started at shutdown. ... Thus the recommended way to implement services that are execute right at the appropriate place in the shutdown order is to make it a service that is a NOP at start, and only contains ExecStop=. To me this is a workaround which should not be needed or necessary and is due to what I consider the brokeness of the design ( or the implementation of that design ). Well, so, there's more to this scheme. Before we install a transaction in our execution queue we check it for ordering cycles and if we find one we refuse the transaction. This some relatively simple graph theory. It's easy to do as long as we keep the ordering relation between start and stop jobs very very simple. It's not that easy though if we need to look for cycles not only between start/start, stop/stop, start+stop/stop+start but also when introducing two different kinds of ordering between start and stop of two units. When Kay and I discussed this graph theory problem back when we wrote the code we came to the conclusion it was much simpler to simply implement the current rules and require that services that shall just execute at shutdown, but not at startup should do so by including an empty ExecStart= but a populated ExecStop=. I am pretty sure the status quo makes a ton of sense if you look at the maths behind it. Lennart -- Lennart Poettering, Red Hat ___ 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)
On 10/09/2014 11:35 PM, Zbigniew Jędrzejewski-Szmek wrote: On Thu, Oct 09, 2014 at 01:41:24AM +0200, Lennart Poettering wrote: The ExecStart=/bin/true we just add because current systemd versions refuse to run service units that have no ExecStart= set. It is on the TODO list to allow services also when they have no ExecStart= but with an ExecStop=, but this has not been implemented yet. Isn't this it: commit 96fb8242cc1ef6b0e28f6c86a4f57950095dd7f1 Author: Lennart Poettering lenn...@poettering.net Date: Thu Aug 21 18:50:42 2014 +0200 service: allow services of Type=oneshot that specify no ExecStart= commands This is useful for services that simply want to run something on shutdown, but not at bootup. They should only set ExecStop= but leave ExecStart= unset. Confused, Zbyszek Yeah this was a weird commit and arguably this should be reverted unless Lennart explain why we need this in the first place. Users should be able to install their units into the shutdown target and use existing ( After/Before ) ordering and an simply ExecStart to start unit(s) and have them executed in expected order during the shutdown sequence. If they cannot something bigger is broken and need fixing. JBG ___ 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)
On Thu, 09.10.14 20:28, Jóhann B. Guðmundsson (johan...@gmail.com) wrote: On 10/09/2014 02:26 PM, Lennart Poettering wrote: On Thu, 09.10.14 12:14, Jóhann B. Guðmundsson (johan...@gmail.com) wrote: On 10/08/2014 11:41 PM, Lennart Poettering wrote: TODO list to allow services also when they have no ExecStart= but with an ExecStop=, but this has not been implemented yet. What's the usecase for this behaviour? Precisely cases like the one described earlier in this thread: when you want to run something only at shutdown, properly ordered against other units that are also shut down. To me that already works just fine. [Unit] Description=My Shutdown Test Before=shutdown.target DefaultDependencies=no [Service] Type=oneshot ExecStart=/bin/systemd-cat -t SHUTDOWN /bin/echo Systemd shutdown test-2 [Install] WantedBy=shutdown.target It's not that easy. Note that in systemd we have the rule that if two units are ordered against each other, and one is started and one is stopped the stop will always be executed first, the start second, regardless if the actual ordering is After= or Before=. Now, this means unless you want to run your code only after some other service shut down, everything is good. But if you want your code to run before some other unit is shut down, then you cannot express this with a service that is started at shutdown. Thus the recommended way to implement services that are execute right at the appropriate place in the shutdown order is to make it a service that is a NOP at start, and only contains ExecStop=. It's not particularly pretty, but not that bad either. And better than the other options we saw... Lennart -- Lennart Poettering, Red Hat ___ 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)
On Fri, 10.10.14 01:35, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote: On Thu, Oct 09, 2014 at 01:41:24AM +0200, Lennart Poettering wrote: The ExecStart=/bin/true we just add because current systemd versions refuse to run service units that have no ExecStart= set. It is on the TODO list to allow services also when they have no ExecStart= but with an ExecStop=, but this has not been implemented yet. Isn't this it: commit 96fb8242cc1ef6b0e28f6c86a4f57950095dd7f1 Author: Lennart Poettering lenn...@poettering.net Date: Thu Aug 21 18:50:42 2014 +0200 service: allow services of Type=oneshot that specify no ExecStart= commands This is useful for services that simply want to run something on shutdown, but not at bootup. They should only set ExecStop= but leave ExecStart= unset. Oh! Indeed! I am getting old! I start getting forgetful! Lennart -- Lennart Poettering, Red Hat ___ 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)
On 10/08/2014 11:41 PM, Lennart Poettering wrote: TODO list to allow services also when they have no ExecStart= but with an ExecStop=, but this has not been implemented yet. What's the usecase for this behaviour? JBG ___ 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)
On Thu, 09.10.14 12:14, Jóhann B. Guðmundsson (johan...@gmail.com) wrote: On 10/08/2014 11:41 PM, Lennart Poettering wrote: TODO list to allow services also when they have no ExecStart= but with an ExecStop=, but this has not been implemented yet. What's the usecase for this behaviour? Precisely cases like the one described earlier in this thread: when you want to run something only at shutdown, properly ordered against other units that are also shut down. Lennart -- Lennart Poettering, Red Hat ___ 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)
On 10/09/2014 02:26 PM, Lennart Poettering wrote: On Thu, 09.10.14 12:14, Jóhann B. Guðmundsson (johan...@gmail.com) wrote: On 10/08/2014 11:41 PM, Lennart Poettering wrote: TODO list to allow services also when they have no ExecStart= but with an ExecStop=, but this has not been implemented yet. What's the usecase for this behaviour? Precisely cases like the one described earlier in this thread: when you want to run something only at shutdown, properly ordered against other units that are also shut down. To me that already works just fine. [Unit] Description=My Shutdown Test Before=shutdown.target DefaultDependencies=no [Service] Type=oneshot ExecStart=/bin/systemd-cat -t SHUTDOWN /bin/echo Systemd shutdown test-2 [Install] WantedBy=shutdown.target journalctl SYSLOG_IDENTIFIER=SHUTDOWN -- Logs begin at Thu 2013-10-24 11:47:22 GMT, end at Thu 2014-10-09 20:00:17 GMT. -- Oct 09 19:57:51 localhost.localdomain SHUTDOWN[1968]: Systemd shutdown test-1 -- Reboot -- Oct 09 19:59:19 localhost.localdomain SHUTDOWN[1898]: Systemd shutdown test-2 ( the former log is from when I initially tested the unit before reboot ) If I wanted to order it after an service I added After=httpd.service [Unit] Description=My Shutdown Test Before=shutdown.target After=httpd.service DefaultDependencies=no [Service] Type=oneshot ExecStart=/bin/systemd-cat -t SHUTDOWN /bin/echo Systemd shutdown test-3 [Install] WantedBy=shutdown.target In my test I added this line to httpd.service ExecStop=/bin/systemd-cat -t SHUTDOWN /bin/echo Systemd shutdown test-3 Apache Stopped Then I rebooted and as you can see things seem to work perfectly as in the test case was stopped after apache had stopped make the shutdown order correct # journalctl SYSLOG_IDENTIFIER=SHUTDOWN -- Reboot -- Oct 09 20:16:37 localhost.localdomain SHUTDOWN[1972]: Systemd shutdown test-3 Apache Stopped Oct 09 20:16:38 localhost.localdomain SHUTDOWN[1985]: Systemd shutdown test-3 What I dont understand what's the usecase for somekind of ExecStop= modfications, why do we need to do that? JBG ___ 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)
On 10/09/2014 08:28 PM, Jóhann B. Guðmundsson wrote: What I dont understand what's the usecase for somekind of ExecStop= modfications, why do we need to do that? Note that the Before= in the test script is failing to pass which indicates something is borked in the ordering I added the Before= line in shutdown-test.service [Unit] Description=My Shutdown Test Before=httpd.service shutdown.target DefaultDependencies=no [Service] Type=oneshot ExecStart=/bin/systemd-cat -t SHUTDOWN /bin/echo Systemd shutdown test-4 [Install] WantedBy=shutdown.target And added this line to the httpd.service ExecStop=/bin/systemd-cat -t SHUTDOWN /bin/echo Systemd shutdown test-4 after shutdown-test.service Rebooted and as you can see the shutdown-test.service is being run *after* the httpd.service not before... Oct 09 21:11:15 localhost.localdomain SHUTDOWN[2098]: Systemd shutdown test-4 after shutdown-test.service Oct 09 21:11:16 localhost.localdomain SHUTDOWN[2108]: Systemd shutdown test-4 Expected result, shutdown-test.service being run before httpd.service as in... Oct 09 21:11:15 localhost.localdomain SHUTDOWN[2108]: Systemd shutdown test-4 Oct 09 21:11:16 localhost.localdomain SHUTDOWN[2098]: Systemd shutdown test-4 after shutdown-test.service ( systemd-208-22.fc20.x86_64 which probably means the dracut and alsa units that are tied to the shutdown.target aren't working as expected ) Perhaps that bug is the reason you think we need somekind of ExecStop= modfications? JBG ___ 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)
On Thu, Oct 09, 2014 at 01:41:24AM +0200, Lennart Poettering wrote: The ExecStart=/bin/true we just add because current systemd versions refuse to run service units that have no ExecStart= set. It is on the TODO list to allow services also when they have no ExecStart= but with an ExecStop=, but this has not been implemented yet. Isn't this it: commit 96fb8242cc1ef6b0e28f6c86a4f57950095dd7f1 Author: Lennart Poettering lenn...@poettering.net Date: Thu Aug 21 18:50:42 2014 +0200 service: allow services of Type=oneshot that specify no ExecStart= commands This is useful for services that simply want to run something on shutdown, but not at bootup. They should only set ExecStop= but leave ExecStart= unset. Confused, Zbyszek ___ 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)
On Sun, 21.09.14 23:40, Alexander Groleau (awg...@xbetanet.com) 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? If you want to something to have something executed before another unit is stopped, then write a service that has: [Unit] After=otherservice.service [Service] Type=oneshot RemainAfterExit=true ExecStart=/bin/true ExecStop=/your/code [Install] WantedBy=otherservice.service Explanation: The ExecStart=/bin/true we just add because current systemd versions refuse to run service units that have no ExecStart= set. It is on the TODO list to allow services also when they have no ExecStart= but with an ExecStop=, but this has not been implemented yet. The ExecStop= is where you place your code. Type=oneshot + RemainAfterExit=true make sure the service gets started properly and then stays around without any processes. The After= orders the unit after the unit you want to be stopped before. Note that in systemd the shutdown order is always the inverse of the startup order. Hence, if you order your new unit with After= after the unit you want to be stopped before, then this has the desired effect. Finally, WantedBy= makes sure you can enable your new unit with systemctl enable, and the right thing will happen. Lennart -- Lennart Poettering, Red Hat ___ 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 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 berra...@redhat.com 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)
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)
On 22 September 2014 07:57, Alexander Groleau awg...@xbetanet.com wrote: 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 Manually ordering services with Before=/After= is usually a mistake. Try using Requires= or BindTo= instead, and let systemd handle ordering for you. [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. I can't see any other obvious problems. This should just work, unless something other than systemd is killing your libvirtd. 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)
On Sep 22, 2014 4:07 PM, Tobias Geerinckx-Rice tobias.geerinckx.r...@gmail.com wrote: On 22 September 2014 07:57, Alexander Groleau awg...@xbetanet.com wrote: 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 Manually ordering services with Before=/After= is usually a mistake. Try using Requires= or BindTo= instead, and let systemd handle ordering for you. 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. [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. I can't see any other obvious problems. This should just work, unless something other than systemd is killing your libvirtd. Regards, T G-R ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- Mantas Mikulėnas ___ 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)
On 22 September 2014 15:36, Mantas Mikulėnas graw...@gmail.com 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 awg...@xbetanet.com 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 Description 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)
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 graw...@gmail.com 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 awg...@xbetanet.com 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 Description 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)
On 23 September 2014 01:10, Alexander Groleau awg...@xbetanet.com 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)
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 awg...@xbetanet.com 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
[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]: 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* ... ___ 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)
On 22 September 2014 05:40, Alexander Groleau awg...@xbetanet.com 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/my.libvirt.service.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
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 awg...@xbetanet.com 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/my.libvirt.service.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
Re: [systemd-devel] Cannot get Shutdown Script to Run (Libvirt Virtual Machine Shutdown)
On Mon, Sep 22, 2014 at 7:40 AM, Alexander Groleau awg...@xbetanet.com 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]: 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
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 arvidj...@gmail.com wrote: On Mon, Sep 22, 2014 at 7:40 AM, Alexander Groleau awg...@xbetanet.com 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]: 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