Bug 444273 - RFE: shut down guests with machine
Summary: RFE: shut down guests with machine
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt   
(Show other bugs)
Version: unspecified
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Daniel Veillard
QA Contact:
: 437204 537270 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2008-04-26 11:05 UTC by Pierre Ossman
Modified: 2010-10-08 17:57 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2010-05-25 15:10:03 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
init script for libvirtd (3.09 KB, application/x-shellscript)
2009-02-02 21:43 UTC, syntron
no flags Details
sysconfig file for libvirtd (585 bytes, message/news)
2009-02-02 21:44 UTC, syntron
no flags Details
init script for libvirtdomains (3.12 KB, application/x-shellscript)
2009-02-02 21:44 UTC, syntron
no flags Details
sysconfig file for libvirtdomains (711 bytes, message/news)
2009-02-02 21:45 UTC, syntron
no flags Details

Description Pierre Ossman 2008-04-26 11:05:05 UTC
One nice feature I'm lacking with the current libvirt package (which otherwise
is a pure delight :)) is the ability to have guests come up and down with the
host. Or rather, come down as the autostart feature is already in place.

Basically, I'd like a init.d script that triggers a "shutdown" on all guests
when the host is going down and waits for them to terminate. A timeout and a
forceful kill is probably also needed though.

The best way is likely with a separate script, as you'd like to restart libvirtd
without killing all your guests.

Comment 1 Pierre Ossman 2008-04-26 11:27:08 UTC
It seems the killing is the current behaviour. :/

So in the light of that, I'd like a tweak from the current forced kill, to a
clean shutdown on service libvirtd stop.

Comment 2 Daniel Berrange 2008-04-26 14:16:21 UTC
Clean shutdown is not viable because this requires co-operation from the guest
OS. There is no guarentee the guest will honour this request to shutdown even
when operating normally, if the guest is operating abnormally it may not even
see the event, and it may hang during shutdown with no way for libvirt to
determine if it is still in process of shutting down, or has hung. 

Killing, or suspending VMs (save to disk) are the only viable options.

Comment 3 Pierre Ossman 2008-04-27 08:17:14 UTC
I agree, which is why I suggest the script _tries_ to shut them down cleanly,
but then gets violent after a certain timeout. Basically the same behaviour as
the SIGTERM/SIGKILL portion at the end of the system shutdown.

Comment 4 Daniel Berrange 2008-04-27 15:59:19 UTC
No, this is the behaviour that used to be present in Xen. It was removed because
it frequently shot domains which were in fact still shutting down cleanly,
simply taking a long time. There is no safe way todo timeouts on shutdown.
Suspending to disk the only guarenteed safe option.

Comment 5 Paul W. Frields 2008-08-10 20:44:51 UTC
Triage here.  Suggest CLOSED {WONTFIX,CANTFIX} then?

Comment 6 Daniel Berrange 2009-01-22 13:09:19 UTC
*** Bug 437204 has been marked as a duplicate of this bug. ***

Comment 7 Daniel Berrange 2009-01-22 13:09:56 UTC
Leave open. This still needs to be addressed in some way

Comment 8 syntron 2009-02-02 21:43:21 UTC
I extended the init script for opensuse. It tries to shutdown all qemu / kvm domains and after a timeout all domains are killed (libvirtd.init and the sysconfig file libvirtd.sysconfig).

Furthermore I also tested the possibility to save / restore domains. This works sometimes and sometimes not. At the moment I have it down that:
- it works if I do stop / start without a reboot in between
- using it for saving / restoring domains restore only returns an error
(libvirtdomains.init and the sysconfig file libvirtdomains.sysconfig)

I hope that the scripts are usefull. I'm not an expert using bash so there will be a lot of things which can be done better ...

Comment 9 syntron 2009-02-02 21:43:59 UTC
Created attachment 330683 [details]
init script for libvirtd

Comment 10 syntron 2009-02-02 21:44:21 UTC
Created attachment 330684 [details]
sysconfig file for libvirtd

Comment 11 syntron 2009-02-02 21:44:44 UTC
Created attachment 330685 [details]
init script for libvirtdomains

Comment 12 syntron 2009-02-02 21:45:11 UTC
Created attachment 330686 [details]
sysconfig file for libvirtdomains

Comment 13 syntron 2009-02-02 21:47:59 UTC
(In reply to comment #8)
> - using it for saving / restoring domains restore only returns an error

some more info:

if a domains is saved on shutdown it is _not_ restored on boot. even if I try to do it manually it is not restored. But doing a save / restory cycle using a running system all is OK.

Comment 14 Mark McLoughlin 2009-02-03 07:39:46 UTC
Moving to Virtualization Tools product

See also:


Comment 16 Mark McLoughlin 2009-11-19 14:08:36 UTC
*** Bug 537270 has been marked as a duplicate of this bug. ***

Comment 17 Daniel Berrange 2010-02-22 13:28:48 UTC
FYI this thread describes the API enhancements required in libvirt in order to safely / reliably support managed shutdown at host halt


Comment 18 Daniel Berrange 2010-05-25 15:10:03 UTC
The APIs described have now been implemented & an corresponding initscript for auto-shutdown/save is now available

commit 66823690e46944f17e195b1f82c5eee527ddee20
Author: Jiri Denemark <jdenemar@redhat.com>
Date:   Fri May 14 15:37:55 2010 +0200

    Init script for handling guests on shutdown/boot

Comment 19 Henrik Nordström 2010-05-25 18:36:30 UTC

I'll look forward to test this. From which package versions will it be available?

Comment 20 Cole Robinson 2010-05-25 18:56:13 UTC
The next libvirt release will probably be 0.8.2

Note You need to log in before you can comment on or make changes to this bug.