From patchwork Tue May 19 21:28:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gollub X-Patchwork-Id: 24807 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4JNbB2f008190 for ; Tue, 19 May 2009 23:37:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754660AbZESXhE (ORCPT ); Tue, 19 May 2009 19:37:04 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754659AbZESXhE (ORCPT ); Tue, 19 May 2009 19:37:04 -0400 Received: from d112a2.x-mailer.de ([212.162.53.4]:39398 "EHLO d112a2.x-mailer.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754650AbZESXhD convert rfc822-to-8bit (ORCPT ); Tue, 19 May 2009 19:37:03 -0400 X-Greylist: delayed 7523 seconds by postgrey-1.27 at vger.kernel.org; Tue, 19 May 2009 19:37:03 EDT Received: from [92.229.163.241] (helo=marvin.localnet) by d112.x-mailer.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1M6WuS-0006IW-T1 for kvm@vger.kernel.org; Tue, 19 May 2009 23:31:40 +0200 From: Daniel Gollub Organization: B1 Systems GmbH To: kvm@vger.kernel.org Subject: [PATCH] qemu-kvm: Handle -no-shutodwn Date: Tue, 19 May 2009 23:28:31 +0200 User-Agent: KMail/1.11.3 (Linux/2.6.27.21-0.1-default; KDE/4.2.3; x86_64; ; ) MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200905192328.31362.gollub@b1-systems.de> X-Info: valid message X-Info: original Date Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- qemu-kvm.c | 9 ++++++--- sysemu.h | 1 + vl.c | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index 5e4002b..b9926eb 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -597,9 +597,12 @@ int kvm_main_loop(void) while (1) { main_loop_wait(1000); - if (qemu_shutdown_requested()) - break; - else if (qemu_powerdown_requested()) + if (qemu_shutdown_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/sysemu.h b/sysemu.h index 1f45fd6..0dd184d 100644 --- a/sysemu.h +++ b/sysemu.h @@ -35,6 +35,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/vl.c b/vl.c index d9f0607..9b2a420 100644 --- a/vl.c +++ b/vl.c @@ -3644,6 +3644,13 @@ static int powerdown_requested; static int debug_requested; static int vmstop_requested; +int qemu_no_shutdown(void) +{ + int r = no_shutdown; + no_shutdown = 0; + return r; +} + int qemu_shutdown_requested(void) { int r = shutdown_requested;