]> git.proxmox.com Git - ovs.git/commitdiff
db-ctl-base: Don't die in ctl_set_column() on error.
authorJakub Sitnicki <jkbs@redhat.com>
Mon, 2 Jul 2018 10:50:09 +0000 (12:50 +0200)
committerBen Pfaff <blp@ovn.org>
Tue, 3 Jul 2018 20:19:45 +0000 (13:19 -0700)
Return the error message to the caller instead of reporting it and dying
so that the caller can handle the error without terminating the process
if needed.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/db-ctl-base.c
lib/db-ctl-base.h
ovn/utilities/ovn-nbctl.c
utilities/ovs-vsctl.c

index 3a6e7e1ac340609f2ba2de48e3217b35fd6bc2f7..d22b6affd846ca840d6b05588e8f5ee80cfc2794 100644 (file)
@@ -2395,12 +2395,21 @@ ctl_context_done(struct ctl_context *ctx,
     invalidate_cache(ctx);
 }
 
-void ctl_set_column(const char *table_name,
-                    const struct ovsdb_idl_row *row, const char *arg,
-                    struct ovsdb_symbol_table *symtab)
+char * OVS_WARN_UNUSED_RESULT
+ctl_set_column(const char *table_name, const struct ovsdb_idl_row *row,
+               const char *arg, struct ovsdb_symbol_table *symtab)
 {
     const struct ovsdb_idl_table_class *table;
+    char *error;
 
-    die_if_error(get_table(table_name, &table));
-    die_if_error(set_column(table, row, arg, symtab));
+    error = get_table(table_name, &table);
+    if (error) {
+        return error;
+    }
+    error = set_column(table, row, arg, symtab);
+    if (error) {
+        return error;
+    }
+
+    return NULL;
 }
index 776d9dc1fcdd031656849b928f95a446b4d65829..a97128d452eb4c887949398ade5d5af83d32a726 100644 (file)
@@ -273,8 +273,7 @@ char *ctl_get_row(struct ctl_context *, const struct ovsdb_idl_table_class *,
                   const char *record_id, bool must_exist,
                   const struct ovsdb_idl_row **);
 
-void ctl_set_column(const char *table_name,
-                    const struct ovsdb_idl_row *, const char *arg,
-                    struct ovsdb_symbol_table *);
+char *ctl_set_column(const char *table_name, const struct ovsdb_idl_row *,
+                     const char *arg, struct ovsdb_symbol_table *);
 
 #endif /* db-ctl-base.h */
index 10ead0fc5ffd53a661b7b0b60f5f342386b05bd3..fc1b1fea7024caaac232bfdc5e6000c4fbce4d0f 100644 (file)
@@ -3279,8 +3279,11 @@ nbctl_lrp_add(struct ctl_context *ctx)
     nbrec_logical_router_port_set_networks(lrp, networks, n_networks);
 
     for (int i = 0; i < n_settings; i++) {
-        ctl_set_column("Logical_Router_Port", &lrp->header_, settings[i],
-                       ctx->symtab);
+        char *error = ctl_set_column("Logical_Router_Port", &lrp->header_,
+                                     settings[i], ctx->symtab);
+        if (error) {
+            ctl_fatal("%s", error);
+        }
     }
 
     /* Insert the logical port into the logical router. */
index 3dd74a186ae07200be45ba21f9eaee1e4a04bbf9..bc8b80340f58470730a8a27d064231f679477739 100644 (file)
@@ -1591,8 +1591,11 @@ add_port(struct ctl_context *ctx,
     }
 
     for (i = 0; i < n_settings; i++) {
-        ctl_set_column("Port", &port->header_, settings[i],
-                       ctx->symtab);
+        char *error = ctl_set_column("Port", &port->header_, settings[i],
+                                     ctx->symtab);
+        if (error) {
+            ctl_fatal("%s", error);
+        }
     }
 
     bridge_insert_port((bridge->parent ? bridge->parent->br_cfg