Bug 821622

Summary: doc improvement for "virsh shutdown"
Product: Red Hat Enterprise Linux 6 Reporter: EricLee <bili>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 6.3CC: acathrow, dallan, dyasny, dyuan, mzhan, rwu, whuang, yupzhang
Target Milestone: rc   
Target Release: 6.3   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-16 13:56:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description EricLee 2012-05-15 07:00:32 UTC
Description of problem:
"man virsh" should write shutdown command will not effect until the acpi daemon started in the guest and "virsh shutdown" should give error info when acpid is not available with the option "--mode acpi"

Version-Release number of selected component (if applicable):
libvirt-0.9.10-18.el6.x86_64
qemu-kvm-0.12.1.2-2.292.el6.x86_64
kernel-2.6.32-270.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
Need:
Guest OS is greater than RHEL6(have acpi pkg installed).
Actions:
# virsh start raw
Domain raw started

run the command ASAP (before the acpi daemon started):
# virsh shutdown --mode acpi raw 
Domain raw is being shutdown
But it will not effect(guest will still running).

After a moment(after the acpi daemon started), rerun the command:
# virsh shutdown --mode acpi raw
Domain raw is being shutdown
And it start to shutdown the guest gracefully.

# man virsh
   ...
       shutdown domain-id [--mode acpi|agent]
           Gracefully shuts down a domain.  This coordinates with the domain OS to perform graceful
           shutdown, so there is no guarantee that it will succeed, and may take a variable length of
           time depending on what services must be shutdown in the domain.

           The exact behavior of a domain when it shuts down is set by the on_shutdown parameter in the
           domain’s XML definition.

           If domain-id is transient, then the metadata of any snapshots will be lost once the guest
           stops running, but the snapshot contents still exist, and a new domain with the same name
           and UUID can restore the snapshot metadata with snapshot-create.

           By default the hypervisor will try to pick a suitable shutdown method. To specify an
           alternative method, the --mode parameter can specify "acpi" or "agent".
   ...


Another environment :
Login to the guest, stop the acpid service:
#service acpid stop

Then rerun command:
# virsh shutdown raw
Domain raw is being shutdown

Actual results:
As below.

Expected results:
Could see something about this circumstances in "man virsh".

When acpid is stoped, the shutdown command should fail with error info like: "error: QEMU guest acpid is not available", but no effect with info "Domain raw is being shutdown" .

Additional info:
just like "--mode agent", when it was not configured shutdown will failed:
# virsh shutdown --mode agent qcow2
error: Failed to shutdown domain qcow2
error: argument unsupported: QEMU guest agent is not configured

Comment 2 Dave Allan 2012-05-16 13:56:25 UTC
The problem here is that libvirt doesn't know what's running in the guest.  It would be possible to hack qemu-ga to provide this information, but IMO that's not worth doing, since if you have qemu-ga, you can call it to shutdown the guest and avoid acpi entirely.  Since the virsh man page already documents that shutdown requires cooperation with the guest OS and is not guaranteed to succeed, I don't think there's anything that can be done here.