Bug 728464

Summary: QEMU does not honour '-no-shutdown' flag after the first shutdown attempt
Product: Red Hat Enterprise Linux 6 Reporter: Daniel Berrangé <berrange>
Component: qemu-kvmAssignee: Amit Shah <amit.shah>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.0CC: chayang, juzhang, jwest, mkenneth, qzhang, sluo, tburke, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.179.el6 Doc Type: Bug Fix
Doc Text:
If QEMU was started with the '-no-shutdown' flag, asking it to not quit after guest shutdown, this flag was overlooked after the first guest shutdown. The fix is to obey the flag after repetitive shutdowns, and the QEMU now doesn't quit if this flag is supplied.
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 15:55:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 533338    

Description Daniel Berrangé 2011-08-05 08:40:16 UTC
Description of problem:
To perform a warm reboot of guests, libvirt uses the '-no-shutdown' flag on the command line, and when shutdown occurs it issues 'system_reset' + 'cont'.

After the first time shutdown occurs though, QEMU resets the no_shutdown flag.

Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.177.el6

How reproducible:
Always

Steps to Reproduce:
1. Boot a RHEL-6 guest, with -no-shutdown flag on command line
2. Run 'system_powerdown' command in monitor
3. Wait for guest OS to shutdown down and issue power off to the VM
4. Run 'system_reset' command
5. Run 'cont' command
6. Wait for guest OS to boot up 
7. Run 'system_powerdown' command in monitor
8. Wait for guest OS to shutdown down and issue power off to the VM
  
Actual results:
QEMU will exit at step 8

Expected results:
QEMU should remain running, allowing steps 4->8 to be repeated again, and again, and again, ....

Additional info:

Comment 1 Daniel Berrangé 2011-08-05 08:40:56 UTC
Requires this upstream fix

commit e69ae5c49af45a67ebdf6a7cf465eb91b5c8ee11
Author: Wen Congyang <wency.com>
Date:   Fri Jun 17 10:25:22 2011 +0800

    do not reset no_shutdown after we shutdown the vm
    
    Daniel P. Berrange sent a libvirt's patch to support
    reboots with the QEMU driver. He implements it in
    json model like this:
    1. add -no-shutdown in the qemu's option:
       qemu -no-shutdown xxxx
    2. shutdown the vm by monitor command system_powerdown
    3. wait for shutdown event
    4. reset the vm by monitor command system_reset
    
    no_shutdown will be reset to 0 if the vm is powered down.
    We only can reboot the vm once.
    
    If no_shutdown is not reset to 0, we can reboot the vm
    many times.
    
    Signed-off-by: Wen Congyang <wency.com>
    Signed-off-by: Anthony Liguori <aliguori.com>

Comment 3 Chao Yang 2011-08-09 02:22:11 UTC
I have reproduced this issue based on steps in Comment #0 with qemu-kvm-0.12.1.2-2.177.el6.x86_64

After step 3, guest stuck at follows, and this is expected:
Halting system...
md: stopping all md devices.
sd 1:0:0:0: [sda] Synchronizing SCSI cache
sd 1:0:0:0: [sda] Stopping disk
ACPI: Preparing to enter system sleep state S5
Disabling non-boot CPUs ...
Power down.

(qemu) info status
VM status: paused

After step 8, qemu exited instead of stop guest before shutdown

CLI:/usr/libexec/qemu-kvm -M rhel6.2.0 -enable-kvm -m 1G -smp 1 -name RHEL6.1 ... -no-shutdown

Comment 8 Sibiao Luo 2011-08-31 09:57:50 UTC
Verified this issue on the fixed version qemu-kvm-0.12.1.2-2.184.el6.x86_64.

steps:
1. boot a RHEL-6 guest with "-no-shutdown" in command line
CLI:# /usr/libexec/qemu-kvm -M rhel6.2.0 -enable-kvm -m 2G -smp 4 -name RHEL6.2
... -no-shutdown
2. run 'system_powerdown' command in the monitor
3. wait for guest OS to shutdown down and issue power off to the VM, and look the guest status
(qemu) info status
VM status: paused
4. run 'system_reset' command 
5. run 'cont' command and then look the guest status
(qemu) cont
(qemu) info status 
VM status: running
6. wait for guest OS to boot up 

Take 2->6 steps to be repeated more than 10 times.

Actual results:
After the step3,the guest status was paused and didn't exit.

Above all, Based on  my Comment and Comment #3, this issue has been fixed.

Comment 10 Amit Shah 2011-11-18 06:52:21 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
If QEMU was started with the '-no-shutdown' flag, asking it to not quit after guest shutdown, this flag was overlooked after the first guest shutdown.  The fix is to obey the flag after repetitive shutdowns, and the QEMU now doesn't quit if this flag is supplied.

Comment 11 errata-xmlrpc 2011-12-06 15:55:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2011-1531.html