From patchwork Mon Jan 1 05:16:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 854294 X-Patchwork-Delegate: jpettit@nicira.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z95D469rbz9t84 for ; Mon, 1 Jan 2018 16:22:12 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id DB826CED; Mon, 1 Jan 2018 05:17:08 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id EB28ECE8 for ; Mon, 1 Jan 2018 05:17:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E792C14B for ; Mon, 1 Jan 2018 05:17:06 +0000 (UTC) X-Originating-IP: 173.228.112.64 Received: from sigabrt.gateway.sonic.net (173-228-112-64.dsl.dynamic.fusionbroadband.com [173.228.112.64]) (Authenticated sender: blp@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id B3A2DC5A53; Mon, 1 Jan 2018 06:17:04 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Sun, 31 Dec 2017 21:16:37 -0800 Message-Id: <20180101051640.13043-12-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20180101051640.13043-1-blp@ovn.org> References: <20180101051640.13043-1-blp@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 12/15] ovsdb-client: Add --timeout option. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Signed-off-by: Ben Pfaff Reviewed-by: Yifeng Sun Acked-by: Justin Pettit --- NEWS | 1 + ovsdb/ovsdb-client.1.in | 6 ++++++ ovsdb/ovsdb-client.c | 12 ++++++++++++ tests/ovs-macros.at | 4 ++++ 4 files changed, 23 insertions(+) diff --git a/NEWS b/NEWS index dfc2fb7728a4..646879c61677 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ Post-v2.8.0 ovsdb-server(5) for more details. * ovsdb-client: New "get-schema-cksum" and "query" commands. * ovsdb-client: New "backup" and "restore" commands. + * ovsdb-client: New --timeout option. * ovsdb-tool: New "db-name" and "schema-name" commands. - ovs-vsctl and other commands that display data in tables now support a --max-column-width option to limit column width. diff --git a/ovsdb/ovsdb-client.1.in b/ovsdb/ovsdb-client.1.in index 56d4797e933c..727e9c6e0651 100644 --- a/ovsdb/ovsdb-client.1.in +++ b/ovsdb/ovsdb-client.1.in @@ -313,6 +313,12 @@ table update. Most output formats add the timestamp on a line of its own just above the table. The JSON output format puts the timestamp in a member of the top-level JSON object named \fBtime\fR. . +.IP "\fB\-t\fR" +.IQ "\fB\-\-timeout=\fIsecs\fR" +Limits \fBovsdb\-client\fR runtime to approximately \fIsecs\fR +seconds. If the timeout expires, \fBovsdb\-client\fR will exit with a +\fBSIGALRM\fR signal. +. .SS "Daemon Options" The daemon options apply only to the \fBmonitor\fR and \fBmonitor\-cond\fR commands. With any other command, they have no effect. diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index a7cab600c98b..b00f04147d39 100644 --- a/ovsdb/ovsdb-client.c +++ b/ovsdb/ovsdb-client.c @@ -213,6 +213,7 @@ parse_options(int argc, char *argv[]) {"force", no_argument, NULL, OPT_FORCE}, {"db-change-aware", no_argument, &db_change_aware, 1}, {"no-db-change-aware", no_argument, &db_change_aware, 0}, + {"timeout", required_argument, NULL, 't'}, VLOG_LONG_OPTIONS, DAEMON_LONG_OPTIONS, #ifdef HAVE_OPENSSL @@ -227,6 +228,7 @@ parse_options(int argc, char *argv[]) table_style.format = TF_TABLE; for (;;) { + unsigned long int timeout; int c; c = getopt_long(argc, argv, short_options, long_options, NULL); @@ -259,6 +261,16 @@ parse_options(int argc, char *argv[]) force = true; break; + case 't': + timeout = strtoul(optarg, NULL, 10); + if (timeout <= 0) { + ovs_fatal(0, "value %s on -t or --timeout is not at least 1", + optarg); + } else { + time_alarm(timeout); + } + break; + case '?': exit(EXIT_FAILURE); diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 56d0a3bca86d..82df193871b3 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -122,6 +122,7 @@ if [ $? -eq 0 ]; then alias ovn-sbctl='OVS_SBCTL_TIMEOUT' alias ovn-nbctl='OVN_NBCTL_TIMEOUT' alias vtep-ctl='VTEP_CTL_TIMEOUT' + alias ovsdb-client='OVSDB_CLIENT_TIMEOUT' OVS_OFCTL_TIMEOUT () { command ovs-ofctl --timeout=$OVS_TIMEOUT "$@" } @@ -137,6 +138,9 @@ if [ $? -eq 0 ]; then VTEP_CTL_TIMEOUT () { command vtep-ctl --timeout=$OVS_TIMEOUT "$@" } + OVSDB_CLIENT_TIMEOUT () { + command ovsdb-client --timeout=$OVS_TIMEOUT "$@" + } fi # parent_pid PID