From 86b2c1dc866e03902f56cac5aaede3d1b653391a Mon Sep 17 00:00:00 2001 Message-Id: <86b2c1dc866e03902f56cac5aaede3d1b653391a.1339678955.git.minovotn@redhat.com> From: Amit Shah <amit.shah@redhat.com> Date: Wed, 13 Jun 2012 16:09:40 +0200 Subject: [PATCH 1/2] Handle -no-shutdown correctly RH-Author: Amit Shah <amit.shah@redhat.com> Message-id: <562f966ac9d04f9c20a3fa423c442dde5a6a57a5.1339603665.git.amit.shah@redhat.com> Patchwork-id: 39959 O-Subject: [RHEL5.9 kvm-userspace PATCH 1/2] Handle -no-shutdown correctly Bugzilla: 819413 RH-Acked-by: Kevin Wolf <kwolf@redhat.com> RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com> RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com> From: Daniel Gollub <gollub@b1-systems.de> Plain QEMU has the parameter -no-shutdown. This avoids termination of the qemu process when VM got shutdown (e.g. to still use the QEMU-Monitor with stopped VM). This parameter has no effect on qemu-kvm, today. This patch introduces identical handling, as in qemu, of -no-shutdown for qemu-kvm: * termination of qemu-kvm process on a VM shutdown get only avoided once * second shutdown of VM cause termination of qemu-kvm (like in qemu) Signed-off-by: Daniel Gollub <gollub@b1-systems.de> Signed-off-by: Avi Kivity <avi@redhat.com> (manually cherry-picked from 18b35c2a97e55e763a5ec86f1cffec3c8060a4b8) Conflicts: qemu/qemu-kvm.c (Conflict due to qemu_kill_report() added in context. Resolution similar to what we have in RHEL6.) RHEL5-specific changes: Remove 'no_shutdown=0' from qemu_no_shutdown to ensure a second shutdown request does not succeed. This was 'fixed' upstream by moving to qemu's main_loop in commit 519387d926121bb188b0b5354850e2925eb603dc . A similar change upstream is also in e69ae5c49af45a67ebdf6a7cf465eb91b5c8ee11 in the main_loop(). That commit isn't backported, as we don't make use of main_loop() in the RHEL5 code. Signed-off-by: Amit Shah <amit.shah@redhat.com> --- qemu/qemu-kvm.c | 8 +++++--- qemu/sysemu.h | 1 + qemu/vl.c | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) Signed-off-by: Michal Novotny <minovotn@redhat.com> --- qemu/qemu-kvm.c | 8 +++++--- qemu/sysemu.h | 1 + qemu/vl.c | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c index a049bec..69a6ade 100644 --- a/qemu/qemu-kvm.c +++ b/qemu/qemu-kvm.c @@ -596,9 +596,11 @@ int kvm_main_loop(void) main_loop_wait(1000); if (qemu_shutdown_requested()) { qemu_kill_report(); - break; - } - else if (qemu_powerdown_requested()) + if (qemu_no_shutdown()) { + vm_stop(0); + } else + break; + } else if (qemu_powerdown_requested()) qemu_system_powerdown(); else if (qemu_reset_requested()) qemu_kvm_system_reset(); diff --git a/qemu/sysemu.h b/qemu/sysemu.h index cda1e92..a48b346 100644 --- a/qemu/sysemu.h +++ b/qemu/sysemu.h @@ -39,6 +39,7 @@ void cpu_disable_ticks(void); void qemu_system_reset_request(void); void qemu_system_shutdown_request(void); void qemu_system_powerdown_request(void); +int qemu_no_shutdown(void); int qemu_shutdown_requested(void); int qemu_reset_requested(void); int qemu_powerdown_requested(void); diff --git a/qemu/vl.c b/qemu/vl.c index 3e9503f..4130785 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -3882,6 +3882,12 @@ static int shutdown_requested, shutdown_signal = -1; static pid_t shutdown_pid; static int powerdown_requested; +int qemu_no_shutdown(void) +{ + int r = no_shutdown; + return r; +} + int qemu_shutdown_requested(void) { int r = shutdown_requested; -- 1.7.7.6