Bug 1418927 - The lifecycle event for Guest OS Shutdown is not distinguishable from a qemu process that was quit with SIG_TERM
Summary: The lifecycle event for Guest OS Shutdown is not distinguishable from a qemu ...
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev   
(Show other bugs)
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Eric Blake
QA Contact: Chao Yang
URL:
Whiteboard:
Keywords:
Depends On:
Blocks: 1384007
TreeView+ depends on / blocked
 
Reported: 2017-02-03 07:47 UTC by Martin Kletzander
Modified: 2017-08-02 03:37 UTC (History)
16 users (show)

Fixed In Version: qemu-kvm-rhev-2.9.0-9.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1384007
Environment:
Last Closed: 2017-08-01 23:44:45 UTC
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2017:2392 normal SHIPPED_LIVE Important: qemu-kvm-rhev security, bug fix, and enhancement update 2017-08-01 20:04:36 UTC
Red Hat Bugzilla 1463188 None None None Never

Internal Trackers: 1463188

Description Martin Kletzander 2017-02-03 07:47:03 UTC
+++ This bug was initially created as a clone of Bug #1384007 +++

Description of problem:

When a libvirt managed qemu process gets signaled to quit, libvirt reports the same lifecylce event as if the guest operating system shuts down.


Version-Release number of selected component (if applicable):
libvirt-daemon-1.2.17-13.el7_2.6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Create a virtual machine with a guest operating system (e.g. Linux)
2. Start the virtual machine 
3. virsh -r event <DOMID> --all
4. Get PID for the qemu process of that VM
5. kill -15 $PID

Actual results:
event 'lifecycle' for domain <DOMAINNAME>: Shutdown Finished

Expected results:
A different event detail that allows to distinguish a shutdown from within the Virtual Machine from a process quit via signal from the hypervisor side.

Additional info:

--- Additional comment from Red Hat Bugzilla Rules Engine on 2016-10-12 07:27:15 EDT ---

Since this bug report was entered in Red Hat Bugzilla, the release flag has been set to ? to ensure that it is properly evaluated for this release.

--- Additional comment from Martin Kletzander on 2017-02-03 02:38:25 EST ---

Just a quick test for the two cases shows:

On 'virsh shutdown domain' QEMU sends us:
  SHUTDOWN
  STOP
  SHUTDOWN

whether on 'kill $domain_pid' we get:
  SHUTDOWN

So there are two problems.  First is that the difference comes *after* the point where we consider the domain to be shut down (and we have already emitted the libvirt event).  More importantly, this is not guaranteed to happen (I just tried it once) and none of the differences (the stop or the second shutdown) make sense after SHUTDOWN was recieved.

The only way to differentiate this would be by adding information to the event in QEMU.  So I'm cloning this BZ to QEMU for the requested support.

Comment 3 Eric Blake 2017-04-06 20:22:35 UTC
On the qemu side, the QMP command 'system_powerdown' (invoked by 'virsh shutdown' if the guest agent is not present) sets the global powerdown_requested, which in turn triggers a call to qemu_system_powerdown(), and that sends the first qemu_event_send_powerdown() event seen by libvirt as POWERDOWN prior to iterating through any registered powerdown_notifiers; one of those notifiers then results in the ACPI signal seen by the guest; the guest (normally) reacts by shutting down and eventually triggers the next round of events sent by qemu when qemu_system_shutdown_request() is reached.  Or, if the guest agent is active, system_powerdown is skipped, but it is still a guest action that triggers qemu_system_shutdown_request().  Either way, the global shutdown_requested is set to 1, although shutdown_signal is left unchanged.

Meanwhile, the SIGTERM handler termsig_handler() calls qemu_system_killed(), which sets the global shutdown_requested but also shutdown_signal, and in turn lets main_loop_should_exit() send qemu_event_send_shutdown() seen as a SHUTDOWN event by libvirt.

Ultimately, since the global shutdown_requested is used through both code paths, the only thing that qemu could do differently is to enhance the SHUTDOWN event that it emits to report the presence of a shutdown signal, based on whether the global shutdown_signal was set at the time the event is emitted.  Such a change is a new feature, though, so it would NOT make qemu 2.9.  I will propose it upstream, and it could be backported to RHEV if upstream agrees to it, but then libvirt still has to have a patch to be taught to make use of that bit of information.

Comment 4 Eric Blake 2017-04-06 21:17:46 UTC
Upstream proposal:
https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg01098.html

Comment 5 Eric Blake 2017-04-11 20:04:06 UTC
Missed qemu 2.9; but simple enough to still be backported if upstream approves the idea

Comment 6 Eric Blake 2017-05-22 21:55:45 UTC
v9 will probably be upstream soon:
https://lists.gnu.org/archive/html/qemu-devel/2017-05/msg03742.html

Comment 9 Miroslav Rezanina 2017-06-08 16:26:57 UTC
Fix included in qemu-kvm-rhev-2.9.0-9.el7

Comment 14 errata-xmlrpc 2017-08-01 23:44:45 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.

https://access.redhat.com/errata/RHSA-2017:2392

Comment 15 errata-xmlrpc 2017-08-02 01:22:26 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.

https://access.redhat.com/errata/RHSA-2017:2392

Comment 16 errata-xmlrpc 2017-08-02 02:14:23 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.

https://access.redhat.com/errata/RHSA-2017:2392

Comment 17 errata-xmlrpc 2017-08-02 02:55:11 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.

https://access.redhat.com/errata/RHSA-2017:2392

Comment 18 errata-xmlrpc 2017-08-02 03:19:49 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.

https://access.redhat.com/errata/RHSA-2017:2392

Comment 19 errata-xmlrpc 2017-08-02 03:37:31 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.

https://access.redhat.com/errata/RHSA-2017:2392


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