From patchwork Thu Jul 12 13:40:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943041 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHBp47jZz9rxx for ; Thu, 12 Jul 2018 23:40:50 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D97C1CB9; Thu, 12 Jul 2018 13:40:23 +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 B72D1CB9 for ; Thu, 12 Jul 2018 13:40:22 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B99174FA for ; Thu, 12 Jul 2018 13:40:20 +0000 (UTC) Received: by mail-wm0-f46.google.com with SMTP id w16-v6so5675727wmc.2 for ; Thu, 12 Jul 2018 06:40:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0SfbUdIAaNgOTbl9njp79hcC8Wv7UG54qNM01M4rhIY=; b=FoyA+7F0BXRoWOPYLnbOBekxmyW7LTjS1bWykTQ8srax4XldP29Fj6ZDcSboZWgVwH sBKU3486G+EE+Gw3yMNgaNEAOfNscDPL7AHrSdMPYMBWskF1KXKcvYsyURQRtyP5P8mg m5P2KN9v8f4f9gM8eNVJ874jGA9s8muvUXSZmSeXBvSNqDPLYsIcCPa6fOjUz79HSLgA imwe/Ej1i14gLitHX+vQvcAGNRO/tsH2AgQUZdt7PJaCd/vKYPHeKL2WpHgZsXWrz1sI 2pwWYcvvPXlm1/6MqTT/svKyZ5O0KA+tmI/wqH6XP5PZERt0JmsOaklvgaXZHbfJh3Dz uZvw== X-Gm-Message-State: AOUpUlEVueHTLzzbbN3Gx4e31K1GJyFS9aK+kTqHcDhdCilUTUaB6JVU kZWt/QVpoQPtswj/FsKy2l8VDoa+HII= X-Google-Smtp-Source: AAOMgpfEBtxBrY9vlhvk5CH3dpnweOJccBnBUOvXYmF7+zieddIoNNbXw7eoSDNnFGYlwkoH6v74jQ== X-Received: by 2002:a1c:8291:: with SMTP id e139-v6mr1545946wmd.39.1531402819265; Thu, 12 Jul 2018 06:40:19 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id v5-v6sm11027411wru.60.2018.07.12.06.40.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:18 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:02 +0200 Message-Id: <20180712134016.14336-2-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 01/15] table: Introduce a constant for default table style. 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 Having a constant in addition to the constant expression for the default table style allows us to reset 'struct table_style' variables to default style. Signed-off-by: Jakub Sitnicki --- lib/table.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/table.h b/lib/table.h index 313ac1dd2..76e65bb70 100644 --- a/lib/table.h +++ b/lib/table.h @@ -20,6 +20,7 @@ #include #include #include "compiler.h" +#include "openvswitch/json.h" struct ds; struct table_style; @@ -83,6 +84,7 @@ struct table_style { }; #define TABLE_STYLE_DEFAULT { TF_LIST, CF_STRING, true, JSSF_SORT, 0 } +static const struct table_style table_style_default = TABLE_STYLE_DEFAULT; #define TABLE_OPTION_ENUMS \ OPT_NO_HEADINGS, \ From patchwork Thu Jul 12 13:40:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943045 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHCM4WpGz9rxx for ; Thu, 12 Jul 2018 23:41:19 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id ADBACCD8; Thu, 12 Jul 2018 13:40:24 +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 DD6A8CB9 for ; Thu, 12 Jul 2018 13:40:22 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 62BB576A for ; Thu, 12 Jul 2018 13:40:22 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id h9-v6so21769209wro.3 for ; Thu, 12 Jul 2018 06:40:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wuT3+IW4vYRIuBgOmE2eoHhtP2E6vL8N5bb7cDqebec=; b=LsBH8ERKMVICq2EhMToGCPr4T9FGy7BQFZceKJmIoauvygiDJdNOmjrm7nLdC5WJh1 f6sT7/obcYOFOmkaoygRj3P6Fmpul9Ilk0LTHRaUlfWws9ay2crcR7WsbOQ5iBDTWO72 UFoVD5tFaA6i1Uhs1YdLDGi4A/pZ6IH7UbWymVs1Yzqt2wyAhk3EUJ+70zqj5qlj6qby 5FpwrjyYSQMOV5ICwhinSV8KjoJbLaHkkf2/P73VfnrhCAHjIIlKJIMcmA9QBsEMcYke vrik7/uaJMdd4xLlZkY8St95Md7ZMUZHuA3qd9t9coi3/jYuAVyBTewGwbnSafpFgnxR 5G0g== X-Gm-Message-State: AOUpUlHNqptAsNVDvDcLSe01eETxLpN5u6g8t+O2QxCMzC2yVwGw8s5b AMpCskqeRCj+ikEvnlxc1TjHh1EKkDM= X-Google-Smtp-Source: AAOMgpdbpzxGd4lxIHdcNc43XxVwVEfFKlRUf/xn6dOXbEDr/FcYvboGHfFqowXTXY8tIbVv6xHyLA== X-Received: by 2002:adf:ef03:: with SMTP id e3-v6mr1722981wro.182.1531402820780; Thu, 12 Jul 2018 06:40:20 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id w135-v6sm11844237wme.7.2018.07.12.06.40.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:20 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:03 +0200 Message-Id: <20180712134016.14336-3-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 02/15] ovsdb-idl: Allow monitoring columns that are already monitored. 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 If IDL was created with monitoring and alerts turned on by default for all columns, then there is no harm in allowing the API users to ask again for monitoring and alerts to be enabled for any given column. This allows us to run prerequisites handlers for db-ctl and ovn-nbctl commands once the IDL has already ran once. Signed-off-by: Jakub Sitnicki --- lib/ovsdb-idl.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index 9ab5d6723..ae0a55c3a 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -1116,6 +1116,20 @@ ovsdb_idl_db_get_mode(struct ovsdb_idl_db *db, return &table->modes[column - table->class_->columns]; } +static void +ovsdb_idl_db_set_mode(struct ovsdb_idl_db *db, + const struct ovsdb_idl_column *column, + unsigned char mode) +{ + const struct ovsdb_idl_table *table = ovsdb_idl_table_from_column(db, + column); + size_t column_idx = column - table->class_->columns; + + if (table->modes[column_idx] != mode) { + *ovsdb_idl_db_get_mode(db, column) = mode; + } +} + static void add_ref_table(struct ovsdb_idl_db *db, const struct ovsdb_base_type *base) { @@ -1136,7 +1150,7 @@ static void ovsdb_idl_db_add_column(struct ovsdb_idl_db *db, const struct ovsdb_idl_column *column) { - *ovsdb_idl_db_get_mode(db, column) = OVSDB_IDL_MONITOR | OVSDB_IDL_ALERT; + ovsdb_idl_db_set_mode(db, column, OVSDB_IDL_MONITOR | OVSDB_IDL_ALERT); add_ref_table(db, &column->type.key); add_ref_table(db, &column->type.value); } From patchwork Thu Jul 12 13:40:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943046 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHD06Wn6z9rxx for ; Thu, 12 Jul 2018 23:41:52 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 65D79CF7; Thu, 12 Jul 2018 13:40:26 +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 2E2AECD9 for ; Thu, 12 Jul 2018 13:40:25 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id F12B8771 for ; Thu, 12 Jul 2018 13:40:23 +0000 (UTC) Received: by mail-wr1-f41.google.com with SMTP id q10-v6so21758740wrd.4 for ; Thu, 12 Jul 2018 06:40:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eW8QL+SA2oAIAVJJouqT1NLBQS16FoZ7pTl+jdQBoDM=; b=j1h8/haz5KQJcp+Zr8g52OoGuYEqNmKjlev+VB5qZp6ZbifGeMWDdld6JOunw6walV R/lyI382mqJd1M+aE20QMQZcyV/cvN+IOa9iiWV80a5RpezAJLQhHKvjeFcyrwXJescX OPPrxmUIYLFVAE66Q36tnkWTB7Z/VB8hul2/ZrygWswMu9JB9x0hKzWj22lcPycc72Sk 6NytZAp8QEr5sVU5gNa635tAxMjor39bjnyi2+RKvjb9yh51C2Fp/mmpJoOMWQgm0VYv yDrcv7sXOfJphifYr6K3oONm3IxSXICt3xX+BedGNRKDHD6IBDupM5g5NYnHMinvIKMZ +Yxg== X-Gm-Message-State: AOUpUlGHkRKYIsXTY7Gbw9yXuMP/pcNSI0cPLPTyg3bdi4m24MMHg0eT lnCQh3GQMoi2ySQWRcZZGcbm1RwyOck= X-Google-Smtp-Source: AAOMgpdEW1Q2gEdVXpOBRAQDTtb7jwexsGZoKoe1ZPq82VdzOP5VpXdx+zDIS6CTuQ236GpVxpRKBg== X-Received: by 2002:adf:8f4a:: with SMTP id p68-v6mr1807619wrb.22.1531402822395; Thu, 12 Jul 2018 06:40:22 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id u63-v6sm5825710wme.22.2018.07.12.06.40.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:21 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:04 +0200 Message-Id: <20180712134016.14336-4-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 03/15] ovn-nbctl: Extract the main loop. 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 Split out a routine for the main ovn-nbctl loop. Preparatory work for introducing daemon mode. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 47df19b23..a027553b7 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -88,6 +88,8 @@ static bool do_nbctl(const char *args, struct ctl_command *, size_t n, struct ovsdb_idl *); static const struct nbrec_dhcp_options *dhcp_options_get( struct ctl_context *ctx, const char *id, bool must_exist); +static void main_loop(const char *args, struct ctl_command *commands, + size_t n_commands, struct ovsdb_idl *idl); int main(int argc, char *argv[]) @@ -95,7 +97,6 @@ main(int argc, char *argv[]) struct ovsdb_idl *idl; struct ctl_command *commands; struct shash local_options; - unsigned int seqno; size_t n_commands; set_program_name(argv[0]); @@ -123,6 +124,18 @@ main(int argc, char *argv[]) ovsdb_idl_set_leader_only(idl, leader_only); run_prerequisites(commands, n_commands, idl); + main_loop(args, commands, n_commands, idl); + + free(args); + exit(EXIT_SUCCESS); +} + +static void +main_loop(const char *args, struct ctl_command *commands, size_t n_commands, + struct ovsdb_idl *idl) +{ + unsigned int seqno; + /* Execute the commands. * * 'seqno' is the database sequence number for which we last tried to @@ -136,14 +149,13 @@ main(int argc, char *argv[]) if (!ovsdb_idl_is_alive(idl)) { int retval = ovsdb_idl_get_last_error(idl); ctl_fatal("%s: database connection failed (%s)", - db, ovs_retval_to_string(retval)); + db, ovs_retval_to_string(retval)); } if (seqno != ovsdb_idl_get_seqno(idl)) { seqno = ovsdb_idl_get_seqno(idl); if (do_nbctl(args, commands, n_commands, idl)) { - free(args); - exit(EXIT_SUCCESS); + return; } } From patchwork Thu Jul 12 13:40:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943047 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHDd5JXcz9s1R for ; Thu, 12 Jul 2018 23:42:25 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 239C0CEF; Thu, 12 Jul 2018 13:40:27 +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 B9824D07 for ; Thu, 12 Jul 2018 13:40:26 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 891694FA for ; Thu, 12 Jul 2018 13:40:25 +0000 (UTC) Received: by mail-wr1-f50.google.com with SMTP id a3-v6so12537115wrt.2 for ; Thu, 12 Jul 2018 06:40:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6+pIEnsjDbhPX4E+KjQ2Ks5ojGlh1XccI7EgGwqUzm8=; b=BAyIqAUv+6p5Wb7vZZrF0EmYxNaGUBl6VbWANRtVQhkzfay39BUVpa8KuSYa9onF0m E4CEZBfBkecIe3+HcKt4KU87DMWHanA1hkSIsiGCdhACAI4ihfO5TlEEV1zrJ2Zlytfl O4F5IKLUrHRzh68N+cXp6Mr3uE5vYEB3OQJmFVB5DzqJyhqtk7akP47uHkNueUJgOP1M m2MdSjpHTIqO3SMrcTMoqs/jiG+2e19aBzBVXHpQjzZvlVm3Dz2GaLalBQQPXuwJxp6t 1wzsWL9DtaP2sIeQKnz7YiMOdI+pxTAMupOR0LlViR5b25lPV5x9aUDghXzaaqyza9Og Bhsg== X-Gm-Message-State: AOUpUlEnZc6H5qtghOqDVrjKitgfMD7K5Ab9bAIPDk8BybdrfqqLPPEL smqCkv4spjAhmnOcy1eVQG3gyeGi+no= X-Google-Smtp-Source: AAOMgpfKD/OwB8GnmxqBQK+p5HBxIACb8VbqGTjlF/ploqaeB+NW3/0hOrjPY6A6GdASMpTzzXrbLQ== X-Received: by 2002:adf:96c3:: with SMTP id u61-v6mr1803833wrb.72.1531402823990; Thu, 12 Jul 2018 06:40:23 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id c10-v6sm21443775wrs.6.2018.07.12.06.40.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:23 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:05 +0200 Message-Id: <20180712134016.14336-5-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 04/15] ovn-nbctl: Pull up destroying commands from do_nbctl(). 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 Destroy commands in the same routine where they were allocated. Preparatory work for reusing the main loop in daemon mode. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index a027553b7..51527741b 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -126,6 +126,13 @@ main(int argc, char *argv[]) main_loop(args, commands, n_commands, idl); + for (struct ctl_command *c = commands; c < &commands[n_commands]; c++) { + ds_destroy(&c->output); + table_destroy(c->table); + free(c->table); + shash_destroy_free_data(&c->options); + } + free(commands); free(args); exit(EXIT_SUCCESS); } @@ -4271,13 +4278,7 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, } else { fputs(ds_cstr(ds), stdout); } - ds_destroy(&c->output); - table_destroy(c->table); - free(c->table); - - shash_destroy_free_data(&c->options); } - free(commands); if (wait_type != NBCTL_WAIT_NONE && status != TXN_UNCHANGED) { ovsdb_idl_enable_reconnect(idl); From patchwork Thu Jul 12 13:40:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943049 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHFT4hp2z9s1R for ; Thu, 12 Jul 2018 23:43:09 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 07233D2A; Thu, 12 Jul 2018 13:40:30 +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 8B02DD1E for ; Thu, 12 Jul 2018 13:40:27 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0D72A4FA for ; Thu, 12 Jul 2018 13:40:26 +0000 (UTC) Received: by mail-wr1-f48.google.com with SMTP id c4-v6so9087767wrs.12 for ; Thu, 12 Jul 2018 06:40:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pxKWi5+pOX80hJROYOcWfAVOe/s4QnwiG4+fddWZ/Es=; b=H5aNNL2Qk3KF75Qb5+Oyhckw1bav+PBHgJJprNgmB3eSQcWJY57j2RBEPv6PHzjDIJ iAxeYd7zUXZsJ15+GoXY8Fpkl4hlDLu4Mlz9fTjNVhdHp7sosEuETk2s0p5GxHBe/FUX XMCIpim0x/YYWMWIYlZDB29Ve4tIGLRGvm3jeWR3+UBCQrYYjwYf1B+5ySShLg+nsWmS tJijD664sbJNi2aKRfsu3Ui8PSK54ksBzZBvKxj3YNUbKs5Dwxh2f8rFGQbPN7bYnwHN TP5k/moxUULgQjWpWnuDnMt6KhNrod9HX6VlIhevaWM9KQWX0yxsEdtsuh3xnx2emJKG 9Ggg== X-Gm-Message-State: AOUpUlFO5ZjeIOgMUzt5/XpmMz5C7wkjjuwn8ZKykWH7oyo80VhkyFu2 DxP81f6jwmxOLS9lWdDeLgbCG2Klzww= X-Google-Smtp-Source: AAOMgpdkbswE0rAff4Qgs6v90rU5D2nZqYGXh5g8tuEgmpY8H2vKjExPIXrHIrQjU1y+5W0bqkTLew== X-Received: by 2002:adf:e9c1:: with SMTP id l1-v6mr1766300wrn.14.1531402825555; Thu, 12 Jul 2018 06:40:25 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id c7-v6sm40999899wre.73.2018.07.12.06.40.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:25 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:06 +0200 Message-Id: <20180712134016.14336-6-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 05/15] ovn-nbctl: Pull up releasing IDL from do_nbctl(). 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 Destroy IDL resources in the routine where we allocated them. Preparatory work for reusing the main loop in daemon mode. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 51527741b..a700695fe 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -126,6 +126,9 @@ main(int argc, char *argv[]) main_loop(args, commands, n_commands, idl); + ovsdb_idl_destroy(idl); + idl = the_idl = NULL; + for (struct ctl_command *c = commands; c < &commands[n_commands]; c++) { ds_destroy(&c->output); table_destroy(c->table); @@ -4299,7 +4302,6 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, } ovsdb_idl_txn_destroy(txn); - ovsdb_idl_destroy(idl); return true; From patchwork Thu Jul 12 13:40:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943050 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHG34SZ2z9rxx for ; Thu, 12 Jul 2018 23:43:39 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F0111D37; Thu, 12 Jul 2018 13:40:31 +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 EDA63D27 for ; Thu, 12 Jul 2018 13:40:29 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6AD3176A for ; Thu, 12 Jul 2018 13:40:29 +0000 (UTC) Received: by mail-wm0-f43.google.com with SMTP id s12-v6so5737217wmc.1 for ; Thu, 12 Jul 2018 06:40:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+PQf2NbS8RkFzMyvsF7I/s0QkSSgaOO8vtEtXAbqO9s=; b=L9JPm/BRna0VQ+qm2Zbs5OhBL38H6Si9ur8TFyfKBX5qrsEpdj+YR04dAkn+DD2uAM 2O9Jf3metcvlnZ57jE/hK6KGCr9l7kJ3BCv4CJXIrEdQUK1kaLzRQ/Ux6bxxckBhVw6M JYn1I3nyS4kdnQVNWssbDZyxCg82V+c3oftnqBgOaXp8m4wIr4V5Zwu3Oq8IkUxdANjI bW06PbLRZ+ot9rZyAZopBhMP2rhS4J0gp7G0zl8mkgTv4fby/VBleoiiklkQsNwnmdxz /rX9T6qXKREW/zWBKEPoZn7We4UwiNbidaMs9k6/Ne0zsxi8fniHjFPOmn40CB78cDEL eCtw== X-Gm-Message-State: AOUpUlH8MSqllOkZqaGe2bXmfh6e5bddOe+yw4ncm4GA8Oin37lE5zqH ivkmQYtQi8WmtcmaQYgxBJoyF/CiHvY= X-Google-Smtp-Source: AAOMgpdoPi1hmWF0nC5mHglpaNd2/IXSvZ3ey6YPJR1EDs34vu+Fhxs8hMaM/leY9N67u8lkR2nRHQ== X-Received: by 2002:a1c:2142:: with SMTP id h63-v6mr1449147wmh.51.1531402827916; Thu, 12 Jul 2018 06:40:27 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id j11-v6sm26217818wrr.37.2018.07.12.06.40.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:26 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:07 +0200 Message-Id: <20180712134016.14336-7-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 06/15] ovn-nbctl: Signal need to try again via an output param. 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 Introduce an output parameter for the flag that signals need to retry running the command. This leaves the return value for error reporting. Preparatory work for reusing the main loop in daemon mode. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index a700695fe..360b25a89 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -84,8 +84,8 @@ OVS_NO_RETURN static void usage(void); static void parse_options(int argc, char *argv[], struct shash *local_options); static void run_prerequisites(struct ctl_command[], size_t n_commands, struct ovsdb_idl *); -static bool do_nbctl(const char *args, struct ctl_command *, size_t n, - struct ovsdb_idl *); +static void do_nbctl(const char *args, struct ctl_command *, size_t n, + struct ovsdb_idl *, bool *retry); static const struct nbrec_dhcp_options *dhcp_options_get( struct ctl_context *ctx, const char *id, bool must_exist); static void main_loop(const char *args, struct ctl_command *commands, @@ -164,7 +164,10 @@ main_loop(const char *args, struct ctl_command *commands, size_t n_commands, if (seqno != ovsdb_idl_get_seqno(idl)) { seqno = ovsdb_idl_get_seqno(idl); - if (do_nbctl(args, commands, n_commands, idl)) { + + bool retry; + do_nbctl(args, commands, n_commands, idl, &retry); + if (!retry) { return; } } @@ -4134,9 +4137,9 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands, } } -static bool +static void do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, - struct ovsdb_idl *idl) + struct ovsdb_idl *idl, bool *retry) { struct ovsdb_idl_txn *txn; enum ovsdb_idl_txn_status status; @@ -4146,6 +4149,8 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, struct shash_node *node; int64_t next_cfg = 0; + ovs_assert(retry); + txn = the_idl_txn = ovsdb_idl_txn_create(idl); if (dry_run) { ovsdb_idl_txn_set_dry_run(txn); @@ -4303,7 +4308,8 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, ovsdb_idl_txn_destroy(txn); - return true; + *retry = false; + return; try_again: /* Our transaction needs to be rerun, or a prerequisite was not met. Free @@ -4318,7 +4324,7 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, table_destroy(c->table); free(c->table); } - return false; + *retry = true; } /* Frees the current transaction and the underlying IDL and then calls From patchwork Thu Jul 12 13:40:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943051 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHGb3mqGz9rxx for ; Thu, 12 Jul 2018 23:44:07 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A8888D36; Thu, 12 Jul 2018 13:40:34 +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 B436DD2F for ; Thu, 12 Jul 2018 13:40:31 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 122EC76F for ; Thu, 12 Jul 2018 13:40:31 +0000 (UTC) Received: by mail-wr1-f49.google.com with SMTP id j5-v6so15232332wrr.8 for ; Thu, 12 Jul 2018 06:40:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PVOT2BukTxFiIYIY9Bhpb+5zfNgWlYFWC44rgCeOj6c=; b=Qt2iofhicgiXtyRejsAVrkbchMuEcRjw8kULJDmK1kuVsKpWKbd4mdPUW6//bYF5XT bhChc5R13AGPLuI8lfPtCsjwCL1YYXHZ3Gp+INbd3NyQvIQ3un8gdY6vbM/mR9CvZn/0 s3b2+7Mahxv31kKyoJWUOc8iFEzJiQaSlfjqdnuDmC/bpsZe9af150W6BmYJ0ndZwKyv 8ZEDfqzuNfl3iq7tidzViJ9CPI94sgx9qW0N/vsesxt5vvudO6LLbjCDfpsnq8yJ0GB2 dWICFMmhIArasaW0bXMkhXVYlfeClX7tNHfbFpqciJbT1sV+D6blOZyuXXs/71r1nUlz Ffrw== X-Gm-Message-State: AOUpUlF6dyrj0ArPbaqSF9b+5KjFg1iuMKicW91ZPORKYwrMcVokdcPn /78Qz3FR2DYusH06+zLernP7kIE3Vdg= X-Google-Smtp-Source: AAOMgpdKX0w63MpR7CYE5GhgTH19uPvul1EDfGwM+GPnHuRuyYKesOsqA2lfJ0w6gi+CN5V25urJlA== X-Received: by 2002:adf:8877:: with SMTP id e52-v6mr1954561wre.30.1531402829531; Thu, 12 Jul 2018 06:40:29 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id 185-v6sm7879628wmh.22.2018.07.12.06.40.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:28 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:08 +0200 Message-Id: <20180712134016.14336-8-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 07/15] ovn-nbctl: Propagate the error from do_nbctl(). 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 Instead of terminating the process, return the error to the caller. This will allow us to reuse the main loop in daemon mode. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 360b25a89..6e136e1d0 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -84,8 +84,9 @@ OVS_NO_RETURN static void usage(void); static void parse_options(int argc, char *argv[], struct shash *local_options); static void run_prerequisites(struct ctl_command[], size_t n_commands, struct ovsdb_idl *); -static void do_nbctl(const char *args, struct ctl_command *, size_t n, - struct ovsdb_idl *, bool *retry); +static char * OVS_WARN_UNUSED_RESULT do_nbctl(const char *args, + struct ctl_command *, size_t n, + struct ovsdb_idl *, bool *retry); static const struct nbrec_dhcp_options *dhcp_options_get( struct ctl_context *ctx, const char *id, bool must_exist); static void main_loop(const char *args, struct ctl_command *commands, @@ -166,7 +167,10 @@ main_loop(const char *args, struct ctl_command *commands, size_t n_commands, seqno = ovsdb_idl_get_seqno(idl); bool retry; - do_nbctl(args, commands, n_commands, idl, &retry); + char *error = do_nbctl(args, commands, n_commands, idl, &retry); + if (error) { + ctl_fatal("%s", error); + } if (!retry) { return; } @@ -4137,7 +4141,7 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands, } } -static void +static char * do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, struct ovsdb_idl *idl, bool *retry) { @@ -4148,6 +4152,7 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, struct ctl_command *c; struct shash_node *node; int64_t next_cfg = 0; + char *error = NULL; ovs_assert(retry); @@ -4181,7 +4186,9 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, (c->syntax->run)(&ctx); } if (ctx.error) { - ctl_fatal("%s", ctx.error); + error = xstrdup(ctx.error); + ctl_context_done(&ctx, c); + goto out_error; } ctl_context_done_command(&ctx, c); @@ -4195,9 +4202,10 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, SHASH_FOR_EACH (node, &symtab->sh) { struct ovsdb_symbol *symbol = node->data; if (!symbol->created) { - ctl_fatal("row id \"%s\" is referenced but never created (e.g. " - "with \"-- --id=%s create ...\")", - node->name, node->name); + error = xasprintf("row id \"%s\" is referenced but never created " + "(e.g. with \"-- --id=%s create ...\")", + node->name, node->name); + goto out_error; } if (!symbol->strong_ref) { if (!symbol->weak_ref) { @@ -4222,7 +4230,9 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, ctl_context_init(&ctx, c, idl, txn, symtab, NULL); (c->syntax->postprocess)(&ctx); if (ctx.error) { - ctl_fatal("%s", ctx.error); + error = xstrdup(ctx.error); + ctl_context_done(&ctx, c); + goto out_error; } ctl_context_done(&ctx, c); } @@ -4236,7 +4246,8 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, case TXN_ABORTED: /* Should not happen--we never call ovsdb_idl_txn_abort(). */ - ctl_fatal("transaction aborted"); + error = xstrdup("transaction aborted"); + goto out_error; case TXN_UNCHANGED: case TXN_SUCCESS: @@ -4246,11 +4257,14 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, goto try_again; case TXN_ERROR: - ctl_fatal("transaction error: %s", ovsdb_idl_txn_get_error(txn)); + error = xasprintf("transaction error: %s", + ovsdb_idl_txn_get_error(txn)); + goto out_error; case TXN_NOT_LOCKED: /* Should not happen--we never call ovsdb_idl_set_lock(). */ - ctl_fatal("database not locked"); + error = xstrdup("database not locked"); + goto out_error; default: OVS_NOT_REACHED(); @@ -4309,11 +4323,14 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, ovsdb_idl_txn_destroy(txn); *retry = false; - return; + return NULL; try_again: /* Our transaction needs to be rerun, or a prerequisite was not met. Free * resources and return so that the caller can try again. */ + *retry = true; + +out_error: ovsdb_idl_txn_abort(txn); ovsdb_idl_txn_destroy(txn); the_idl_txn = NULL; @@ -4324,7 +4341,8 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, table_destroy(c->table); free(c->table); } - *retry = true; + + return error; } /* Frees the current transaction and the underlying IDL and then calls From patchwork Thu Jul 12 13:40:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943052 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHH51wlDz9rxx for ; Thu, 12 Jul 2018 23:44:33 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 79DEFD3D; Thu, 12 Jul 2018 13:40:35 +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 EFE91D32 for ; Thu, 12 Jul 2018 13:40:32 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 733FF76A for ; Thu, 12 Jul 2018 13:40:32 +0000 (UTC) Received: by mail-wm0-f42.google.com with SMTP id w16-v6so5676237wmc.2 for ; Thu, 12 Jul 2018 06:40:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DS+vRToPFcrL1cxulJGQ0TJDm8UfBsmxjUVDtkhi6MM=; b=d5WgKpI2ZXT5TZ/cxBZEGcZQPIKynUWAPzllWW35X/lGKrY4wgBq5rc+/Ttms09+id jFNYOAq/HPVIjiMaoJ/n6aW2umg3RC70noew01iEjrVrYhSW6h4OiCqov5jEiXxEQ7GQ MQVslJuu8SMYgkL3eLNQ6DuHCXPsY1fpP5pXzEbl5mIi7qk1wBbQWMozDm9gV0YLGR7i GzFi9X8ZEq/Gg/iAdfw4j7sUfUWvcsA7NPYI6MtsmqoX3Lt/cDAGwr+nBTEX1GfJXCHd hV4VwQbkyW09TRT2+B/AQgxGE+cWUZEZXCYn9r3wcj02UWog0LiDezajZPOILevIoItH 1APA== X-Gm-Message-State: AOUpUlHwK8aZ+cbAxjjY2g0fdIj9CqREDviIpAdXbWMpJJoTDNEfVjcV +AXzhZ4xNaG/wsbQBchz1co8YHrDm4k= X-Google-Smtp-Source: AAOMgpcB7sA+aGGSUXog+v8pFdhcgGhnhZram98LiX/EK005NWfrLb9IMi9PjyMvdV6rVy6J71mx4A== X-Received: by 2002:a1c:864c:: with SMTP id i73-v6mr1514185wmd.40.1531402830977; Thu, 12 Jul 2018 06:40:30 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id w4-v6sm6083927wrt.40.2018.07.12.06.40.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:30 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:09 +0200 Message-Id: <20180712134016.14336-9-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 08/15] ovn-nbctl: Propagate errors from the main loop. 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 Let the caller handle the errors instead of reporting it and terminating. Prepare for reusing the main loop in daemon mode. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 6e136e1d0..747aa63b6 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -89,8 +89,10 @@ static char * OVS_WARN_UNUSED_RESULT do_nbctl(const char *args, struct ovsdb_idl *, bool *retry); static const struct nbrec_dhcp_options *dhcp_options_get( struct ctl_context *ctx, const char *id, bool must_exist); -static void main_loop(const char *args, struct ctl_command *commands, - size_t n_commands, struct ovsdb_idl *idl); +static char * OVS_WARN_UNUSED_RESULT main_loop(const char *args, + struct ctl_command *commands, + size_t n_commands, + struct ovsdb_idl *idl); int main(int argc, char *argv[]) @@ -125,7 +127,10 @@ main(int argc, char *argv[]) ovsdb_idl_set_leader_only(idl, leader_only); run_prerequisites(commands, n_commands, idl); - main_loop(args, commands, n_commands, idl); + char *error = main_loop(args, commands, n_commands, idl); + if (error) { + ctl_fatal("%s", error); + } ovsdb_idl_destroy(idl); idl = the_idl = NULL; @@ -141,7 +146,7 @@ main(int argc, char *argv[]) exit(EXIT_SUCCESS); } -static void +static char * main_loop(const char *args, struct ctl_command *commands, size_t n_commands, struct ovsdb_idl *idl) { @@ -169,10 +174,10 @@ main_loop(const char *args, struct ctl_command *commands, size_t n_commands, bool retry; char *error = do_nbctl(args, commands, n_commands, idl, &retry); if (error) { - ctl_fatal("%s", error); + return error; } if (!retry) { - return; + return NULL; } } @@ -181,6 +186,8 @@ main_loop(const char *args, struct ctl_command *commands, size_t n_commands, poll_block(); } } + + return NULL; } static void From patchwork Thu Jul 12 13:40:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943053 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHHh2YCwz9rxx for ; Thu, 12 Jul 2018 23:45:04 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4B714D3A; Thu, 12 Jul 2018 13:40:37 +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 B656CD3C for ; Thu, 12 Jul 2018 13:40:34 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4765A4FA for ; Thu, 12 Jul 2018 13:40:34 +0000 (UTC) Received: by mail-wm0-f46.google.com with SMTP id v25-v6so5731739wmc.0 for ; Thu, 12 Jul 2018 06:40:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XSiLMlQSkrr13ba23H0kZgB8E0U67NehF3mkbPyZeo4=; b=V945eb5BhUgIKReiFUlnJz/cJfKJkIhZD9FEH+g9xXLS/uw2kHh/wde53bxhB8qR5/ QQcF2te3j7GIKVsNnzPHwBVWNft/y0TNEvccUYF9qC7/QXjW5gTeWHrgFqr67wd6jENm i0bWhCm4VQswocX9Z8gkAah5dNp4cRAxDg9N7N8Rcp8/Ki7qDtYgzCtH8GUBEorqS4Gz u0CnU/n9jxhi/mzPQtpOIMZcjh4i/ap5XLMx6IOT9Y6h2oLcMlcOfi6ZdQXJcAAYTm8d mAAvN4Ov3st0S/rUOvTwhM6tvE9PLUVbuLtwysySqgPHk+GOUJkw83wIsyVXTZzdTJ9+ cnlA== X-Gm-Message-State: AOUpUlGMIbILIZI+3ts3n0xXBmKh9xzCuz3x7GVRG8JEU7Icrj2Em8CR ljO8kUKBSxGk1EwS5PiX+5rAU2AotJA= X-Google-Smtp-Source: AAOMgpeVz9UZ8bidCzYwIaDEp6+2wGqMNNjYrqCKE14Zx1HOKsaRnpbsfyKDDFPnyizn4OEaNmb7bg== X-Received: by 2002:a1c:ed0d:: with SMTP id l13-v6mr1479431wmh.73.1531402832671; Thu, 12 Jul 2018 06:40:32 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id s16-v6sm18201689wrq.20.2018.07.12.06.40.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:32 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:10 +0200 Message-Id: <20180712134016.14336-10-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 09/15] ovn-nbctl: Propagate errors from prerequisites runner. 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 Instead of terminating the process, return the error to the caller. This will allow us to reuse the prerequisites runner in daemon mode. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 747aa63b6..154e7799a 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -82,8 +82,9 @@ static int leader_only = true; static void nbctl_cmd_init(void); OVS_NO_RETURN static void usage(void); static void parse_options(int argc, char *argv[], struct shash *local_options); -static void run_prerequisites(struct ctl_command[], size_t n_commands, - struct ovsdb_idl *); +static char * OVS_WARN_UNUSED_RESULT run_prerequisites(struct ctl_command[], + size_t n_commands, + struct ovsdb_idl *); static char * OVS_WARN_UNUSED_RESULT do_nbctl(const char *args, struct ctl_command *, size_t n, struct ovsdb_idl *, bool *retry); @@ -101,6 +102,7 @@ main(int argc, char *argv[]) struct ctl_command *commands; struct shash local_options; size_t n_commands; + char *error; set_program_name(argv[0]); fatal_ignore_sigpipe(); @@ -125,9 +127,12 @@ main(int argc, char *argv[]) /* Initialize IDL. */ idl = the_idl = ovsdb_idl_create(db, &nbrec_idl_class, true, false); ovsdb_idl_set_leader_only(idl, leader_only); - run_prerequisites(commands, n_commands, idl); + error = run_prerequisites(commands, n_commands, idl); + if (error) { + ctl_fatal("%s", error); + } - char *error = main_loop(args, commands, n_commands, idl); + error = main_loop(args, commands, n_commands, idl); if (error) { ctl_fatal("%s", error); } @@ -4117,7 +4122,7 @@ static const struct ctl_table_class tables[NBREC_N_TABLES] = { [NBREC_TABLE_ACL].row_ids[0] = {&nbrec_acl_col_name, NULL, NULL}, }; -static void +static char * run_prerequisites(struct ctl_command *commands, size_t n_commands, struct ovsdb_idl *idl) { @@ -4138,7 +4143,9 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands, ctl_context_init(&ctx, c, idl, NULL, NULL, NULL); (c->syntax->prerequisites)(&ctx); if (ctx.error) { - ctl_fatal("%s", ctx.error); + char *error = xstrdup(ctx.error); + ctl_context_done(&ctx, c); + return error; } ctl_context_done(&ctx, c); @@ -4146,6 +4153,8 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands, ovs_assert(!c->table); } } + + return NULL; } static char * From patchwork Thu Jul 12 13:40:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943054 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHJD39n1z9rxx for ; Thu, 12 Jul 2018 23:45:32 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 03048D54; Thu, 12 Jul 2018 13:40:38 +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 82B69D1E for ; Thu, 12 Jul 2018 13:40:36 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id EBBC976A for ; Thu, 12 Jul 2018 13:40:35 +0000 (UTC) Received: by mail-wm0-f47.google.com with SMTP id i139-v6so5677971wmf.4 for ; Thu, 12 Jul 2018 06:40:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WuMrQQB9HPGhcqwstHJimbLvwY1mJxoslq7hNt+99wQ=; b=kkipVjMORuAfVOzLIynRu3E8GZhkEOWeqL2DJt438RnWPD3+SBu7euhhlg9wlE0T6Z dyK30jwzuWrTdiBijObL5YEzsDH8hLUVZwduMAnwjoAY77SXpjWWGMo5YHP8RBDcvgtM 118/rPtErTY2IGOHzBlyYRyIvj0NoUrhMvExvl2+tTBUMmB1GrRX1CfykRsTXq5QO4Ie WWKXoKt5vqWH2a7pSSdWfL08sVBNM2VPKJGC6y0/Yf7NEoCJ2fToqsFETCyy6dyVEgC0 dLznSDpEM+WuoY/uDPcCvrHPjD9k1DBOgbsOy1W1Ze/vxJD47rj/YRwPdbjuIpsE5BiL KQ7Q== X-Gm-Message-State: AOUpUlEqNVDugpXfpyDZdJfVNEOtxWhCSqAqWhe9DO29qztgd09DMc92 PsN2rmHT7ztHohcpmcLdTODzYhVsvi0= X-Google-Smtp-Source: AAOMgpeWE8Sk7+tG/0KvOvNt00AOy3s8mBKCSJ3RMwM41563LGRJUiWI0olIjNSK7jiNsGcujwabKA== X-Received: by 2002:a1c:149:: with SMTP id 70-v6mr1513407wmb.2.1531402834417; Thu, 12 Jul 2018 06:40:34 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id r125-v6sm3393825wmb.27.2018.07.12.06.40.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:33 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:11 +0200 Message-Id: <20180712134016.14336-11-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 10/15] ovn-nbctl: Introduce a poll_timer based wait timeout. 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 Extend the main loop and the command runner so that the caller can specify a timeout for poll_block(). This will allow us to break out of the main loop when waiting on IDL, like in the blocked '--wait=sb/hv sync' case. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 154e7799a..7f83abc40 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -37,6 +37,7 @@ #include "svec.h" #include "table.h" #include "timeval.h" +#include "timer.h" #include "util.h" #include "openvswitch/vlog.h" @@ -87,13 +88,16 @@ static char * OVS_WARN_UNUSED_RESULT run_prerequisites(struct ctl_command[], struct ovsdb_idl *); static char * OVS_WARN_UNUSED_RESULT do_nbctl(const char *args, struct ctl_command *, size_t n, - struct ovsdb_idl *, bool *retry); + struct ovsdb_idl *, + const struct timer *, + bool *retry); static const struct nbrec_dhcp_options *dhcp_options_get( struct ctl_context *ctx, const char *id, bool must_exist); static char * OVS_WARN_UNUSED_RESULT main_loop(const char *args, struct ctl_command *commands, size_t n_commands, - struct ovsdb_idl *idl); + struct ovsdb_idl *idl, + const struct timer *); int main(int argc, char *argv[]) @@ -132,7 +136,7 @@ main(int argc, char *argv[]) ctl_fatal("%s", error); } - error = main_loop(args, commands, n_commands, idl); + error = main_loop(args, commands, n_commands, idl, NULL); if (error) { ctl_fatal("%s", error); } @@ -153,7 +157,7 @@ main(int argc, char *argv[]) static char * main_loop(const char *args, struct ctl_command *commands, size_t n_commands, - struct ovsdb_idl *idl) + struct ovsdb_idl *idl, const struct timer *wait_timeout) { unsigned int seqno; @@ -177,7 +181,8 @@ main_loop(const char *args, struct ctl_command *commands, size_t n_commands, seqno = ovsdb_idl_get_seqno(idl); bool retry; - char *error = do_nbctl(args, commands, n_commands, idl, &retry); + char *error = do_nbctl(args, commands, n_commands, idl, + wait_timeout, &retry); if (error) { return error; } @@ -4159,7 +4164,7 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands, static char * do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, - struct ovsdb_idl *idl, bool *retry) + struct ovsdb_idl *idl, const struct timer *wait_timeout, bool *retry) { struct ovsdb_idl_txn *txn; enum ovsdb_idl_txn_status status; @@ -4286,8 +4291,6 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, OVS_NOT_REACHED(); } - ovsdb_symbol_table_destroy(symtab); - for (c = commands; c < &commands[n_commands]; c++) { struct ds *ds = &c->output; @@ -4331,11 +4334,19 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, } } ovsdb_idl_wait(idl); + if (wait_timeout) { + timer_wait(wait_timeout); + } poll_block(); + if (wait_timeout && timer_expired(wait_timeout)) { + error = xstrdup("timeout expired"); + goto out_error; + } } done: ; } + ovsdb_symbol_table_destroy(symtab); ovsdb_idl_txn_destroy(txn); *retry = false; From patchwork Thu Jul 12 13:40:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943055 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHJm6G15z9s2M for ; Thu, 12 Jul 2018 23:46:00 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A1500D60; Thu, 12 Jul 2018 13:40:39 +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 E712FD53 for ; Thu, 12 Jul 2018 13:40:37 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5D27176A for ; Thu, 12 Jul 2018 13:40:37 +0000 (UTC) Received: by mail-wr1-f41.google.com with SMTP id t6-v6so21749839wrn.7 for ; Thu, 12 Jul 2018 06:40:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7inGvLT4xTVfZkr51qX57I+CItNdf29qG5qE/A2NhvE=; b=Z2rGPfso1cZyB0YF+/zQP6+eTSfIbjWc+BHL0ouuCjL9CylZYKdNgq0qiGoMzDHniM 0y+DC2BPXwl3KXiLKHSQ3lZWpP5GuBJxVSExtcKwzAgxGYg8Ox/+DfjaG+v8DnR8QxEY gLYgQrWRMGBvK1WL3G6bD18jEvsS2+TIkdWS3ceTymu6VY0aaQQgvvfViQTCDXrtlOpG bIpyD+dcUD3hOS0+ET6a2M7z+7mxhYaFbcHKAK2uKhdHErRvNiMWMWfeZ8zfQRkZu93v 9h5YH6wxvxluAdPSbyvaGSkVEI6j4eGQiyq0dM9PIlIVhLMDmZu6mdD06lm3G4YIDPmi reaw== X-Gm-Message-State: AOUpUlFG0fNdYW4X+hfNWfiy6uMQteMdBstLt5gh1gN8Yiqgt0M5BYmX O+WW8UuMwirwwrEOKNpLSUzrJsaO9o4= X-Google-Smtp-Source: AAOMgpfRygOlzrp7MEWg9AD7/i5rhh+SrpGai1eqFbORKDQxgq1dp6FY/yqPPzC1e576mKHuptQ50g== X-Received: by 2002:adf:83c6:: with SMTP id 64-v6mr1410368wre.5.1531402835903; Thu, 12 Jul 2018 06:40:35 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id t6-v6sm4766902wrn.97.2018.07.12.06.40.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:35 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:12 +0200 Message-Id: <20180712134016.14336-12-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 11/15] ovn-nbctl: Extract helper for printing oneline output. 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 This will allow us to direct oneline-formatted output to other sinks than stdout if needed. Preparatory work for daemon mode. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.c | 53 ++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 7f83abc40..3dd24d193 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -4162,6 +4162,39 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands, return NULL; } +static void +oneline_format(struct ds *lines, struct ds *s) +{ + size_t j; + + ds_chomp(lines, '\n'); + for (j = 0; j < lines->length; j++) { + int ch = lines->string[j]; + switch (ch) { + case '\n': + ds_put_cstr(s, "\\n"); + break; + + case '\\': + ds_put_cstr(s, "\\\\"); + break; + + default: + ds_put_char(s, ch); + } + } + ds_put_char(s, '\n'); +} + +static void +oneline_print(struct ds *lines) +{ + struct ds s = DS_EMPTY_INITIALIZER; + oneline_format(lines, &s); + fputs(ds_cstr(&s), stdout); + ds_destroy(&s); +} + static char * do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, struct ovsdb_idl *idl, const struct timer *wait_timeout, bool *retry) @@ -4297,25 +4330,7 @@ do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, if (c->table) { table_print(c->table, &table_style); } else if (oneline) { - size_t j; - - ds_chomp(ds, '\n'); - for (j = 0; j < ds->length; j++) { - int ch = ds->string[j]; - switch (ch) { - case '\n': - fputs("\\n", stdout); - break; - - case '\\': - fputs("\\\\", stdout); - break; - - default: - putchar(ch); - } - } - putchar('\n'); + oneline_print(ds); } else { fputs(ds_cstr(ds), stdout); } From patchwork Thu Jul 12 13:40:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943056 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHKT4Pjyz9s3R for ; Thu, 12 Jul 2018 23:46:37 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8570FD69; Thu, 12 Jul 2018 13:40:41 +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 6CC5CD59 for ; Thu, 12 Jul 2018 13:40:40 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3DD7E76A for ; Thu, 12 Jul 2018 13:40:39 +0000 (UTC) Received: by mail-wr1-f54.google.com with SMTP id q10-v6so21759576wrd.4 for ; Thu, 12 Jul 2018 06:40:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v7FrJhxrrJVPoIQnCyS5s6JgxtHDSx9OrUhsUqCP8Dk=; b=TIYnzRXTEwGv81DzzWYRi+HaYqMxUE7WxrTchcoLw8H9lqby0X9cAAka5cboSvNkt7 Kjd290Jwz9YukfqlLFif4JF5nlfWQJDmhtG5I78CZmOZK6+n90qdL96e+WuSB6s/Jara lrpPIybzo4h1IiWBNKcRGatdA6vepGnXzFqQ0C7gXJAZZfC8vrOELsuUUd4+TMUitOxG EKrEKZEE6CTfbYrJ8gbo7IRh23oAijCdGfwo1DEHoFaiEJuUtAZkg7m9+BJF858EwiOu ad0XcdkRtC8FrsuGEOTQ7wG+hImS65qFMleW7NXj6bgMmUtexLDT4xDBapcq0ry4yJRl lcLA== X-Gm-Message-State: AOUpUlHMGuBMjbDCdp5IcVXbdMM5TmBWbHGv1RoHWMM5i7lxos8bRVmD Ow1P1UBUycJcx7/hoCxb0koau8F2XfU= X-Google-Smtp-Source: AAOMgpfbsCF9Y7JdyLqEncl4+uP+CX+S2bLkY5bjws0USD7SAbEy4XgMpLXehhGoqbz8KSr5pGiJYg== X-Received: by 2002:adf:92a5:: with SMTP id 34-v6mr1957087wrn.83.1531402837576; Thu, 12 Jul 2018 06:40:37 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id 5-v6sm8570538wmv.48.2018.07.12.06.40.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:37 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:13 +0200 Message-Id: <20180712134016.14336-13-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 12/15] ovn-nbctl: Initial support for daemon mode. 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 Make ovn-nbctl act as a unixctl server if we were asked to detach. This turns ovn-nbctl into a long-lived process that acts a proxy for interacting with NB DB. The main difference to regular mode of ovn-nbctl is that in the daemon mode, a local copy of database contents has to be obtained only once. Just two unixctl commands are supported 'run' and 'exit'. The former can be used to run any ovn-nbctl command or a batch of them as so: ovs-appctl -t ovn-nbctl run [OPTIONS] COMMAND [-- [OPTIONS] COMMAND] ... Running commands that have not yet been converted to not use ctl_fatal() will result in death of the daemon process. However, --monitor option can be used to keep the daemon running. Signed-off-by: Jakub Sitnicki --- ovn/utilities/ovn-nbctl.8.xml | 40 ++++++++ ovn/utilities/ovn-nbctl.c | 213 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 227 insertions(+), 26 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.8.xml b/ovn/utilities/ovn-nbctl.8.xml index abba4ecdb..2cd2fab30 100644 --- a/ovn/utilities/ovn-nbctl.8.xml +++ b/ovn/utilities/ovn-nbctl.8.xml @@ -913,6 +913,43 @@ +

Daemon Mode

+ +

+ If ovn-nbctl is invoked with the --detach + option (see Daemon Options, below), it runs in the + background as a daemon and accepts commands from ovs-appctl + (or another JSON-RPC client) indefinitely. The currently supported + commands are described below. +

+ +

+ +

+ +
+
+ run [options] command + [arg...] [-- [options] + command [arg...] ...] +
+
+ Instructs the daemon process to run one or more ovn-nbctl + commands described above and reply with the results of running these + commands. Accepts the --no-wait, --wait, + --timeout, --dry-run, --oneline, + and the options described under Table Formatting Options + in addition to the the command-specific options. +
+ +
exit
+
Causes ovn-nbctl to gracefully terminate.
+
+ +

+ Daemon mode is considered experimental. +

+

Options

@@ -982,6 +1019,9 @@
+

Daemon Options

+ +

Logging options

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 3dd24d193..ba9b7ca49 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -20,6 +20,7 @@ #include #include "command-line.h" +#include "daemon.h" #include "db-ctl-base.h" #include "dirs.h" #include "fatal-signal.h" @@ -38,6 +39,7 @@ #include "table.h" #include "timeval.h" #include "timer.h" +#include "unixctl.h" #include "util.h" #include "openvswitch/vlog.h" @@ -80,6 +82,13 @@ OVS_NO_RETURN static void nbctl_exit(int status); /* --leader-only, --no-leader-only: Only accept the leader in a cluster. */ static int leader_only = true; +/* --unixctl-path: Path to use for unixctl server, for "monitor" and "snoop" + commands. */ +static char *unixctl_path; + +static unixctl_cb_func server_cmd_exit; +static unixctl_cb_func server_cmd_run; + static void nbctl_cmd_init(void); OVS_NO_RETURN static void usage(void); static void parse_options(int argc, char *argv[], struct shash *local_options); @@ -98,15 +107,13 @@ static char * OVS_WARN_UNUSED_RESULT main_loop(const char *args, size_t n_commands, struct ovsdb_idl *idl, const struct timer *); +static void server_loop(struct ovsdb_idl *idl); int main(int argc, char *argv[]) { struct ovsdb_idl *idl; - struct ctl_command *commands; struct shash local_options; - size_t n_commands; - char *error; set_program_name(argv[0]); fatal_ignore_sigpipe(); @@ -119,38 +126,55 @@ main(int argc, char *argv[]) char *args = process_escape_args(argv); shash_init(&local_options); parse_options(argc, argv, &local_options); - commands = ctl_parse_commands(argc - optind, argv + optind, &local_options, - &n_commands); - VLOG(ctl_might_write_to_db(commands, n_commands) ? VLL_INFO : VLL_DBG, - "Called as %s", args); - - if (timeout) { - time_alarm(timeout); - } + argc -= optind; + argv += optind; /* Initialize IDL. */ idl = the_idl = ovsdb_idl_create(db, &nbrec_idl_class, true, false); ovsdb_idl_set_leader_only(idl, leader_only); - error = run_prerequisites(commands, n_commands, idl); - if (error) { - ctl_fatal("%s", error); - } - error = main_loop(args, commands, n_commands, idl, NULL); - if (error) { - ctl_fatal("%s", error); + if (get_detach()) { + if (argc != 0) { + ctl_fatal("non-option arguments not supported with --detach " + "(use --help for help)"); + } + server_loop(idl); + } else { + struct ctl_command *commands; + size_t n_commands; + char *error; + + commands = ctl_parse_commands(argc, argv, &local_options, &n_commands); + VLOG(ctl_might_write_to_db(commands, n_commands) ? VLL_INFO : VLL_DBG, + "Called as %s", args); + + if (timeout) { + time_alarm(timeout); + } + + error = run_prerequisites(commands, n_commands, idl); + if (error) { + ctl_fatal("%s", error); + } + + error = main_loop(args, commands, n_commands, idl, NULL); + if (error) { + ctl_fatal("%s", error); + } + + struct ctl_command *c; + for (c = commands; c < &commands[n_commands]; c++) { + ds_destroy(&c->output); + table_destroy(c->table); + free(c->table); + shash_destroy_free_data(&c->options); + } + free(commands); } ovsdb_idl_destroy(idl); idl = the_idl = NULL; - for (struct ctl_command *c = commands; c < &commands[n_commands]; c++) { - ds_destroy(&c->output); - table_destroy(c->table); - free(c->table); - shash_destroy_free_data(&c->options); - } - free(commands); free(args); exit(EXIT_SUCCESS); } @@ -160,6 +184,7 @@ main_loop(const char *args, struct ctl_command *commands, size_t n_commands, struct ovsdb_idl *idl, const struct timer *wait_timeout) { unsigned int seqno; + bool idl_ready; /* Execute the commands. * @@ -169,6 +194,11 @@ main_loop(const char *args, struct ctl_command *commands, size_t n_commands, * it's because the database changed and we need to obtain an up-to-date * view of the database before we try the transaction again. */ seqno = ovsdb_idl_get_seqno(idl); + + /* IDL might have already obtained the database copy during previous + * invocation. If so, we can't expect the sequence number to change before + * we issue any new requests. */ + idl_ready = ovsdb_idl_has_ever_connected(idl); for (;;) { ovsdb_idl_run(idl); if (!ovsdb_idl_is_alive(idl)) { @@ -177,7 +207,8 @@ main_loop(const char *args, struct ctl_command *commands, size_t n_commands, db, ovs_retval_to_string(retval)); } - if (seqno != ovsdb_idl_get_seqno(idl)) { + if (idl_ready || seqno != ovsdb_idl_get_seqno(idl)) { + idl_ready = false; seqno = ovsdb_idl_get_seqno(idl); bool retry; @@ -214,6 +245,7 @@ parse_options(int argc, char *argv[], struct shash *local_options) OPT_COMMANDS, OPT_OPTIONS, OPT_BOOTSTRAP_CA_CERT, + DAEMON_OPTION_ENUMS, VLOG_OPTION_ENUMS, TABLE_OPTION_ENUMS, SSL_OPTION_ENUMS, @@ -232,6 +264,7 @@ parse_options(int argc, char *argv[], struct shash *local_options) {"leader-only", no_argument, &leader_only, true}, {"no-leader-only", no_argument, &leader_only, false}, {"version", no_argument, NULL, 'V'}, + DAEMON_LONG_OPTIONS, VLOG_LONG_OPTIONS, STREAM_SSL_LONG_OPTIONS, {"bootstrap-ca-cert", required_argument, NULL, OPT_BOOTSTRAP_CA_CERT}, @@ -336,6 +369,7 @@ parse_options(int argc, char *argv[], struct shash *local_options) } break; + DAEMON_OPTION_HANDLERS VLOG_OPTION_HANDLERS TABLE_OPTION_HANDLERS(&table_style) STREAM_SSL_OPTION_HANDLERS @@ -529,6 +563,7 @@ Options:\n\ program_name, program_name, ctl_get_db_cmd_usage(), ctl_list_db_tables_usage(), default_nb_db()); table_usage(); + daemon_usage(); vlog_usage(); printf("\ --no-syslog equivalent to --verbose=nbctl:syslog:warn\n"); @@ -4562,3 +4597,129 @@ nbctl_cmd_init(void) ctl_init(&nbrec_idl_class, nbrec_table_classes, tables, NULL, nbctl_exit); ctl_register_commands(nbctl_commands); } + +static void +server_cmd_exit(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *exiting_) +{ + bool *exiting = exiting_; + *exiting = true; + unixctl_command_reply(conn, NULL); +} + +static void +server_cmd_run(struct unixctl_conn *conn, int argc, const char **argv_, + void *idl_) +{ + struct ovsdb_idl *idl = idl_; + struct ctl_command *commands = NULL; + struct shash local_options; + size_t n_commands = 0; + char *error = NULL; + + /* Copy args so that getopt() can permute them. Leave last entry NULL. */ + char **argv = xcalloc(argc + 1, sizeof *argv); + for (int i = 0; i < argc; i++) { + argv[i] = xstrdup(argv_[i]); + } + + /* Reset global state. */ + oneline = false; + dry_run = false; + wait_type = NBCTL_WAIT_NONE; + force_wait = false; + timeout = 0; + table_style = table_style_default; + + /* Parse commands & options. */ + char *args = process_escape_args(argv); + shash_init(&local_options); + optind = 0; + parse_options(argc, argv, &local_options); + commands = ctl_parse_commands(argc - optind, argv + optind, + &local_options, &n_commands); + VLOG(ctl_might_write_to_db(commands, n_commands) ? VLL_INFO : VLL_DBG, + "Running command %s", args); + + struct timer *wait_timeout = NULL; + struct timer wait_timeout_; + if (timeout) { + wait_timeout = &wait_timeout_; + timer_set_duration(wait_timeout, timeout * 1000); + } + + error = run_prerequisites(commands, n_commands, idl); + if (error) { + unixctl_command_reply_error(conn, error); + goto out; + } + error = main_loop(args, commands, n_commands, idl, wait_timeout); + if (error) { + unixctl_command_reply_error(conn, error); + goto out; + } + + struct ds output = DS_EMPTY_INITIALIZER; + for (struct ctl_command *c = commands; c < &commands[n_commands]; c++) { + if (c->table) { + table_format(c->table, &table_style, &output); + } else if (oneline) { + oneline_format(&c->output, &output); + } else { + ds_put_cstr(&output, ds_cstr_ro(&c->output)); + } + + ds_destroy(&c->output); + table_destroy(c->table); + free(c->table); + } + unixctl_command_reply(conn, ds_cstr_ro(&output)); + ds_destroy(&output); + +out: + free(error); + for (struct ctl_command *c = commands; c < &commands[n_commands]; c++) { + shash_destroy_free_data(&c->options); + } + free(commands); + shash_destroy_free_data(&local_options); + free(args); + for (int i = 0; i < argc; i++) { + free(argv[i]); + } + free(argv); +} + +static void +server_cmd_init(struct ovsdb_idl *idl, bool *exiting) +{ + unixctl_command_register("exit", "", 0, 0, server_cmd_exit, exiting); + unixctl_command_register("run", "", 1, INT_MAX, server_cmd_run, idl); +} + +static void +server_loop(struct ovsdb_idl *idl) +{ + struct unixctl_server *server = NULL; + bool exiting = false; + + daemonize_start(false); + int error = unixctl_server_create(unixctl_path, &server); + if (error) { + ctl_fatal("failed to create unixctl server (%s)", + ovs_retval_to_string(error)); + } + server_cmd_init(idl, &exiting); + + for (;;) { + unixctl_server_run(server); + daemonize_complete(); + unixctl_server_wait(server); + if (exiting) { + break; + } + poll_block(); + } + + unixctl_server_destroy(server); +} From patchwork Thu Jul 12 13:40:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943057 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHL26yylz9s1R for ; Thu, 12 Jul 2018 23:47:06 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3B5CED7D; Thu, 12 Jul 2018 13:40:44 +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 61097D59 for ; Thu, 12 Jul 2018 13:40:41 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D22194FA for ; Thu, 12 Jul 2018 13:40:40 +0000 (UTC) Received: by mail-wr1-f41.google.com with SMTP id q10-v6so21759672wrd.4 for ; Thu, 12 Jul 2018 06:40:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MsksL+AwbxDwEWR/P7+27KiEvSLkPSS4RbSh0oQXE1c=; b=Wgkk5mfVm/0MsGqlm1ujzGsWUuzNmWDDy+7PIG+jmBnYJuT3I/stus+qaDSP1B73f1 XE+ncO2/EKanu8KTZttOVioW8gDUQUIKCKoW/sht1SZk0nKCqFGQxo/NT7QjFlRiiY6/ 4U0+198SY9u7eZKbXwIFfEMFTmuTHLpZ+l8TT2SJX/ecuHWkbZUajgu6Ibnn85cXFUwM qXtPkJGXSGEhfHrmg6THll202HL5zRaDnli+kib0MQDeMgMg7LOZTM8Ic6XTMu3/1T3D QQdLGa070ssTGzRVvzdHVI8aGJjnbyGiyqVGQwGhr9DHzCX9AbGDyrWjRUhNjvB2AT6K 6Y2Q== X-Gm-Message-State: AOUpUlEWo2A6UzEcVG61KkryKHLZXZfoXZVhZj7El4SkghoJfg3Yqa8t gYAYSMmi3GikLISA0EVt9KQgqTQfA1M= X-Google-Smtp-Source: AAOMgpeYH4cVfvbOuLTXWSqNwB1Kq46N1CTFcdTkW0N8mZEpItrvsYVGH12lowPvfuG3KUEOc4hRXA== X-Received: by 2002:adf:9246:: with SMTP id 64-v6mr1887439wrj.109.1531402839350; Thu, 12 Jul 2018 06:40:39 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id h12-v6sm2327972wmb.3.2018.07.12.06.40.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:38 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:14 +0200 Message-Id: <20180712134016.14336-14-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 13/15] tests: Add test for ovn-nbctl dry run mode. 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: Jakub Sitnicki --- tests/ovn-nbctl.at | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index 73a61a4be..89daf631a 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -1382,3 +1382,24 @@ inactivity_probe : 30000 OVN_NBCTL_TEST_STOP AT_CLEANUP + +dnl --------------------------------------------------------------------- + +AT_SETUP([ovn-nbctl - dry run mode]) +OVN_NBCTL_TEST_START + +# Check that dry run has no permanent effect. +AT_CHECK([ovn-nbctl --dry-run ls-add ls0 -- ls-list | uuidfilt], [0], [dnl +<0> (ls0) +]) +AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl +]) + +# Check that dry-run mode is not sticky. +AT_CHECK([ovn-nbctl ls-add ls0]) +AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl +<0> (ls0) +]) + +OVN_NBCTL_TEST_STOP +AT_CLEANUP From patchwork Thu Jul 12 13:40:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943058 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHLc3wkHz9rxx for ; Thu, 12 Jul 2018 23:47:36 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F11B6D82; Thu, 12 Jul 2018 13:40:44 +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 EB6C2D66 for ; Thu, 12 Jul 2018 13:40:42 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7D6D3773 for ; Thu, 12 Jul 2018 13:40:42 +0000 (UTC) Received: by mail-wm0-f51.google.com with SMTP id z13-v6so6100491wma.5 for ; Thu, 12 Jul 2018 06:40:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VZ6g9za0IGAB9KAclQ3VdTdzL6v4lxCr2OxDAb8KksU=; b=CqkWTV3CA914O+b2iUx34xoN5RJN9VMIBfbsSO/Q6pU4NcJjSyeGXhV/l1O25ZkF2b lzd8n/iUhoNQWP17aCBeJ6q2kV2S/V7Z6/a3Wn6U4AzxCRFt6Lf3ZfMV+t3LHciAhXeJ Yc3Ga1QDbxA3Gmy6adyXk3hvhX8FEgSAdcetPhi+xzh6TCUCWZBafSHwo/bfA6ZrDY0A fG+7GX3S7ox9YyX7A8JAnrfgdRFfvakGVWGHnRxTGCoeDQtXfmG443ux7FeSwRujU4WP D4olotnVE68yjWnwkeHhHcZxf3T2W4u4c7jV/kfaJ5PaH/zAzy7iPIUKTlFTWLvnXIQ6 RBAg== X-Gm-Message-State: AOUpUlF2DQYG/64XLRnsg/hjdL+90fIk+w1o1leUDYOofBbWqSHCg4eM DyRKNit45ZLkNL3voo+QjGnm1S/xmdc= X-Google-Smtp-Source: AAOMgpdFdCW5zL4hoNxIyMHE0n73bCrzYhJmlsiUppLgeoPiL67hfrBl89qqzQS3X+fknMkN89Wv5A== X-Received: by 2002:a1c:9ec5:: with SMTP id h188-v6mr1532920wme.76.1531402840983; Thu, 12 Jul 2018 06:40:40 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id f18-v6sm23857755wrt.64.2018.07.12.06.40.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:40 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:15 +0200 Message-Id: <20180712134016.14336-15-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 14/15] tests: Add test for sync command to ovn-nbctl test suite. 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: Jakub Sitnicki --- tests/ovn.at | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/ovn.at b/tests/ovn.at index d1a8967dd..adb99db77 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -10541,3 +10541,22 @@ OVN_CHECK_PACKETS([hv2/vif2-tx.pcap], [vif2.expected]) OVN_CLEANUP([hv1], [hv2]) AT_CLEANUP + +AT_SETUP([ovn -- sync]) +ovn_start + +AT_CHECK([ovn-nbctl get NB_Global . nb_cfg], [0], [dnl +0 +]) + +AT_CHECK([ovn-nbctl --wait=sb sync]) +AT_CHECK([ovn-nbctl get NB_Global . sb_cfg], [0], [dnl +1 +]) + +AT_CHECK([ovn-nbctl --wait=hv sync]) +AT_CHECK([ovn-nbctl get NB_Global . hv_cfg], [0], [dnl +2 +]) + +AT_CLEANUP From patchwork Thu Jul 12 13:40:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 943059 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41RHMM21SBz9rxx for ; Thu, 12 Jul 2018 23:48:15 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 043FDD8C; Thu, 12 Jul 2018 13:40:47 +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 71499CD5 for ; Thu, 12 Jul 2018 13:40:44 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id EFF53784 for ; Thu, 12 Jul 2018 13:40:43 +0000 (UTC) Received: by mail-wm0-f52.google.com with SMTP id h20-v6so6051057wmb.4 for ; Thu, 12 Jul 2018 06:40:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VmaYYtjVAA79uGWGkxp2fegHwLytIa7OaWfQeqmBcjY=; b=c1nEqbXFDI0TuCzYkcBnXW/uEDEPyEdyDyHy0BEgIggNf5OaHw56hNeN9Hq9SmRtxP 5yJAl2C0Ds4GrSPjH3qSQOMhW2twKpbtJ+Tmm0v1VQoyA2c46CUt7OG6cEldgHdX5UlL FGIO7iG2RCWUIJWNSWI8Oh5BjDw1h9i1JNNfDRgrsrjJYvk03lNxomWWWQXSAMt7C5y/ mbEVUKlLYTWQWx5Y0hee45aZTYyRVGlRZwt0dqQ81KkPJApgKwPTLbRLR/UJLbb0JSJW t8MZrgIJruZruS8OYi1gTJM0P4gzMULcJWtuXiAgWQU6UqtNcw0J3M8fkHXPaOVKUo7D Yd9w== X-Gm-Message-State: AOUpUlEx7ErOKmzddSJxEFpAjgCjcdzB2e+wmq68/5UDyX4IoPgQxDCP SGEB3wjiJLDYZngijsSsxjk0kSeZ14E= X-Google-Smtp-Source: AAOMgpeO4ri25ekhTvW3SG1CwSCd9DTLFTk8LZP7yg+p5SAuRE1MEM+3ACwTCNaa2PPjmXfz8t95sQ== X-Received: by 2002:a1c:5f82:: with SMTP id t124-v6mr1435497wmb.14.1531402842453; Thu, 12 Jul 2018 06:40:42 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id u6-v6sm3717059wmu.5.2018.07.12.06.40.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 06:40:41 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Thu, 12 Jul 2018 15:40:16 +0200 Message-Id: <20180712134016.14336-16-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180712134016.14336-1-jkbs@redhat.com> References: <20180712134016.14336-1-jkbs@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 15/15] tests: Add test for oneline-formatted output for ovn-nbctl. 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: Jakub Sitnicki --- tests/ovn-nbctl.at | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index 89daf631a..60b4d0c9c 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -1403,3 +1403,24 @@ AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl OVN_NBCTL_TEST_STOP AT_CLEANUP + +dnl --------------------------------------------------------------------- + +AT_SETUP([ovn-nbctl - oneline output]) +OVN_NBCTL_TEST_START + +AT_CHECK([ovn-nbctl ls-add ls0 -- ls-add ls1]) + +# Expect one line for one command. +AT_CHECK([ovn-nbctl --oneline ls-list | uuidfilt], [0], [dnl +<0> (ls0)\n<1> (ls1) +]) + +# Expect lines for two commands. +AT_CHECK([ovn-nbctl --oneline ls-list -- ls-list | uuidfilt], [0], [dnl +<0> (ls0)\n<1> (ls1) +<0> (ls0)\n<1> (ls1) +]) + +OVN_NBCTL_TEST_STOP +AT_CLEANUP