[ovs-dev] [PATCH v2 2/2] windows, ovn-nbctl: Add service_start call inside the server loop

Ben Pfaff blp at ovn.org
Tue Oct 2 22:37:52 UTC 2018


On Tue, Oct 02, 2018 at 06:01:26PM +0300, Alin Gabriel Serdean wrote:
> Currently all ovn-nbctl (daemon) tests are failing due to the missing
> call to `service_start` which is required on Windows.
> 
> Windows lacks fork so we need to pass all arguments, so we can spawn a new
> process and interpret it properly when calling `service_start`.
> 
> Signed-off-by: Alin Gabriel Serdean <aserdean at ovn.org>
> Acked-by: Ben Pfaff <blp at ovn.org>
> ---
> v2: Remove OVS_UNUSED, add acks

I think that this can be made non-Windows specific by rewriting it as
follows.

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index eabd30308ac2..7e42b53a9079 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -117,7 +117,7 @@ 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);
+static void server_loop(struct ovsdb_idl *idl, int argc, char *argv[]);
 
 int
 main(int argc, char *argv[])
@@ -173,26 +173,24 @@ main(int argc, char *argv[])
     shash_init(&local_options);
     apply_options_direct(parsed_options, n_parsed_options, &local_options);
     free(parsed_options);
-    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);
 
     if (get_detach()) {
-        if (argc != 0) {
+        if (argc != optind) {
             ctl_fatal("non-option arguments not supported with --detach "
                       "(use --help for help)");
         }
-        server_loop(idl);
+        server_loop(idl, argc, argv);
     } else {
         struct ctl_command *commands;
         size_t n_commands;
         char *error;
 
-        error = ctl_parse_commands(argc, argv, &local_options, &commands,
-                                   &n_commands);
+        error = ctl_parse_commands(argc - optind, argv + optind,
+                                   &local_options, &commands, &n_commands);
         if (error) {
             ctl_fatal("%s", error);
         }
@@ -5349,11 +5347,12 @@ server_cmd_init(struct ovsdb_idl *idl, bool *exiting)
 }
 
 static void
-server_loop(struct ovsdb_idl *idl)
+server_loop(struct ovsdb_idl *idl, int argc, char *argv[])
 {
     struct unixctl_server *server = NULL;
     bool exiting = false;
 
+    service_start(&argc, &argv);
     daemonize_start(false);
     int error = unixctl_server_create(unixctl_path, &server);
     if (error) {


More information about the dev mailing list