Bug 959017 - virsh shutdown domain
Summary: virsh shutdown domain
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: libvirt
Version: 18
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 744077
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-05-03 02:10 UTC by Dean Hunter
Modified: 2013-05-09 18:51 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-05-08 22:18:45 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Dean Hunter 2013-05-03 02:10:48 UTC
Description of problem:

"virsh shutdown DOMAIN" does not shutdown the domain. The domain continues running even after 5 minutes of waiting. The domain is a standard Fedora 18 / Gnome desktop install.


Version-Release number of selected component (if applicable):

libvirt-0.10.2.4-1.fc18.x86_64


How reproducible: Consistent


Steps to Reproduce:

ssh root@fedora18 reboot
sleep 60
virsh shutdown Fedora18
sleep 300
virsh domstate Fedora18

  
Actual results:

[root@host ~]# ssh root@fedora18 reboot
Connection to fedora18 closed by remote host.
[root@host ~]# sleep 60
[root@host ~]# virsh shutdown Fedora18
Domain Fedora18 is being shutdown

[root@host ~]# sleep 300
[root@host ~]# virsh domstate Fedora18
running

[root@host ~]# 


Expected results:

[root@host ~]# virsh domstate Fedora18
shut off

[root@host ~]# 


Additional info:

Comment 1 Eric Blake 2013-05-03 04:11:59 UTC
This is not a libvirt bug.  'virsh shutdown' requires guest cooperation; but your guest is not wired up to react to either ACPI events or qemu-guest-agent commands, therefore it is not cooperating.

The simplest thing for you to do might be installing acpid in your guest.  Meanwhile, you're not the first person to request that GNOME reconsider their default of ignoring ACPI requests (the default was changed back in Fedora 15; older versions of Fedora shut down just fine in reaction to an ACPI event).

Comment 2 Dean Hunter 2013-05-03 15:02:29 UTC
Thank you for your prompt response. I could not imagine that this might be a "bug" that has slipped through, but, as with several other long standing differences I have discovered, it is very difficult to find solid information about how to work around the problem. Everybody else seems to already know what to do and why and not say much about it.

So you are referring to the "--mode" parameter of the virsh shutdown command:

shutdown domain [--mode acpi|agent]

And you are saying that the default Gnome desktop install on Fedora 18 does not provide a service to respond to either alternative? And you recommend installing acpid on the guest.

Can you direct me to any documentation of this situation, other that the man pages? I would like to better understand where else I might find this or related problems.

Comment 3 Eric Blake 2013-05-03 16:57:31 UTC
bug 744047 details my request for a change in GNOME default reaction to ACPI when in a VM - but it hasn't gone anywhere fast.

THere are also other BZs about getting guest-agent wired up by default, although I didn't search for them just now - this would involve getting the agent installed by default even in live images, and having packages like virt-install wire up an agent by default when installing a known Fedora guest.

For my own fedora guests, I install dconf-editor, then tweak org.gnome.settings-daemon.plugins.power button-power to be interactive instead of its default of suspend (since suspend on a VM isn't as useful as it is bare-metal); this at least lets me get by without installing acpid if I'm logged in (but doesn't seem to help if the guest is still on the gdm screen instead of a session).  I also think using the guest-agent is better than using ACPI, but that's more involved to set up correctly (http://libvirt.org/formatdomain.html, search for guest_agent for an example).

But I am likewise disappointed at the lack of a succinct documentation page on the issue, so if nothing else, this bug can serve as a reminder that libvirt's web site needs a page that covers the pros and cons of the various shutdown methods.

Comment 4 Eric Blake 2013-05-03 16:58:23 UTC
(In reply to comment #3)
> bug 744047 details my request for a change in GNOME default reaction to ACPI
> when in a VM - but it hasn't gone anywhere fast.

Typo: bug 744077 was intended.

Comment 5 Dean Hunter 2013-05-03 17:09:05 UTC
I googled "virsh shutdown acpi" and found some warnings about security concerns with the use of acpid. I did not see much about configuring acpi so I did:

ssh root@fedora18 yum install acpid --assumeyes
ssh root@fedora18 reboot

then tried to shutdown again:

virsh shutdown Fedora18 --agent acpi

but still it will not shutdown.

Comment 6 Eric Blake 2013-05-03 17:16:03 UTC
(In reply to comment #5)
> I googled "virsh shutdown acpi" and found some warnings about security
> concerns with the use of acpid. I did not see much about configuring acpi so
> I did:
> 
> ssh root@fedora18 yum install acpid --assumeyes
> ssh root@fedora18 reboot
> 
> then tried to shutdown again:
> 
> virsh shutdown Fedora18 --agent acpi

'--agent acpi' shouldn't be needed - by default, if you omit --agent, libvirt should try all possible shutdown methods (--agent is more to force an explicit method, even if it is lower priority than what libvirt would attempt first).

> 
> but still it will not shutdown.

Have you checked that the service is actually running in your guest?  You may need to do something like 'systemctl enable acpid'.

While libvirt can't document how to make ALL guests react to ACPI events, we can at least put together a page that mentions common settings for common guests (such as Fedora and Windows).  At least we HAVE documented that shutdown requires guest cooperation, and that guests may ignore the request: http://libvirt.org/html/libvirt-libvirt.html#virDomainShutdownFlags

along with the alternative of virDomainDestroy ('virsh destroy') as the alternative that forces a guest to stop without requiring cooperation.

Comment 7 Dean Hunter 2013-05-03 17:44:44 UTC
Yes, I checked that acpid.service was running. The install actually enabled the service (!) and the during the following reboot it started.

I learned virsh from the man pages, where I learn most command line activities. Perhaps:

"This coordinates with the domain OS to perform graceful shutdown, so there is no guarantee that it will succeed, ...."

could be supplemented with a reference that is more specific and has a date. It is hard to decode many years of historical references and determine what is accurate on this platform.

But more than anything else, "I want it to just work."


I am now attempting to configure qemu-guest-agent.

Comment 8 Dean Hunter 2013-05-03 18:35:58 UTC
qemu-guest-agent works

Comment 9 Dean Hunter 2013-05-03 20:23:58 UTC
Thank you for your help. I have added:

    --channel unix,path=/var/lib/libvirt/qemu/guest.agent,mode=bind,target_type=virtio,name=org.qemu.guest_agent.0 \

to my virt-install script and:

  yum install qemu-guest-agent --assumeyes

to the Anaconda Kickstart post script.

Comment 10 Dean Hunter 2013-05-04 13:59:35 UTC
But of course what works on Fedora 18 causes an SELinux alert and fails on Fedora 19: https://bugzilla.redhat.com/show_bug.cgi?id=959639

Comment 11 Cole Robinson 2013-05-08 22:18:45 UTC
Closing as NOTABUG since this a known issue as pointed out by Eric

Comment 12 Dean Hunter 2013-05-09 18:51:12 UTC
Instead of waiting for Gnome to implement ACPI, which I could not get to work, you might want to install the qemu-guest-agent when the domain is created and expand the man page for virt-install with an example of the required channel, as this is something you might have more control over.


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