From patchwork Tue Sep 5 11:10:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Privoznik X-Patchwork-Id: 9938461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E4F12600CB for ; Tue, 5 Sep 2017 11:12:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D825C288CB for ; Tue, 5 Sep 2017 11:12:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD19828943; Tue, 5 Sep 2017 11:12:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 73708288CB for ; Tue, 5 Sep 2017 11:12:08 +0000 (UTC) Received: from localhost ([::1]:58135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpBm3-0003rX-Om for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Sep 2017 07:12:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpBkk-0003R8-SQ for qemu-devel@nongnu.org; Tue, 05 Sep 2017 07:10:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpBka-0000Ec-T3 for qemu-devel@nongnu.org; Tue, 05 Sep 2017 07:10:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59370) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpBka-0000Cd-Mr for qemu-devel@nongnu.org; Tue, 05 Sep 2017 07:10:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E743B61483 for ; Tue, 5 Sep 2017 11:10:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E743B61483 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=mprivozn@redhat.com Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CBDB82431; Tue, 5 Sep 2017 11:10:33 +0000 (UTC) From: Michal Privoznik To: qemu-devel@nongnu.org Date: Tue, 5 Sep 2017 13:10:31 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 05 Sep 2017 11:10:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] watchdog: Allow setting action on the fly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, the only time that users can set watchdog action is at the start as all we expose is this -watchdog-action command line argument. This is suboptimal when users want to plug the device later via monitor. Alternatively, they might want to change the action for already existing device on the fly. Inspired by: https://bugzilla.redhat.com/show_bug.cgi?id=1447169 Signed-off-by: Michal Privoznik --- hw/watchdog/watchdog.c | 9 +++++++++ qapi-schema.json | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c index 0c5c9cde1c..971f05c61a 100644 --- a/hw/watchdog/watchdog.c +++ b/hw/watchdog/watchdog.c @@ -29,6 +29,8 @@ #include "qapi-event.h" #include "hw/nmi.h" #include "qemu/help_option.h" +#include "qmp-commands.h" +#include "qapi/qmp/qerror.h" static int watchdog_action = WDT_RESET; static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list; @@ -147,3 +149,10 @@ void watchdog_perform_action(void) break; } } + +void qmp_watchdog_set_action(const char *action, Error **errp) +{ + if (select_watchdog_action(action) == -1) { + error_setg(errp, QERR_INVALID_PARAMETER, action); + } +} diff --git a/qapi-schema.json b/qapi-schema.json index 802ea53d00..be81ffc0bb 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -6539,3 +6539,12 @@ # Since 2.9 ## { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' } + +## +# @watchdog-set-action: +# +# Set watchdog action +# +# Since 2.11 +## +{ 'command': 'watchdog-set-action', 'data' : {'action': 'str'} }