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

Message ID 20181005145427.25560-1-aserdean@ovn.org
State New
Headers show
Series
  • [ovs-dev,v3,1/2] windows, ovn-nbctl: Add service_start call inside the server loop
Related show

Commit Message

Alin Gabriel Serdean Oct. 5, 2018, 2:54 p.m.
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@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Co-authored-by: Ben Pfaff <blp@ovn.org>
---
v3: Switch to Ben's patch
v2: Remove OVS_UNUSED, add acks
---
---
 ovn/utilities/ovn-nbctl.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Patch

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index eabd30308..7e42b53a9 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) {