On 05/24/2018 10:17 AM, Michael S. Tsirkin wrote:
Add more checks on how did QEMU exit.

Legal ways to exit right now:
- exit(0) or return from main
- kill(SIGTERM) - sent by testing infrastructure

Yes, but kill(SIGTERM) causes qemu proper to exit with status 0, because we handle the signal rather than letting it have default behavior or rethrowing it.


Signed-off-by: Michael S. Tsirkin <m...@redhat.com>
Suggested-by: Thomas Huth <th...@redhat.com>
---

TODO: refactor testing infrastructure to stop
QEMU through QMP as opposed to SIGTERM.

          if (pid == s->qemu_pid && WIFSIGNALED(wstatus)) {
+            /* Core dump is never OK */
              assert(!WCOREDUMP(wstatus));
+            /* Either exit normally or get killed */
+            assert((WIFEXITED(wstatus) || WIFSIGNALED(wstatus)));

Eww. This is true if someone does SIGKILL, but not if someone does SIGTERM.

+            /* Exited normally - check exit status. */
+            assert(!WIFEXITED(wstatus) || WEXITSTATUS(wstatus) == 0);

This is fine.

+            /* Killed - we only ever send SIGTERM. */
+            assert(!WIFSIGNALED(wstatus) || WTERMSIG(wstatus) == SIGTERM);

But this is bogus. Sending SIGTERM does NOT cause WIFSIGNALED(); you'd be hard-pressed to get qemu to exit with WTERMSIG(wstatus) == SIGTERM.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Reply via email to