[systemd-devel] Cannot get Shutdown Script to Run (Libvirt Virtual Machine Shutdown)
Daniel P. Berrange
berrange at redhat.com
Tue Sep 23 02:44:21 PDT 2014
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 :|
More information about the systemd-devel
mailing list