From patchwork Tue Nov 2 16:26:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 69908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 98417B70E6 for ; Wed, 3 Nov 2010 03:29:03 +1100 (EST) Received: from localhost ([127.0.0.1]:54188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDJjH-0001t2-71 for incoming@patchwork.ozlabs.org; Tue, 02 Nov 2010 12:28:59 -0400 Received: from [140.186.70.92] (port=44887 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDJgt-0001Lp-2t for qemu-devel@nongnu.org; Tue, 02 Nov 2010 12:26:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDJgr-00007z-NG for qemu-devel@nongnu.org; Tue, 02 Nov 2010 12:26:31 -0400 Received: from cantor.suse.de ([195.135.220.2]:49903 helo=mx1.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PDJgr-00007v-DJ for qemu-devel@nongnu.org; Tue, 02 Nov 2010 12:26:29 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id E101D947EC; Tue, 2 Nov 2010 17:26:28 +0100 (CET) From: Alexander Graf To: qemu-devel Developers Date: Tue, 2 Nov 2010 17:26:28 +0100 Message-Id: <1288715188-28710-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1288623713-28062-1-git-send-email-agraf@suse.de> References: <1288623713-28062-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 40/40] xen: add sysrq support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sending sys-requests on Xen is different from the usual keyboard based ways. For xen, we need to add a xenstored node which the guest pulls the sysrq information from. This patch implements said interface by introducing a new human monitor command to use it. It's purely optional. Signed-off-by: Alexander Graf --- hmp-commands.hx | 24 ++++++++++++++++++++++++ hw/xen.h | 2 ++ hw/xen_domainbuild.c | 8 ++++++++ monitor.c | 8 ++++++++ 4 files changed, 42 insertions(+), 0 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 81999aa..40fdd00 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -436,6 +436,30 @@ This command is useful to send keys that your graphical user interface intercepts at low level, such as @code{ctrl-alt-f1} in X Window. ETEXI +#if defined(CONFIG_XEN) || defined(CONFIG_XENNER) + { + .name = "xen_sysrq", + .args_type = "string:s", + .params = "key", + .help = "send sysrq to the Xen VM", + .mhandler.cmd = do_xen_sysrq, + }, +#endif + +STEXI +@item xen_sysrq @var{key} +@findex xen_sysrq + +Send @var{key} as sys-request to the Xen VM. This is the equivalent to +alt-print-@var{key} in normal Linux guests. Example: +@example +xen_sysrq s +@end example + +Please keep in mind that this is the only way of sending sys-requests to +Xen PV machines. The usual alt-print-@var{key} way does not work. +ETEXI + { .name = "system_reset", .args_type = "", diff --git a/hw/xen.h b/hw/xen.h index 780dcf7..f2ac576 100644 --- a/hw/xen.h +++ b/hw/xen.h @@ -18,4 +18,6 @@ enum xen_mode { extern uint32_t xen_domid; extern enum xen_mode xen_mode; +void xen_sysrq(const char *sysrq); + #endif /* QEMU_HW_XEN_H */ diff --git a/hw/xen_domainbuild.c b/hw/xen_domainbuild.c index 7f1fd66..49962db 100644 --- a/hw/xen_domainbuild.c +++ b/hw/xen_domainbuild.c @@ -211,6 +211,14 @@ static int xen_domain_watcher(void) _exit(0); } +void xen_sysrq(const char *sysrq) +{ + void *dom; + + dom = xs_get_domain_path(xenstore, xen_domid); + xenstore_write_str(dom, "control/sysrq", sysrq); +} + /* normal cleanup */ static void xen_domain_cleanup(void) { diff --git a/monitor.c b/monitor.c index 61607c5..99aae01 100644 --- a/monitor.c +++ b/monitor.c @@ -30,6 +30,7 @@ #include "hw/pci.h" #include "hw/watchdog.h" #include "hw/loader.h" +#include "hw/xen.h" #include "gdbstub.h" #include "net.h" #include "net/slirp.h" @@ -1639,6 +1640,13 @@ static void release_keys(void *opaque) } } +#if defined(CONFIG_XEN) || defined(CONFIG_XENNER) +static void do_xen_sysrq(Monitor *mon, const QDict *qdict) +{ + xen_sysrq(strdup(qdict_get_str(qdict, "string"))); +} +#endif + static void do_sendkey(Monitor *mon, const QDict *qdict) { char keyname_buf[16];