From nobody Tue May 21 11:44:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1607459084; cv=none; d=zohomail.com; s=zohoarc; b=ZRp66lElir6duHLEouCGSo/1R27q95wVkzZNH6dscfCtDte6r+jkpBa52mhNhWGQdldXVAPIJ1Rl3w2nvQCuk4T64gYRSOk7DSKlMx3u78Iez2KeEw82oqXGS1s//FxpGR1MRkjzbn0qW1VUcs3pnE/oZdPRGZbua6sjKk915kA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607459084; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=QARxm3Je5pKxqTTQOw/5OsgTlH0FU6BpWGtrXezWHu8=; b=c3Not3AiUId83c3UHVEh28daxVqBPTTjxVZ+OJQ4JVXSycr1rdVp/MycA15oHlogRhwfmkEEHOiqD8ameSqOs1WNOIrG2b4GI8ju8dXLU+iD9GA7ul96ilWArkym222nwZ38oJqmccz1j2TLbBhxGzT/Q5nPBPp6otO3Lg0JKEY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607459084868233.60867326673815; Tue, 8 Dec 2020 12:24:44 -0800 (PST) Received: from localhost ([::1]:58570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmiWE-00018t-QV for importer@patchew.org; Tue, 08 Dec 2020 14:19:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmiS6-0007rd-9H for qemu-devel@nongnu.org; Tue, 08 Dec 2020 14:15:11 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:51940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmiS1-0007TY-Jd for qemu-devel@nongnu.org; Tue, 08 Dec 2020 14:15:09 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B8J9wdI029371; Tue, 8 Dec 2020 19:14:59 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 3581mqvh98-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 08 Dec 2020 19:14:59 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B8JAVj4140213; Tue, 8 Dec 2020 19:14:58 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 358m3y5wje-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Dec 2020 19:14:58 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0B8JEvaH017802; Tue, 8 Dec 2020 19:14:57 GMT Received: from ban25x6uut148.us.oracle.com (/10.153.73.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 08 Dec 2020 11:14:57 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=QARxm3Je5pKxqTTQOw/5OsgTlH0FU6BpWGtrXezWHu8=; b=CYfqM21GO1exWFLNYDcr1UHp2iJFCWRdBZpyDGE+Owgkosliz4HMiygeAJ42nqh8qB4W pPSSI3ddI+EHT/bcKBYAzbbW4mgSuDqVM6WIPINp78OvdLMw1UgGcBuNfGtd9bjFUWoT v6KTYoPgvMaZ5jF8xuruJAz8FO0W1gHNxxLQZVE/YBB60T4ptxhTxlaA6IbKWVQdmoOa n3j9D1scLnzufNd0u3Z5I3kQkfd8vNfBOeJ/v/ww7JvUnhUzYtK+CANOCpOCL6qw2dhJ m0HcnYi/vwD6PAPpyLH5LPgd5dXN7uA3HbA7lcHUuXe9pcOFFQDh6Jq8TyNMal9aGnos RQ== From: Alejandro Jimenez To: qemu-devel@nongnu.org Subject: [PATCH 1/4] vl: Add an -action option to respond to guest events Date: Tue, 8 Dec 2020 14:14:47 -0500 Message-Id: <1607454890-3339-2-git-send-email-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607454890-3339-1-git-send-email-alejandro.j.jimenez@oracle.com> References: <1607454890-3339-1-git-send-email-alejandro.j.jimenez@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9829 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=1 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080117 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9829 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 mlxlogscore=999 clxscore=1015 malwarescore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080117 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=alejandro.j.jimenez@oracle.com; helo=userp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Several command line options currently in use are meant to modify the behavior of QEMU in response to certain guest events like: -no-reboot, -no-shutdown, -watchdog-action. These can be grouped into a single option of the form: -action event=3Daction Which can be used to specify the existing options above in the following format: -action reboot=3Dnone|shutdown -action shutdown=3Dpoweroff|pause -action watchdog=3Dreset|shutdown|poweroff|pause|debug|none|inject-nmi This is done in preparation for adding yet another option of this type, which modifies the QEMU behavior when a guest panic occurs. Suggested-by: Paolo Bonzini Signed-off-by: Alejandro Jimenez Reviewed-by: David Edmondson Reviewed-by: Liam Merwick --- MAINTAINERS | 2 + include/sysemu/runstate-action.h | 16 +++++ include/sysemu/sysemu.h | 1 + qapi/run-state.json | 88 ++++++++++++++++++++++++++ qemu-options.hx | 22 +++++++ softmmu/meson.build | 1 + softmmu/runstate-action.c | 131 +++++++++++++++++++++++++++++++++++= ++++ softmmu/vl.c | 30 ++++++++- 8 files changed, 290 insertions(+), 1 deletion(-) create mode 100644 include/sysemu/runstate-action.h create mode 100644 softmmu/runstate-action.c diff --git a/MAINTAINERS b/MAINTAINERS index 68bc160..7dcc4bd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2332,6 +2332,7 @@ M: Paolo Bonzini S: Maintained F: include/qemu/main-loop.h F: include/sysemu/runstate.h +F: include/sysemu/runstate-action.h F: util/main-loop.c F: util/qemu-timer.c F: softmmu/vl.c @@ -2340,6 +2341,7 @@ F: softmmu/cpus.c F: softmmu/cpu-throttle.c F: softmmu/cpu-timers.c F: softmmu/icount.c +F: softmmu/runstate-action.c F: qapi/run-state.json =20 Read, Copy, Update (RCU) diff --git a/include/sysemu/runstate-action.h b/include/sysemu/runstate-act= ion.h new file mode 100644 index 0000000..f545ab3 --- /dev/null +++ b/include/sysemu/runstate-action.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef RUNSTATE_ACTION_H +#define RUNSTATE_ACTION_H + +/* in softmmu/runstate-action.c */ +int process_runstate_actions(void *opaque, QemuOpts *opts, Error **errp); +int runstate_action_parse(QemuOptsList *opts_list, const char *optarg); + +#endif /* RUNSTATE_ACTION_H */ diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 817ff4c..5480e61 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -43,6 +43,7 @@ extern int win2k_install_hack; extern int alt_grab; extern int ctrl_grab; extern int graphic_rotate; +extern int no_reboot; extern int no_shutdown; extern int old_param; extern int boot_menu; diff --git a/qapi/run-state.json b/qapi/run-state.json index 964c8ef..6b033c1 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -329,6 +329,94 @@ 'inject-nmi' ] } =20 ## +# @RunStateEventType: +# +# An enumeration of Run State event types +# +# @reboot: Guest reboot +# +# @shutdown: Guest shutdown +# +# @watchdog: A watchdog device's timer has expired +# +# Since: 6.0 +## +{ 'enum': 'RunStateEventType', + 'data': [ 'reboot', 'shutdown', 'watchdog' ] } + +## +# @RunStateAction: +# +# Describes a guest event and the subsequent action that is taken +# by QEMU when such event takes place. +# +# Since: 6.0 +## +{ 'union': 'RunStateAction', + 'base': { 'event': 'RunStateEventType' }, + 'discriminator': 'event', + 'data': { + 'reboot': 'RunStateRebootAction', + 'shutdown': 'RunStateShutdownAction', + 'watchdog': 'RunStateWatchdogAction' } } + +## +# @RunStateRebootAction: +# +# @action: Action taken by QEMU when guest reboots +# +# Since: 6.0 +## +{ 'struct': 'RunStateRebootAction', + 'data': { 'action': 'RebootAction' } } + +## +# @RebootAction: +# +# Possible QEMU actions upon guest reboot +# +# @none: Reset the VM +# +# @shutdown: Shutdown the VM and exit +# +# Since: 6.0 +## +{ 'enum': 'RebootAction', + 'data': [ 'none', 'shutdown' ] } + +## +# @RunStateShutdownAction: +# +# @action: Action taken by QEMU when guest shuts down +# +# Since: 6.0 +## +{ 'struct': 'RunStateShutdownAction', + 'data': { 'action': 'ShutdownAction' } } + +## +# @ShutdownAction: +# +# @pause: pause the VM +# +# @poweroff: Shutdown the VM and exit +# +# Since: 6.0 +## +{ 'enum': 'ShutdownAction', + 'data': [ 'pause', 'poweroff' ] } + +## +# @RunStateWatchdogAction: +# +# @action: Action taken by QEMU when watchdog device timer expires +# +# Since: 6.0 +## +{ 'struct': 'RunStateWatchdogAction', + 'data': { 'action': 'WatchdogAction' } } + +## # @watchdog-set-action: # # Set watchdog action diff --git a/qemu-options.hx b/qemu-options.hx index 104632e..a0d50f0 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3894,6 +3894,28 @@ SRST changes to the disk image. ERST =20 +DEF("action", HAS_ARG, QEMU_OPTION_action, + "-action reboot=3Dnone|shutdown\n" + " action when guest reboots [default=3Dnone]\n" + "-action shutdown=3Dpoweroff|pause\n" + " action when guest shuts down [default=3Dpoweroff]\= n" + "-action watchdog=3Dreset|shutdown|poweroff|inject-nmi|pause|debug|non= e\n" + " action when watchdog fires [default=3Dreset]\n", + QEMU_ARCH_ALL) +SRST +``-action event=3Daction`` + The action parameter serves to modify QEMU's default behavior when + certain guest events occur. It provides a generic method for specifyin= g the + same behaviors that are modified by the ``-no-reboot`` and ``-no-shutd= own`` + parameters. + + Examples: + + ``-action reboot=3Dshutdown,shutdown=3Dpause`` + ``-watchdog i6300esb -action watchdog=3Dpause`` + +ERST + DEF("loadvm", HAS_ARG, QEMU_OPTION_loadvm, \ "-loadvm [tag|id]\n" \ " start right away with a saved state (loadvm in monito= r)\n", diff --git a/softmmu/meson.build b/softmmu/meson.build index 8f7210b..8ad586e 100644 --- a/softmmu/meson.build +++ b/softmmu/meson.build @@ -10,6 +10,7 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( 'qtest.c', 'vl.c', 'cpu-timers.c', + 'runstate-action.c', )]) =20 specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: [files( diff --git a/softmmu/runstate-action.c b/softmmu/runstate-action.c new file mode 100644 index 0000000..bbbbc07 --- /dev/null +++ b/softmmu/runstate-action.c @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "sysemu/runstate-action.h" +#include "sysemu/sysemu.h" +#include "sysemu/watchdog.h" +#include "qemu/config-file.h" +#include "qapi/error.h" +#include "qemu/option_int.h" +#include "qapi/qapi-commands-run-state.h" + +static void runstate_action_help(void) +{ + int idx; + + printf("Events for which an action can be specified:\n"); + for (idx =3D 0; idx < RUN_STATE_EVENT_TYPE__MAX; idx++) { + printf("%10s\n", RunStateEventType_str(idx)); + } +} + +/* + * Set the internal state to react to a guest reboot event + * as specified by the action parameter. + */ +static void qmp_reboot_set_action(RebootAction act, Error **errp) +{ + switch (act) { + case REBOOT_ACTION_NONE: + no_reboot =3D 0; + break; + case REBOOT_ACTION_SHUTDOWN: + no_reboot =3D 1; + break; + default: + g_assert_not_reached(); + } +} + +/* + * Set the internal state to react to a guest shutdown event + * as specified by the action parameter. + */ +static void qmp_shutdown_set_action(ShutdownAction act, Error **errp) +{ + switch (act) { + case SHUTDOWN_ACTION_PAUSE: + no_shutdown =3D 1; + break; + case SHUTDOWN_ACTION_POWEROFF: + no_shutdown =3D 0; + break; + default: + g_assert_not_reached(); + } +} + +/* + * Process an event|action pair and set the appropriate internal + * state if event and action are valid. + */ +static int set_runstate_action(void *opaque, const char *event, + const char *action, Error **errp) +{ + int event_idx, act_idx; + + event_idx =3D qapi_enum_parse(&RunStateEventType_lookup, event, -1, er= rp); + + switch (event_idx) { + case RUN_STATE_EVENT_TYPE_REBOOT: + act_idx =3D qapi_enum_parse(&RebootAction_lookup, action, -1, errp= ); + qmp_reboot_set_action(act_idx, NULL); + break; + case RUN_STATE_EVENT_TYPE_SHUTDOWN: + act_idx =3D qapi_enum_parse(&ShutdownAction_lookup, action, -1, er= rp); + qmp_shutdown_set_action(act_idx, NULL); + break; + case RUN_STATE_EVENT_TYPE_WATCHDOG: + if (select_watchdog_action(action) =3D=3D -1) { + error_report("unknown watchdog action parameter"); + exit(1); + } + break; + default: + /* + * The event and action types are checked for validity in the call= s to + * qapi_enum_parse(), which will cause an exit if the requested ev= ent or + * action are invalid, since error_fatal is used as the error para= meter. + * This case is unreachable unless those conditions change. + */ + g_assert_not_reached(); + } + + return 0; +} + +/* + * Parse provided -action arguments from cmdline. + */ +int runstate_action_parse(QemuOptsList *opts_list, const char *optarg) +{ + QemuOpts *opts; + + if (!strcmp(optarg, "help")) { + runstate_action_help(); + return -1; + } + + opts =3D qemu_opts_parse_noisily(opts_list, optarg, false); + if (!opts) { + return -1; + } + return 0; +} + +/* + * Process all the -action parameters parsed from cmdline. + */ +int process_runstate_actions(void *opaque, QemuOpts *opts, Error **errp) +{ + if (qemu_opt_foreach(opts, set_runstate_action, NULL, errp)) { + return -1; + } + return 0; +} diff --git a/softmmu/vl.c b/softmmu/vl.c index e6e0ad5..2b1583e 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -34,6 +34,7 @@ #include "qemu/uuid.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" +#include "sysemu/runstate-action.h" #include "sysemu/seccomp.h" #include "sysemu/tcg.h" #include "sysemu/xen.h" @@ -147,7 +148,7 @@ Chardev *parallel_hds[MAX_PARALLEL_PORTS]; int win2k_install_hack =3D 0; int singlestep =3D 0; int fd_bootchk =3D 1; -static int no_reboot; +int no_reboot; int no_shutdown =3D 0; int graphic_rotate =3D 0; const char *watchdog; @@ -506,6 +507,21 @@ static QemuOptsList qemu_fw_cfg_opts =3D { }, }; =20 +static QemuOptsList qemu_action_opts =3D { + .name =3D "action", + /* + * When lists are merged, the location is set to the first use of the + * option. If a subsequent option has an invalid parameter, the error = msg + * will display the wrong location. Avoid this by not merging the list= s. + */ + .merge_lists =3D false, + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_action_opts.head), + .desc =3D { + /* Validation is done when processing the runstate actions */ + { } + }, +}; + /** * Get machine options * @@ -2948,6 +2964,7 @@ void qemu_init(int argc, char **argv, char **envp) qemu_add_opts(&qemu_icount_opts); qemu_add_opts(&qemu_semihosting_config_opts); qemu_add_opts(&qemu_fw_cfg_opts); + qemu_add_opts(&qemu_action_opts); module_call_init(MODULE_INIT_OPTS); =20 runstate_init(); @@ -3420,6 +3437,12 @@ void qemu_init(int argc, char **argv, char **envp) } watchdog =3D optarg; break; + case QEMU_OPTION_action: + if (runstate_action_parse(qemu_find_opts("action"), + optarg) < 0) { + exit(1); + } + break; case QEMU_OPTION_watchdog_action: if (select_watchdog_action(optarg) =3D=3D -1) { error_report("unknown -watchdog-action parameter"); @@ -3902,6 +3925,11 @@ void qemu_init(int argc, char **argv, char **envp) qemu_opts_foreach(qemu_find_opts("name"), parse_name, NULL, &error_fatal); =20 + if (qemu_opts_foreach(qemu_find_opts("action"), + process_runstate_actions, NULL, &error_fatal)) { + exit(1); + } + #ifndef _WIN32 qemu_opts_foreach(qemu_find_opts("add-fd"), parse_add_fd, NULL, &error_fatal); --=20 1.8.3.1 From nobody Tue May 21 11:44:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1607455698; cv=none; d=zohomail.com; s=zohoarc; b=bQYMVzxNV1UG/FuF/E3auwE8PM1PNGqAn0d25qq4Cf9ELmlrwUDYPWjEUeLj2l0fubXBsYZU+DIWVp9d+Uq2utQxIWMBsoat4afAWQOICkUG8hwvafnl7eEFsBQpYX/X1tkWL+z6M3YSkwPZqsVtDbIly1QueqOjB6rk3DTjBh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607455698; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ExN+tFiH8ci654jF68vXB+1ZOCnGFJ4J8cj8AtKmyuE=; b=gfivSe+SUIOn+H/Fjq+RVX7utGfO2sPrg7ubTzA142xeW86n9ATPAE2RmClFh2LpmOGIgPRo7UsGeVp9L1de1w/sA1Ycp0yMdCBmgQyotCMp1WD2j9HybCYy5i//u3jJtm3bEmGyM2KTR4mn92Ttb8PjWecB6g0Yx/IF249fvmg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607455698399318.5081292852434; Tue, 8 Dec 2020 11:28:18 -0800 (PST) Received: from localhost ([::1]:46932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmien-0008Vz-8a for importer@patchew.org; Tue, 08 Dec 2020 14:28:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmiTx-0000H4-KQ for qemu-devel@nongnu.org; Tue, 08 Dec 2020 14:17:06 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:58176) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmiTt-0007oe-Rw for qemu-devel@nongnu.org; Tue, 08 Dec 2020 14:17:04 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B8J9x0k029390; Tue, 8 Dec 2020 19:16:59 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 3581mqvhhm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 08 Dec 2020 19:16:59 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B8JAVVk140153; Tue, 8 Dec 2020 19:14:58 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 358m3y5wjf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Dec 2020 19:14:58 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0B8JEw3U031456; Tue, 8 Dec 2020 19:14:58 GMT Received: from ban25x6uut148.us.oracle.com (/10.153.73.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 08 Dec 2020 11:14:58 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=ExN+tFiH8ci654jF68vXB+1ZOCnGFJ4J8cj8AtKmyuE=; b=MCHaq1L2+d3R0kVlS70qUrhTlc9qu/Go5v3H6aBYtczON5fd/8LhbblizAt8nNAi3wlg 5EbE3/DNN1XX5nxDBl0wDups2Cee8D8skcnBGOnVJDrBZo1eJI2FiajQ/+/Z6V9rIjM1 bUWH2M/LkiK9sF0+2RMFaIea+J6C8hB/dfZhbm5tIE+YxxynnqeRxUp+VW9DulrWibxE vgekvVPpCUcBkov10YHtGutJkZRHzbhkFw01wVXN9hl0/ks8muUtUuLs5PFzk5J/jWoO pTPWYQb+4TTkhbVNeMlKleVecMkeqsLrKFr+hcBjNyh2ermU1xs8OJQRK8aco7Z1+ON/ lQ== From: Alejandro Jimenez To: qemu-devel@nongnu.org Subject: [PATCH 2/4] vl: Add option to avoid stopping VM upon guest panic Date: Tue, 8 Dec 2020 14:14:48 -0500 Message-Id: <1607454890-3339-3-git-send-email-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607454890-3339-1-git-send-email-alejandro.j.jimenez@oracle.com> References: <1607454890-3339-1-git-send-email-alejandro.j.jimenez@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9829 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080117 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9829 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 clxscore=1011 malwarescore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 impostorscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080117 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=alejandro.j.jimenez@oracle.com; helo=userp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The current default action of pausing a guest after a panic event is received leaves the responsibility to resume guest execution to the management layer. The reasons for this behavior are discussed here: https://lore.kernel.org/qemu-devel/52148F88.5000509@redhat.com/ However, in instances like the case of older guests (Linux and Windows) using a pvpanic device but missing support for the PVPANIC_CRASHLOADED event, and Windows guests using the hv-crash enlightenment, it is desirable to allow the guests to continue running after sending a PVPANIC_PANICKED event. This allows such guests to proceed to capture a crash dump and automatically reboot without intervention of a management layer. Add an option to avoid stopping a VM after a panic event is received, by passing: -action panic=3Dnone in the command line arguments, or during runtime by using an upcoming QMP command. Suggested-by: Paolo Bonzini Signed-off-by: Alejandro Jimenez Reviewed-by: David Edmondson Reviewed-by: Liam Merwick --- include/sysemu/sysemu.h | 1 + qapi/run-state.json | 27 ++++++++++++++++++++++++++- qemu-options.hx | 3 +++ softmmu/runstate-action.c | 22 ++++++++++++++++++++++ softmmu/vl.c | 14 +++++++++++--- 5 files changed, 63 insertions(+), 4 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 5480e61..863142e 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -45,6 +45,7 @@ extern int ctrl_grab; extern int graphic_rotate; extern int no_reboot; extern int no_shutdown; +extern int pause_on_panic; extern int old_param; extern int boot_menu; extern bool boot_strict; diff --git a/qapi/run-state.json b/qapi/run-state.json index 6b033c1..27b62ce 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -337,12 +337,14 @@ # # @shutdown: Guest shutdown # +# @panic: Guest has panicked +# # @watchdog: A watchdog device's timer has expired # # Since: 6.0 ## { 'enum': 'RunStateEventType', - 'data': [ 'reboot', 'shutdown', 'watchdog' ] } + 'data': [ 'reboot', 'shutdown', 'panic', 'watchdog' ] } =20 ## # @RunStateAction: @@ -358,6 +360,7 @@ 'data': { 'reboot': 'RunStateRebootAction', 'shutdown': 'RunStateShutdownAction', + 'panic': 'RunStatePanicAction', 'watchdog': 'RunStateWatchdogAction' } } =20 ## @@ -407,6 +410,28 @@ 'data': [ 'pause', 'poweroff' ] } =20 ## +# @RunStatePanicAction: +# +# @action: Action taken by QEMU when guest panicks +# +# Since: 6.0 +## +{ 'struct': 'RunStatePanicAction', + 'data': { 'action': 'PanicAction' } } + +## +# @PanicAction: +# +# @none: Continue VM execution +# +# @pause: Pause the VM +# +# Since: 6.0 +## +{ 'enum': 'PanicAction', + 'data': [ 'none', 'pause' ] } + +## # @RunStateWatchdogAction: # # @action: Action taken by QEMU when watchdog device timer expires diff --git a/qemu-options.hx b/qemu-options.hx index a0d50f0..8b7d8bb 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3899,6 +3899,8 @@ DEF("action", HAS_ARG, QEMU_OPTION_action, " action when guest reboots [default=3Dnone]\n" "-action shutdown=3Dpoweroff|pause\n" " action when guest shuts down [default=3Dpoweroff]\= n" + "-action panic=3Dpause|none\n" + " action when guest panics [default=3Dpause]\n" "-action watchdog=3Dreset|shutdown|poweroff|inject-nmi|pause|debug|non= e\n" " action when watchdog fires [default=3Dreset]\n", QEMU_ARCH_ALL) @@ -3911,6 +3913,7 @@ SRST =20 Examples: =20 + ``-action panic=3Dnone`` ``-action reboot=3Dshutdown,shutdown=3Dpause`` ``-watchdog i6300esb -action watchdog=3Dpause`` =20 diff --git a/softmmu/runstate-action.c b/softmmu/runstate-action.c index bbbbc07..9c92595 100644 --- a/softmmu/runstate-action.c +++ b/softmmu/runstate-action.c @@ -62,6 +62,24 @@ static void qmp_shutdown_set_action(ShutdownAction act, = Error **errp) } =20 /* + * Set the internal state to react to a guest panic event + * as specified by the action parameter. + */ +static void qmp_panic_set_action(PanicAction action, Error **errp) +{ + switch (action) { + case PANIC_ACTION_NONE: + pause_on_panic =3D 0; + break; + case PANIC_ACTION_PAUSE: + pause_on_panic =3D 1; + break; + default: + g_assert_not_reached(); + } +} + +/* * Process an event|action pair and set the appropriate internal * state if event and action are valid. */ @@ -81,6 +99,10 @@ static int set_runstate_action(void *opaque, const char = *event, act_idx =3D qapi_enum_parse(&ShutdownAction_lookup, action, -1, er= rp); qmp_shutdown_set_action(act_idx, NULL); break; + case RUN_STATE_EVENT_TYPE_PANIC: + act_idx =3D qapi_enum_parse(&PanicAction_lookup, action, -1, errp); + qmp_panic_set_action(act_idx, NULL); + break; case RUN_STATE_EVENT_TYPE_WATCHDOG: if (select_watchdog_action(action) =3D=3D -1) { error_report("unknown watchdog action parameter"); diff --git a/softmmu/vl.c b/softmmu/vl.c index 2b1583e..20f89cb 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -150,6 +150,7 @@ int singlestep =3D 0; int fd_bootchk =3D 1; int no_reboot; int no_shutdown =3D 0; +int pause_on_panic =3D 1; int graphic_rotate =3D 0; const char *watchdog; QEMUOptionRom option_rom[MAX_OPTION_ROMS]; @@ -1449,9 +1450,16 @@ void qemu_system_guest_panicked(GuestPanicInformatio= n *info) if (current_cpu) { current_cpu->crash_occurred =3D true; } - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, - !!info, info); - vm_stop(RUN_STATE_GUEST_PANICKED); + + if (pause_on_panic) { + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, + !!info, info); + vm_stop(RUN_STATE_GUEST_PANICKED); + } else { + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_RUN, + !!info, info); + } + if (!no_shutdown) { qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF, !!info, info); --=20 1.8.3.1 From nobody Tue May 21 11:44:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1607455410; cv=none; d=zohomail.com; s=zohoarc; b=Vc0dfGufGywzTrDJq2hFUrlHXwKOEFynyM/TfIDX8LxYs+wDOgf4DHN/z2PSfMb2s/qXkCMzOdLn4sxuxYO4Z5UMArL5X3zJ+L4MCXESAicKMUndtal9LK/k0z7mmL4SUMCra9IEkERek9e3Z/qbDfzFRz3QGydXjMJtjTQQqXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607455410; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=WpBu+h6zx2OWrB4QyP0nWA4cWe8kbsktFYEr6Jg3Qd8=; b=WtJcNtm9R6aW8QwdfezgZXh8lYnlbajfn7xzMqvLhFaKpEuw3J/CVCdS4NJP2/VMpa3vjAKPpWymy04wVzpV8zAI3pEWc1ZNqu9nDFiMdBm6jIvVqrOYXpaYKia/Mi5ntkHxDT1WUSAqAOLSKWd+ZoYsPdwGRBblWNGwrLoZkCU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607455410722861.2112302318542; Tue, 8 Dec 2020 11:23:30 -0800 (PST) Received: from localhost ([::1]:36672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmia9-000476-Bs for importer@patchew.org; Tue, 08 Dec 2020 14:23:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmiS7-0007su-R6 for qemu-devel@nongnu.org; Tue, 08 Dec 2020 14:15:14 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:48648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmiS1-0007Tk-Jy for qemu-devel@nongnu.org; Tue, 08 Dec 2020 14:15:11 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B8J9IVP098393; Tue, 8 Dec 2020 19:15:00 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 35825m4jtx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 08 Dec 2020 19:15:00 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B8JAV1L140299; Tue, 8 Dec 2020 19:15:00 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 358m3y5wjw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Dec 2020 19:15:00 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0B8JEwIH028391; Tue, 8 Dec 2020 19:14:59 GMT Received: from ban25x6uut148.us.oracle.com (/10.153.73.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 08 Dec 2020 11:14:58 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=WpBu+h6zx2OWrB4QyP0nWA4cWe8kbsktFYEr6Jg3Qd8=; b=MvK61hJZVGzIKbFHJSgWfgHnlSRndDF6VAOSEF90aVLvDsxaSTpYS3YRZVzmt/2rDgCw AciiFdkVJQpxNhXDDT7YhjWH4kn7TWFo5ifg3V9BefzP3b/LPdeAece0iKS9E7YfL4dN eMg9iVSsvIGJnHBTSRFvrxqswN3NxJhd90bw/k7Bc1XLaFGPEYfwzRz6rbUzL+PL0shf kxu0pkEJa9s41e99ruf6xl1ceGj8pOtVZOJVelv1awpmb3ATWsCCyC+eGoEEZ5wTb3jI T106JaYoiynnuu+zm/sLEZZt/rS9FmSdL+w/5Z1HGtm7H8yvvZo+TlfQAd7yYm1RGaAq Tg== From: Alejandro Jimenez To: qemu-devel@nongnu.org Subject: [PATCH 3/4] qmp: Allow setting -action parameters on the fly Date: Tue, 8 Dec 2020 14:14:49 -0500 Message-Id: <1607454890-3339-4-git-send-email-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607454890-3339-1-git-send-email-alejandro.j.jimenez@oracle.com> References: <1607454890-3339-1-git-send-email-alejandro.j.jimenez@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9829 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=1 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080117 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9829 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 bulkscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 mlxscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080117 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=141.146.126.78; envelope-from=alejandro.j.jimenez@oracle.com; helo=aserp2120.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add QMP commands to allow for the behaviors specified by the -action event=3Daction command line option to be set at runtime, mimicking the watchdog-set-action QMP command. Suggested-by: Paolo Bonzini Signed-off-by: Alejandro Jimenez Reviewed-by: David Edmondson Reviewed-by: Liam Merwick --- qapi/run-state.json | 27 +++++++++++++++++++++++++++ softmmu/runstate-action.c | 6 +++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/qapi/run-state.json b/qapi/run-state.json index 27b62ce..de27516 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -451,6 +451,33 @@ { 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} } =20 ## +# @reboot-set-action: +# +# Set reboot action +# +# Since: 6.0 +## +{ 'command': 'reboot-set-action', 'data' : {'action': 'RebootAction'} } + +## +# @shutdown-set-action: +# +# Set shutdown action +# +# Since: 6.0 +## +{ 'command': 'shutdown-set-action', 'data' : {'action': 'ShutdownAction'} } + +## +# @panic-set-action: +# +# Set panic action +# +# Since: 6.0 +## +{ 'command': 'panic-set-action', 'data' : {'action': 'PanicAction'} } + +## # @GUEST_PANICKED: # # Emitted when guest OS panic is detected diff --git a/softmmu/runstate-action.c b/softmmu/runstate-action.c index 9c92595..aef23b8 100644 --- a/softmmu/runstate-action.c +++ b/softmmu/runstate-action.c @@ -29,7 +29,7 @@ static void runstate_action_help(void) * Set the internal state to react to a guest reboot event * as specified by the action parameter. */ -static void qmp_reboot_set_action(RebootAction act, Error **errp) +void qmp_reboot_set_action(RebootAction act, Error **errp) { switch (act) { case REBOOT_ACTION_NONE: @@ -47,7 +47,7 @@ static void qmp_reboot_set_action(RebootAction act, Error= **errp) * Set the internal state to react to a guest shutdown event * as specified by the action parameter. */ -static void qmp_shutdown_set_action(ShutdownAction act, Error **errp) +void qmp_shutdown_set_action(ShutdownAction act, Error **errp) { switch (act) { case SHUTDOWN_ACTION_PAUSE: @@ -65,7 +65,7 @@ static void qmp_shutdown_set_action(ShutdownAction act, E= rror **errp) * Set the internal state to react to a guest panic event * as specified by the action parameter. */ -static void qmp_panic_set_action(PanicAction action, Error **errp) +void qmp_panic_set_action(PanicAction action, Error **errp) { switch (action) { case PANIC_ACTION_NONE: --=20 1.8.3.1 From nobody Tue May 21 11:44:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1607455634; cv=none; d=zohomail.com; s=zohoarc; b=bLuGyzn+0P0hpDwQxUjkOy154m0dvnS5Oke3IN2MKA5glIV2rIfqo4yGp4p6rSdY0oEzRFRPJ6Xy/nwfz9fefzbVZBhAQHNrjba7oexQmzhZoZSa+fzUZyim669x+FYcNSY9orUaNyVFiYdvOMiQQUA+cdFrULLC9R3scr1+ZYs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607455634; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=hEapBxrb93rMy2MDuYbpH09EASrOKbuHVY2y3SczyCA=; b=g2DRQrn7HloLfizMk/VTV2mqI1shTQgX7lCxWHRmeDR0bUL8wS+nP3hNFvfbJTLraCYfdj8cuLFh/eFfdyFEsuiiPZSRpr5sOsLKPjsor7sWLJp/edeUufFQr3uyxg8xsC1uzGDUc1TS8DUJ9Ny6cRpApOWcnP0D7F5wGdkFbHw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607455634233612.1944752532346; Tue, 8 Dec 2020 11:27:14 -0800 (PST) Received: from localhost ([::1]:43780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmidl-0007Cx-1r for importer@patchew.org; Tue, 08 Dec 2020 14:27:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmiTy-0000HR-Tg for qemu-devel@nongnu.org; Tue, 08 Dec 2020 14:17:08 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:38712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmiTu-0007om-VY for qemu-devel@nongnu.org; Tue, 08 Dec 2020 14:17:06 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B8J9J4k107124; Tue, 8 Dec 2020 19:17:01 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 357yqbvp10-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 08 Dec 2020 19:17:01 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B8JAeGs015803; Tue, 8 Dec 2020 19:15:00 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 358kytcvb8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Dec 2020 19:15:00 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0B8JExew028398; Tue, 8 Dec 2020 19:15:00 GMT Received: from ban25x6uut148.us.oracle.com (/10.153.73.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 08 Dec 2020 11:14:59 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=hEapBxrb93rMy2MDuYbpH09EASrOKbuHVY2y3SczyCA=; b=M4Q5ImuyFU4a/GVoDKXEQU5dkqiytNRHjTVZTAGbXSp2dmWz+hE1wQcW6YL8E2hdH5sr DMenb4Wjh+46zsL6pKJRtyFkfSfM9LhCTbP93rrpIAoqGR3DGUrGrAqpm4+OZ9EaGRqh uolOE/ras2BGdMzRJu54A0pQZPdeXFXs9iNzRNjogKX6iR6Z5mnAj2CEcDJhhrMGSKy9 VJej5GagcGGQ3es71rhP38XmYURtv3ig8RCwc4tgjqwC/jr4TaG7FqEDE/uvbDsMbN9b H8DJg0CoFT5jJOuuAVJstGp5oCo7ouexYWS6p0kYZavWPEMs0SO22NqMvxU/Ppmb+3i+ Nw== From: Alejandro Jimenez To: qemu-devel@nongnu.org Subject: [PATCH 4/4] qtest/pvpanic: Test panic option that allows VM to continue Date: Tue, 8 Dec 2020 14:14:50 -0500 Message-Id: <1607454890-3339-5-git-send-email-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607454890-3339-1-git-send-email-alejandro.j.jimenez@oracle.com> References: <1607454890-3339-1-git-send-email-alejandro.j.jimenez@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9829 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxscore=0 malwarescore=0 suspectscore=1 mlxlogscore=999 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080117 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9829 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 mlxlogscore=999 clxscore=1015 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 spamscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080117 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=141.146.126.79; envelope-from=alejandro.j.jimenez@oracle.com; helo=aserp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Test the scenario where the -action panic=3Dnone parameter is used to signal that the VM must continue executing after a guest panic occurs. Suggested-by: Paolo Bonzini Signed-off-by: Alejandro Jimenez Reviewed-by: David Edmondson Reviewed-by: Liam Merwick --- tests/qtest/pvpanic-test.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c index 016b32e..6dcad2d 100644 --- a/tests/qtest/pvpanic-test.c +++ b/tests/qtest/pvpanic-test.c @@ -11,13 +11,36 @@ #include "libqos/libqtest.h" #include "qapi/qmp/qdict.h" =20 +static void test_panic_nopause(void) +{ + uint8_t val; + QDict *response, *data; + QTestState *qts; + + qts =3D qtest_init("-device pvpanic -action panic=3Dnone"); + + val =3D qtest_inb(qts, 0x505); + g_assert_cmpuint(val, =3D=3D, 3); + + qtest_outb(qts, 0x505, 0x1); + + response =3D qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED"); + g_assert(qdict_haskey(response, "data")); + data =3D qdict_get_qdict(response, "data"); + g_assert(qdict_haskey(data, "action")); + g_assert_cmpstr(qdict_get_str(data, "action"), =3D=3D, "run"); + qobject_unref(response); + + qtest_quit(qts); +} + static void test_panic(void) { uint8_t val; QDict *response, *data; QTestState *qts; =20 - qts =3D qtest_init("-device pvpanic"); + qts =3D qtest_init("-device pvpanic -action panic=3Dpause"); =20 val =3D qtest_inb(qts, 0x505); g_assert_cmpuint(val, =3D=3D, 3); @@ -40,6 +63,7 @@ int main(int argc, char **argv) =20 g_test_init(&argc, &argv, NULL); qtest_add_func("/pvpanic/panic", test_panic); + qtest_add_func("/pvpanic/panic-nopause", test_panic_nopause); =20 ret =3D g_test_run(); =20 --=20 1.8.3.1