From patchwork Wed Jul 11 19:27: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: 942642 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 41Qpxd1mDZz9s01 for ; Thu, 12 Jul 2018 05:27:49 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 893301009; Wed, 11 Jul 2018 19:27: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 46C26BD8 for ; Wed, 11 Jul 2018 19:27:22 +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 CF09C4FA for ; Wed, 11 Jul 2018 19:27:21 +0000 (UTC) Received: by mail-wr1-f48.google.com with SMTP id g6-v6so10371122wrp.0 for ; Wed, 11 Jul 2018 12:27:21 -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=gTVcwAL6gR2taMoIc6L7rE8Q4g7zmDrYAFzcB38Yakc=; b=pNEG+kButGsVt80EMKqP45dGdVQeN9M1RIKTq3cTvcfZgDMwEO5N/y1IV6RVpq8LbI eipGy+Sfj0aPdkGiv+K6Ebgij1MgkVbe/RK+1fdJjfbtNTtz7cetlJEGffTKwBq/TJdA 9Aw9uKwXG6ScN/lltkTfKW8Y6jbAAbAnpTmm4X8kwfIP9kitU3kEJuxRTROWijtZI/Ol 1MrOt8tno9c+X0FQIiily3aVdzctl+JKv72kcrrgeg6Y+/L1M4B6lQ+AeXehHXscTxX7 lEBYy4M/KuKHVdBxdUh5xQy/D9WHkouUCY/gE5VYbM20E9qSOkzcjEDGQPLhSE5KGRbc ehRg== X-Gm-Message-State: APt69E2I4D/rbfDlRx/DCJwVPaBbkuMMl3hN1Th4TdnkmQ0JN1ObFqCF w4CSsEO3M5/reTfmmxCT5SmlJREdkUU= X-Google-Smtp-Source: AAOMgpdrvTYUTAgdHytfqg68umRW9jnlIY05o57M7qvl4Wp1PwRfuXv+L/NjvAkEm2f2O+M60ZXLyQ== X-Received: by 2002:adf:af27:: with SMTP id z36-v6mr20617909wrc.59.1531337240318; Wed, 11 Jul 2018 12:27:20 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id v190-v6sm3744928wme.21.2018.07.11.12.27.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:19 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:03 +0200 Message-Id: <20180711192717.21409-2-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 01/15] table: Allow default style to be used in an assignment. 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 Type cast lets us use the macro as the RHS expression in assignments (structure copy), apart from the usual case of initialization. Signed-off-by: Jakub Sitnicki --- lib/table.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/table.h b/lib/table.h index 313ac1dd2..220a9818e 100644 --- a/lib/table.h +++ b/lib/table.h @@ -82,7 +82,8 @@ struct table_style { int max_column_width; /* CF_STRING: Limit for column width. */ }; -#define TABLE_STYLE_DEFAULT { TF_LIST, CF_STRING, true, JSSF_SORT, 0 } +#define TABLE_STYLE_DEFAULT \ + (struct table_style) { TF_LIST, CF_STRING, true, JSSF_SORT, 0 } #define TABLE_OPTION_ENUMS \ OPT_NO_HEADINGS, \ From patchwork Wed Jul 11 19:27: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: 942643 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 41Qpy91HHGz9s01 for ; Thu, 12 Jul 2018 05:28:17 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4A72B102A; Wed, 11 Jul 2018 19:27:25 +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 0E054FF1 for ; Wed, 11 Jul 2018 19:27:24 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 765714FA for ; Wed, 11 Jul 2018 19:27:23 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id v3-v6so3685209wmh.0 for ; Wed, 11 Jul 2018 12:27: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=wuT3+IW4vYRIuBgOmE2eoHhtP2E6vL8N5bb7cDqebec=; b=eUAneJV6FpcyUPEfUwarE1w3zFcVvlt4jGaDG6KnWbir4qPecICv275j4w5KzCDc1h e4yoJM+NKbBCtSseMNyXzSPK4DiBSF/5FCKKYqIHdMPDXb4agA7NRe97aCuYrJsZTp87 AM4CYgS1jPQgrXTWpaJJkrVr6PFh3rayA51WckZmuyPnQuYa1raomMZYvKa7ualSuzWr F4IbU5XCsQn+ZOBYhSJAWjXvdN2pEG3WOz+zc+GdWVe2Y+JaYDwGDc7Q3irFl1A4mnXK mtyPatmAcj6Af4IAFU4a7nXrv+MIZQf4ysPdvtIptpYdOAmBYGRT9oyoC0AOtN5RfuqP 7CdQ== X-Gm-Message-State: APt69E01avkiiijUAiKUTzNDX4rBFsuDS6Y7yGdQZig2XiWymbO8UbNe /geM3cUnAsyv9ASUowOH6g8ZjkusMW4= X-Google-Smtp-Source: AAOMgpca5+r8ko/cLdrzVE3sxoNkTIYsJzExGLbvJ98M1ujAwh3F08nLaHOk8EdXDMox0jzCsdHXow== X-Received: by 2002:a1c:f20d:: with SMTP id s13-v6mr17057477wmc.36.1531337241930; Wed, 11 Jul 2018 12:27:21 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id h8-v6sm1779686wmb.32.2018.07.11.12.27.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:21 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:04 +0200 Message-Id: <20180711192717.21409-3-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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 Wed Jul 11 19:27: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: 942644 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 41Qpyf61Pvz9s01 for ; Thu, 12 Jul 2018 05:28:42 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 039A81033; Wed, 11 Jul 2018 19:27: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 A02C51025 for ; Wed, 11 Jul 2018 19:27:25 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 2174F4FA for ; Wed, 11 Jul 2018 19:27:25 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id c13-v6so19238545wrt.1 for ; Wed, 11 Jul 2018 12:27:24 -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=Ph8lzSQeIxT+saKb3HLKYmtawuBhZhlRBwLFERt73JyOsXteB0DszwZKBUNOxVwaTN AlzCOKVxdgyRcwO+Lqt21oQv+Ql4EOh4snilgKARBg/kymEwakBJZfxt1DOc7WPRXAAM MM2Q4f0o86l8oLNXey53NVCxknVG+jeJsZ3EcjipEyT4e5MS+Ydh9GvrGMZWxrOv7PfD k+8ylXl76jhvY9j8hshU2VjH6kX0KXoq+8jMEgNxENlp8ioBrj6KYOz68oy6980OoU5x XLkv/vT5eK2CkjWgzDVZUcXLgvMNzHjxo8Y2gx4OEs18U0vfoDbGHPEuVqYmh9Xv9bvZ 808Q== X-Gm-Message-State: APt69E2qkWqJm2HpqDtfaoVSOPiZOQYRRTFPy6Z3jrRNe7CtSWUuKplA a4h5K+43GjStCIzIIgvdsBxTSn67gAg= X-Google-Smtp-Source: AAOMgpchVA7t/bH82OWneSSOHzl26dOpimxHa/MZ9Q8Ri7cYSbIBwNWpVTuo3ri5o/KLbzI6Q7UeKA== X-Received: by 2002:adf:8895:: with SMTP id f21-v6mr21483368wrf.250.1531337243602; Wed, 11 Jul 2018 12:27:23 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id x16-v6sm3797250wme.12.2018.07.11.12.27.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:23 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:05 +0200 Message-Id: <20180711192717.21409-4-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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 Wed Jul 11 19:27: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: 942645 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 41Qpz92hJRz9s01 for ; Thu, 12 Jul 2018 05:29:09 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id BEA91103E; Wed, 11 Jul 2018 19:27:29 +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 4C813103E for ; Wed, 11 Jul 2018 19:27:27 +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 D0F2176A for ; Wed, 11 Jul 2018 19:27:26 +0000 (UTC) Received: by mail-wm0-f43.google.com with SMTP id z13-v6so3665527wma.5 for ; Wed, 11 Jul 2018 12:27: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=6+pIEnsjDbhPX4E+KjQ2Ks5ojGlh1XccI7EgGwqUzm8=; b=DDLfxAMWhI5YyjT6tXvZyEYcUo0HV0KnhjO8R9rLVkfC5oqXj5wm2kG5sSFePgSZk2 T/W7stlKSSwi985/JvA0E+ECwaNus01r32+FTOZZXcwtgenfH9gWtvb5qM0io7CxSwqk bJ8rJcMmFJ1hSi5VJ2Xr9JWaeCJ6L5y/ysGxewIAbnuiSdlPign1dSCwRJf9mZ+22pZc c0RorfIibvwZvpLkOBjndXWo7Up13YSE8GXGypwhF5vCFp439BXFSQj5AmR98DRdyBYK zXdfQBdvQUIOuDxyBVmS5xvILGgi6bXG6VJg+d5SRmfTXLXcJdWvadbOwBl3m5dafPTG Smzw== X-Gm-Message-State: APt69E3O8w1PWBhVkioJVZXDCvfQRGBTtGCUmrECzpk2iNWEX7HUWEpm fozLNo/UMzynLIuSyU6HPUuxrhW01Zk= X-Google-Smtp-Source: AAOMgpfcUS+0B8ZxemY44O0LPYKGQ7m+UH5IgtJcpcpJnQjbf/xwl4/Jga4RYsHNtJADG1nrN9gr/Q== X-Received: by 2002:a1c:be13:: with SMTP id o19-v6mr17103994wmf.1.1531337245308; Wed, 11 Jul 2018 12:27:25 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id k13-v6sm15759568wrr.14.2018.07.11.12.27.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:24 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:06 +0200 Message-Id: <20180711192717.21409-5-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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 Wed Jul 11 19:27: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: 942646 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 41Qpzh3vMYz9s01 for ; Thu, 12 Jul 2018 05:29:36 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 97ADF1058; Wed, 11 Jul 2018 19:27: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 00E851045 for ; Wed, 11 Jul 2018 19:27:29 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 80C99771 for ; Wed, 11 Jul 2018 19:27:28 +0000 (UTC) Received: by mail-wm0-f41.google.com with SMTP id i139-v6so3410728wmf.4 for ; Wed, 11 Jul 2018 12:27:28 -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=DOzZcuqJ8bA7ucqnGvgZg1yzghZFLR6iJmsGng1KqvH0xK8oXNW6g04Vfll3diCPAR 2dfIRtIDfec3QV3fM8+TtVITqTJbECbFaI16M/6meXC9Ir3FNZP757L9j6CV2u/Ezcfm ozw7t7bQlgMDOHN1H9zK9TciA7KB+0mDyqAhk7eNp7XgtkKXtVnAiS4zYKUyH0oll6GX W4vq6yDhiMwIGT9J5I1KdP2dfixgXXYRuP8n1p4zKmiokFMBswNDCqXFUpoJwMVa4kSb n8cgi8nEUN88sFUbeb4IVTVeMVMITwpvTQMRZKln/PpoCPjkeRpVg8ROYpPKnqKEhNnb xPwg== X-Gm-Message-State: APt69E2DFYcejwWpvGFdET8AvtIr+Eip6yKWaTiCqXVFi+8q4lZYAE9g /jubpv58zLm+5pDKCf0MzPgXFnl/wio= X-Google-Smtp-Source: AAOMgpce9mfu6jjKXFc4y0djfyaWxJNJj01Asx7Cpdf/JkrsIzGe/bxcFBAz2xsT1BVGiqRgKUiHNw== X-Received: by 2002:a1c:84d0:: with SMTP id g199-v6mr20071921wmd.90.1531337246982; Wed, 11 Jul 2018 12:27:26 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id 73-v6sm4467324wmu.37.2018.07.11.12.27.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:26 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:07 +0200 Message-Id: <20180711192717.21409-6-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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 Wed Jul 11 19:27: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: 942647 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 41Qq0H5XCTz9s01 for ; Thu, 12 Jul 2018 05:30:07 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 40DF51067; Wed, 11 Jul 2018 19:27: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 513341062 for ; Wed, 11 Jul 2018 19:27:34 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 24029782 for ; Wed, 11 Jul 2018 19:27:33 +0000 (UTC) Received: by mail-wm0-f48.google.com with SMTP id z13-v6so3665747wma.5 for ; Wed, 11 Jul 2018 12:27: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=+PQf2NbS8RkFzMyvsF7I/s0QkSSgaOO8vtEtXAbqO9s=; b=DZpxCU0Zx1lGq0kiRsXYIwitydkRrn6qMwL+wP6zcLGmydvSbqHW7A9HarfSUBijZG zWj6Y33AQoEw1IfWDTFhTFvA+Cd/wZ634NpWwq/lZOzyB1akQHFT/qhwNnRyxd34Z+Ur 0qN67CsWm8uDe0nVrZJxdUg+nhUAcCdlyzJHcHVUfuhE26i24jhnoOW+rzMU7UQPvhPd d7l3KADmSG3AhPrMF7B5EJRxNiBvFX254R0oLGV8DfYzyAGerzqhI3hpibyLuu2eJ/zn I3QmYWv2yJocRDp7Z8dGTYokC6HwvnbcG2L+Cyv3U8gyTFNDQAXVEN48dNPiaRellTeu y1lQ== X-Gm-Message-State: APt69E2jxh/xq+pFP6SSKFDL+tzLfpv424xbCO7S59tjyFuvNNbSmXqK NIT/U4LkoEqUa+h1VwzDFD3/oYxk4ZA= X-Google-Smtp-Source: AAOMgpfxYBiwdgmMsmK5PLVt+d52oeUpP5l+9jLCitPzW1hY27KvZDzLK0BRzh9V9u357BP5Yb237w== X-Received: by 2002:a1c:b94c:: with SMTP id j73-v6mr19597973wmf.104.1531337251616; Wed, 11 Jul 2018 12:27:31 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id r140-v6sm3951787wmd.27.2018.07.11.12.27.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:31 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:08 +0200 Message-Id: <20180711192717.21409-7-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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 Wed Jul 11 19:27: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: 942648 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 41Qq0k0SZTz9s01 for ; Thu, 12 Jul 2018 05:30:29 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 20B09106A; Wed, 11 Jul 2018 19:27: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 94C601062 for ; Wed, 11 Jul 2018 19:27:35 +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 D1D6376A for ; Wed, 11 Jul 2018 19:27:34 +0000 (UTC) Received: by mail-wm0-f47.google.com with SMTP id z6-v6so339549wma.0 for ; Wed, 11 Jul 2018 12:27: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=PVOT2BukTxFiIYIY9Bhpb+5zfNgWlYFWC44rgCeOj6c=; b=CbA9kGyfEC5833jjHp+SRyWHXWFdHLIEHm3NAy5ijbNYo2nG1rJ5lbw10gqQ45ynJl 6f8r1uhfujtqACS4wz1Tkl2zyX7LWYXUtEnXFAfRU642NV6zB5wR93cN1L61cmeTmUV5 U612RtqdCNWMx/Sj0qxdWnF1zLFJPPB3Gh2K0MeHofSinvPYFMRVz5A/jcWFJigCHUp8 MAz+uvFnAKnI37kkNDiaoMlyE5e2oqh8XKBcDMnJZw/1Zij7G9phnZdkfeRCS6RVtt96 c9A+seslMTXltm6RFP/Ke15/lcnTCe7XFL3r5zfruUdV2VGHeXEJCycFlVluC4XmmUoz fNKw== X-Gm-Message-State: APt69E1pwiP90AjibO80EqMAT1On0X8ayzF9p7z2ccO3N5mUwyyqCn5O NbXLKw+npfbu2srSWigJiNsLYy28KiU= X-Google-Smtp-Source: AAOMgpch/2a+YtFphWBPSDd34WCAO6gHs0yQLGDUfBKjQPcwzioya28CbLi14msKflS7iRp+Giy2ZQ== X-Received: by 2002:a1c:5b88:: with SMTP id p130-v6mr14875608wmb.69.1531337253197; Wed, 11 Jul 2018 12:27:33 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id i190-v6sm4649361wmd.33.2018.07.11.12.27.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:32 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:09 +0200 Message-Id: <20180711192717.21409-8-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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 Wed Jul 11 19:27: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: 942649 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 41Qq186k0Fz9s01 for ; Thu, 12 Jul 2018 05:30:52 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E0F141074; Wed, 11 Jul 2018 19:27: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 C8826106A for ; Wed, 11 Jul 2018 19:27:36 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 49F2876A for ; Wed, 11 Jul 2018 19:27:36 +0000 (UTC) Received: by mail-wm0-f44.google.com with SMTP id 69-v6so3647216wmf.3 for ; Wed, 11 Jul 2018 12:27:36 -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=XZjxCBy1L0hPjhvzd+TbIX0okzwxGAikTQ1SghCGCjtUWNhLuLr0KV6Kna/j6N+3aV uprhk2CGqmVjPBkCIgPDNuQtA15G7XZFSWWeOtZ8UZe1JLbKCCPekb7XQ7wljmCLBFEe tFlYMLTviYjpYFbOeK1+soCYYTyoCr9+E+voKDOzGTSpAS3QZ+mik231ydWrMcQ/SaTY FdGWMxTR8XCukEbdWuVrPbGpUGm0KtLqfsza3bfGL1Fav8MI9C8RpuhTWb7O+cx6ca9H 8HCWxFPRPuBxych84/As5gUTpMRRUcLPVAtfKB+KRa2y6kC8nxLL+rslitTvgPeIwcNK MZfA== X-Gm-Message-State: APt69E0Do6Xrlgt8RHD8wKus6ARcbQLdIjJo9weotNjxvFwvzeEOCmac xiJ01Q4FSS8v1rz6CDxs+AYagS/Yz4Q= X-Google-Smtp-Source: AAOMgpeV6YrrwQxzQB0Qn9VoFWMVPabTyLpie+hXckm0xLlkbMjRH3c6qqPSsCgPdsBX/WCMQEUisA== X-Received: by 2002:a1c:b5cb:: with SMTP id e194-v6mr18815736wmf.133.1531337254741; Wed, 11 Jul 2018 12:27:34 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id o4-v6sm38315689wra.3.2018.07.11.12.27.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:34 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:10 +0200 Message-Id: <20180711192717.21409-9-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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 Wed Jul 11 19:27: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: 942650 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 41Qq1c1Gngz9s01 for ; Thu, 12 Jul 2018 05:31:16 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B77B8107B; Wed, 11 Jul 2018 19:27:40 +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 A91691064 for ; Wed, 11 Jul 2018 19:27:38 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0EE5E775 for ; Wed, 11 Jul 2018 19:27:37 +0000 (UTC) Received: by mail-wr1-f52.google.com with SMTP id s11-v6so19272074wra.13 for ; Wed, 11 Jul 2018 12:27: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=XSiLMlQSkrr13ba23H0kZgB8E0U67NehF3mkbPyZeo4=; b=E0PV6FEa8/7dPHOGcqUuBfoa6aYOmLZnC8F7BeizuM+cEJCjxuHJkAIZPcEvSP4S9u w+1KlwwXsbQsfKmTYReWH2hCEtaYAbjlKa/HGHjixY3/6E4I9uFxURKXdP3OpV4xpX4/ v2tb0rL0NdTUCHpTYyYlGKxxgYHUz8Tv8/i/j6S40SZro+jvzJH/K2+7wiEa0efcDtl4 4N1xzY2d2tuIduNpbjN1wk9KTPn18O/yc2m6um3CxxbrH9fU05tm3pVYfnQnxS+dNyD8 qAIA9+OaAlVmFq/qRb/2ba9R8hxbTdnXMXU6hnYIX4lN0VjNYJfgJGuJwy8NcACvLz88 0MTw== X-Gm-Message-State: APt69E28fB62K57WQbQC/7KO7ZLOKje7L/e+dj6P7F6CDs29uE6Jvsf+ z+bPzLx6a+63RY+v9RQxpJak3+Bg/NU= X-Google-Smtp-Source: AAOMgpePEw5EBp1ABqYxX6e1pnR5rA0QsIaKafWrlOaKrFCgfvwMYDJHXq5KmjfNTLm4aJAL/hrlvA== X-Received: by 2002:adf:c321:: with SMTP id n30-v6mr21401821wrf.235.1531337256483; Wed, 11 Jul 2018 12:27:36 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id q17-v6sm23094385wrr.7.2018.07.11.12.27.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:35 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:11 +0200 Message-Id: <20180711192717.21409-10-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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 Wed Jul 11 19:27: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: 942651 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 41Qq242bwkz9s01 for ; Thu, 12 Jul 2018 05:31:40 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9A5871084; Wed, 11 Jul 2018 19:27: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 5A9F41072 for ; Wed, 11 Jul 2018 19:27:40 +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 C3E9B4FA for ; Wed, 11 Jul 2018 19:27:39 +0000 (UTC) Received: by mail-wm0-f46.google.com with SMTP id i139-v6so3411104wmf.4 for ; Wed, 11 Jul 2018 12:27: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=WuMrQQB9HPGhcqwstHJimbLvwY1mJxoslq7hNt+99wQ=; b=rkgPNk6pMHKLamSqrkn3JWhPBEfWkY2lLmJ01ypBiaqgRkzozFD2+C42j5lj0Gd4BX c8z09i+U2LVE3u7hVUNvbfb01fdc9VSvJo9QIan/8EOPcloArP6pHCiipOZRCZRL6EtB +Cv8+5nO5QZI/77mYkXDOztU0+5Gj63apQ/USQaaghSuF/+HCSxfZ4zkxrnL6if+LDBJ UtYkP4zqv/jhkewAgOgWlCvwj02aUT6m39CzkQwAscZ3enbWrRCfunoRJesPjdbUNMmX 06tA1AmEpQ0NwDp8O//rns4QheOsY2i7tDrqHxhUAsgtsh5TFwA9A4JiEl6wBPddk0Aw 0q5A== X-Gm-Message-State: APt69E361HNn6m70ZvJMzWGpJ+Re/++PSYt8D2cVfpoDHLS79Y5SiMqV i+bB0xk+rxL2MfgqPyYUAagH7CCjgcs= X-Google-Smtp-Source: AAOMgpf0WyMqVr0QG538W3jh0Xp6BXcsU7z+3URbbk/JDwncGO5JpqCsbwWsi3xTq8dxOTu/BvJjJw== X-Received: by 2002:a1c:d812:: with SMTP id p18-v6mr19319375wmg.92.1531337258232; Wed, 11 Jul 2018 12:27:38 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id w2-v6sm4398755wme.45.2018.07.11.12.27.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:37 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:12 +0200 Message-Id: <20180711192717.21409-11-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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(-) -- 2.14.4 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 Wed Jul 11 19:27: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: 942652 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 41Qq2p3lzxz9s01 for ; Thu, 12 Jul 2018 05:32:18 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CAB6C1093; Wed, 11 Jul 2018 19:27: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 D340AFF4 for ; Wed, 11 Jul 2018 19:27:41 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5CB77771 for ; Wed, 11 Jul 2018 19:27:41 +0000 (UTC) Received: by mail-wr1-f52.google.com with SMTP id h10-v6so19268643wre.6 for ; Wed, 11 Jul 2018 12:27:41 -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=sDHo0de6Ey6to6ZfMhQivndWOdaEqzqxQXLZ8/Pt3Z1dcDxGNpS15i2mV4biJCgjD1 FptlPkW3ip2jqnteuMn9WodPQDBNl9e/EKoKeSRn2jXNL/lfuwuQzzwRcOtRHOREpakj pBrOGW7SoxlzadzZGHLyZxq0k/eYXcOCM1P0cgH6EcOV8/5ZKdSmTmyvrrO10YigzNoP S8lxSCk//4QBXOddhLfYU6JOqsNxUYn75FhcJ72roTIiU81mOsFu88TQWxl00oGoOaL3 czkft+i2wLYQeHSnTivuk56vVYlhaTlLDmqMmEgrJ8EibmhuWAZgyGXopZ6p7iN2HwEA ReBw== X-Gm-Message-State: APt69E0mHHVUReKMTjfcQDkz4HsC4kDXaUr27fN/wEP54hV9wodlGbSH quwyspZ2dJkWFe8cgBKmgUrw3HhwTxc= X-Google-Smtp-Source: AAOMgpeTmhREwGBvYOsX+tTKZof7nprDmUoGyRtyzNvO9QeoYe9wB4ufeYsSkrtPSghQ2eLASlTJxw== X-Received: by 2002:adf:a634:: with SMTP id k49-v6mr22955451wrc.181.1531337259859; Wed, 11 Jul 2018 12:27:39 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id z18-v6sm17901233wrr.76.2018.07.11.12.27.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:39 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:13 +0200 Message-Id: <20180711192717.21409-12-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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 Wed Jul 11 19:27: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: 942653 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 41Qq3K5lDYz9s01 for ; Thu, 12 Jul 2018 05:32:45 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E1D0C109B; Wed, 11 Jul 2018 19:27:45 +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 2469BFF4 for ; Wed, 11 Jul 2018 19:27:44 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DF35376A for ; Wed, 11 Jul 2018 19:27:42 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id r16-v6so19281318wrt.11 for ; Wed, 11 Jul 2018 12:27: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=MfxdTZBgdnlnAmCqWq5Ztsqx0PSL7AYAf3GZs0Za9wM=; b=gEWcw1jxkxTj5hi5BPPXiFplVGeTJXhbr+rzeTLEHC8ML6qBq1B04UmflzudRYKDz4 /o8rkCLK0piRNllRgpKE1agxeSsfKHcuSU4I4cnZ5BnTJFZqHr70woRmxrKP58aWvi6S DLWt3A8FcGKhPldgstbGsq0tuOLtCpZzlls+CXH+7G2rHbTf56sqLXgYSrBNNihxJczN hR9lbvlw9XzMKOs+beP2B12YsTVZRXmHfX+65LFHtwKcab1gTm+uAfblZys+KGuLZ3U8 ZAHq16jm3jfzT7lPwYq6HzIHxxitIa1VSujr025vHVBRZJdVRZHvxhjB4h9HPwIY8+Po mFqg== X-Gm-Message-State: AOUpUlH+DvF4kRvJPDpPXKMOmxaeLsrzSSUmV/1FRf6mlpagCz0VDk31 sGsbQmLZRoxzGLS1bfmTcqLAyaI2+YY= X-Google-Smtp-Source: AAOMgpcAF3Pm/DcBr2NhQjYq/maGYCygymOPOKvauhcsoc8Ntgk2EcIMkk21h2U3/i6dye7D3vfYOw== X-Received: by 2002:adf:ef03:: with SMTP id e3-v6mr12160623wro.182.1531337261259; Wed, 11 Jul 2018 12:27:41 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id r140-v6sm3952738wmd.27.2018.07.11.12.27.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:40 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:14 +0200 Message-Id: <20180711192717.21409-13-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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(-) -- 2.14.4 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..fc42f817e 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 Wed Jul 11 19:27: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: 942654 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 41Qq3t1gB2z9s01 for ; Thu, 12 Jul 2018 05:33:14 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A46E11082; Wed, 11 Jul 2018 19:27: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 2F0D11099 for ; Wed, 11 Jul 2018 19:27:45 +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 9834A76A for ; Wed, 11 Jul 2018 19:27:44 +0000 (UTC) Received: by mail-wr1-f41.google.com with SMTP id t6-v6so19274931wrn.7 for ; Wed, 11 Jul 2018 12:27:44 -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=BQB72rh3XcA4Y5HLtj2bruVZe6vO+SuFFOeeri0m2EceYBqEwwRy7GjsR6h57IXY7f JOdIvpc6b8lWU8PMl7dmPb0ABDyPJ4E7QDtbdOJhRJCsVq3rah0lrHpbavniWS3d6BC/ 4Pb/4uZ2zljSw7G9E3IQTIIySNFqmr10tE0fN4KXjlivv4JhXvrvt7b1GxKJ4Jre4lmH QKQk683yGIS5lAhUanEEtgimmQF+J35xqzr/GyRfMzO4qrRc9DyVcZLVBvM+3E3/yYBp WTgcb1FceHz4d1sb0/0PMX8Uo3llyvzXe3PugOs/sRHPXSxWPot0DmkjTr/sICQYhoDb ihJQ== X-Gm-Message-State: APt69E3KzmXDLLS12nAVt/bKJ5HcsIBYm2SnQDrmH/X7WdLd5gw0V2cw erHIlkIn/KsUkTrluZhUI+geOEjegBM= X-Google-Smtp-Source: AAOMgpfmIQhZkv/DhDFh+X/oFK1YsY8RMQZ37dLyrw2CBriWG38UynJhFTaT9MFaOaIZfagyMctkqw== X-Received: by 2002:adf:8877:: with SMTP id e52-v6mr23568860wre.30.1531337263071; Wed, 11 Jul 2018 12:27:43 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id b6-v6sm44606414wru.66.2018.07.11.12.27.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:42 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:15 +0200 Message-Id: <20180711192717.21409-14-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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 Wed Jul 11 19:27: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: 942655 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 41Qq4Q1m0Hz9s19 for ; Thu, 12 Jul 2018 05:33:42 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 85A4310A8; Wed, 11 Jul 2018 19:27:48 +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 541801082 for ; Wed, 11 Jul 2018 19:27:47 +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 214BE772 for ; Wed, 11 Jul 2018 19:27:46 +0000 (UTC) Received: by mail-wr1-f48.google.com with SMTP id h10-v6so19268811wre.6 for ; Wed, 11 Jul 2018 12:27:45 -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=nWYVFDyQ/8LL06lK61cBjPAYLEghrptjJYBK6Bf9S6eDEw/J/9GQrlytZdXC2nrkF+ dQBJsc8may1Il3RlotL3oiJAotDxINyGKmICPsG3hl8hwtN0ORg9O9pxlS61haiFjQss uwKdRPbpHf5xkr054wrWecePqIPt0cFsUxuhr0Z73TMmQZbxFCjzX3ajFkBQtbFhhQpK kI/d0k4+gVJGueVn6iQHIgJfefOs5LU0anQ8KKfzHmw6UKLhyxqguy9eOFAnSfhtVcwS j99dZi39W4j+9w9ia70+QfCd1cIVyAjRtSeWtE5l3GJzMzJtD7fzpZBVM4WFLzH8bpWx 5TYQ== X-Gm-Message-State: APt69E3nQIdhEyR/G8pvGRWw+bMGIxRcbyUY5azRLj1V7GYfndIuGpLb MZVUotCvFEHPl6kxTdP3sEM5jngxR2U= X-Google-Smtp-Source: AAOMgpfC76B6lot4PHOSRbaOMLYd1MCI4zdmuD/0+qE6qpu2mtg6QJahf8XM7IJD7cBrDta1cKUdIA== X-Received: by 2002:adf:f28c:: with SMTP id k12-v6mr20431093wro.263.1531337264558; Wed, 11 Jul 2018 12:27:44 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id f18-v6sm20803476wrt.64.2018.07.11.12.27.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:44 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:16 +0200 Message-Id: <20180711192717.21409-15-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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 Wed Jul 11 19:27:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 942656 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 41Qq4y2FKYz9s01 for ; Thu, 12 Jul 2018 05:34:10 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6CD7310A7; Wed, 11 Jul 2018 19:27:49 +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 2DF411028 for ; Wed, 11 Jul 2018 19:27:48 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9C8404FA for ; Wed, 11 Jul 2018 19:27:47 +0000 (UTC) Received: by mail-wr1-f53.google.com with SMTP id c4-v6so6608184wrs.12 for ; Wed, 11 Jul 2018 12:27:47 -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=sQ6xn2pdiYL6+wVQ78tMhOTKljIOF7kGn9BrlgJ054AuIuuG+73WMfhxC3ZziaWbgq yPBDGjxVyMR+WaCq8ZRlJJcCn6tSyEDizBk23DrRckIg0K47T46Gxc57VIYc199A0vXF +kbSwZogQHtL94LhW59B8E703Kg2/IpFTnobr6Nvmjq2OPvgmr2X1z0+CVnYlOfGqYGw ZKi0ylFmr/6zqtBn9/r8HfpjH1g3v2IHUZpaPhNxZMWmbGiqmAQESgVWIjnKbjgkklQW 2+6aRdJM+cWvM7mWnjJodTLKTaaKQa/1QgK/T8kSIi2Ia6mhjoZDHiMWKWKQuQEGmtEa Plzg== X-Gm-Message-State: APt69E0/BcM4NQl2RNseEHQU8fY94kGW0LeQkcUAwJrJVg3tUtrd9OGw /1Le/nLbK1zCIcYIkFMmjBiulD9imFY= X-Google-Smtp-Source: AAOMgpdw/S4megGuLeSCpigH7YQgBEHmFvdG96N3Bh1oabxqUTCgICOeAQkdBJsqvKyiNe5Wr7hxAQ== X-Received: by 2002:adf:8ab0:: with SMTP id y45-v6mr20649845wry.98.1531337266121; Wed, 11 Jul 2018 12:27:46 -0700 (PDT) Received: from redhat.com (218.red-2-136-166.dynamicip.rima-tde.net. [2.136.166.218]) by smtp.gmail.com with ESMTPSA id y191-v6sm4997252wme.21.2018.07.11.12.27.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 12:27:45 -0700 (PDT) From: Jakub Sitnicki To: dev@openvswitch.org Date: Wed, 11 Jul 2018 21:27:17 +0200 Message-Id: <20180711192717.21409-16-jkbs@redhat.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711192717.21409-1-jkbs@redhat.com> References: <20180711192717.21409-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 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