From 5cf00e3ac3972fca9e88b6f099551405e6209b94 Mon Sep 17 00:00:00 2001 From: Alexey Roytman Date: Wed, 17 Feb 2021 09:33:07 +0200 Subject: [PATCH] ovsdb-client: Fix needs-conversion when SERVER is explicitly specified. When you try to specify `SERVER` to the 'ovsdb-client needs-conversion' command, it interprets the `SERVER` parameter as the path to the schema and returns an error. This PR fixes it. Fixes: 1b1d2e6daa56 ("ovsdb: Introduce experimental support for clustered databases.") Submitted-at: https://github.com/openvswitch/ovs/pull/347 Signed-off-by: Alexey Roytman Signed-off-by: Ilya Maximets --- ovsdb/ovsdb-client.c | 5 +++-- tests/ovsdb-client.at | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index fae27c640e9..bff16dff867 100644 --- a/ovsdb/ovsdb-client.c +++ b/ovsdb/ovsdb-client.c @@ -1573,14 +1573,15 @@ static void do_needs_conversion(struct jsonrpc *rpc, const char *database_ OVS_UNUSED, int argc OVS_UNUSED, char *argv[]) { + const char *schema_file_name = argv[argc - 1]; struct ovsdb_schema *schema1; - check_ovsdb_error(ovsdb_schema_from_file(argv[0], &schema1)); + check_ovsdb_error(ovsdb_schema_from_file(schema_file_name, &schema1)); char *database = schema1->name; open_rpc(1, NEED_DATABASE, argc, argv, &rpc, &database); if (is_database_clustered(rpc, database)) { - ovsdb_schema_persist_ephemeral_columns(schema1, argv[0]); + ovsdb_schema_persist_ephemeral_columns(schema1, schema_file_name); } struct ovsdb_schema *schema2 = fetch_schema(rpc, schema1->name); diff --git a/tests/ovsdb-client.at b/tests/ovsdb-client.at index 467175f1a7e..27eab0672d9 100644 --- a/tests/ovsdb-client.at +++ b/tests/ovsdb-client.at @@ -12,6 +12,30 @@ AT_CHECK([ovsdb-client get-schema-cksum unix:socket ordinals], [0], [12345678 9 OVSDB_SERVER_SHUTDOWN AT_CLEANUP +AT_SETUP([ovsdb-client needs-conversion (no conversion needed)]) +AT_KEYWORDS([ovsdb client file positive]) +ordinal_schema > schema +touch .db.~lock~ +AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore]) +AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db], [0], [ignore], [ignore]) +AT_CHECK([ovsdb-client needs-conversion unix:socket schema], [0], [no +]) +OVSDB_SERVER_SHUTDOWN +AT_CLEANUP + +AT_SETUP([ovsdb-client needs-conversion (conversion needed)]) +AT_KEYWORDS([ovsdb client file positive]) +ordinal_schema > schema +touch .db.~lock~ +AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore]) +AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db], [0], [ignore], [ignore]) +sed 's/5\.1\.3/5.1.4/' < schema > schema2 +AT_CHECK([diff schema schema2], [1], [ignore]) +AT_CHECK([ovsdb-client needs-conversion unix:socket schema2], [0], [yes +]) +OVSDB_SERVER_SHUTDOWN +AT_CLEANUP + AT_SETUP([ovsdb-client backup and restore]) AT_KEYWORDS([ovsdb client positive])