Server logging cleanup/functionality
[fio.git] / init.c
diff --git a/init.c b/init.c
index ce1645077380613fabac367f71f0dbb8962f92b7..87052b9e5476aae581ffc6475293aa5529bf7590 100644 (file)
--- a/init.c
+++ b/init.c
@@ -46,6 +46,8 @@ char *exec_profile = NULL;
 int warnings_fatal = 0;
 int terse_version = 2;
 int is_backend = 0;
+int is_client = 0;
+char *client;
 
 int write_bw_log = 0;
 int read_only = 0;
@@ -160,21 +162,21 @@ static struct option l_opts[FIO_NR_OPTIONS] = {
                .has_arg        = no_argument,
                .val            = 'S',
        },
+       {
+               .name           = (char *) "net-port",
+               .has_arg        = required_argument,
+               .val            = 'P',
+       },
+       {
+               .name           = (char *) "client",
+               .has_arg        = required_argument,
+               .val            = 'C',
+       },
        {
                .name           = NULL,
        },
 };
 
-FILE *get_f_out()
-{
-       return f_out;
-}
-
-FILE *get_f_err()
-{
-       return f_err;
-}
-
 /*
  * Return a free job structure.
  */
@@ -1079,6 +1081,9 @@ static void usage(const char *name)
                " (def 1024)\n");
        printf("\t--warnings-fatal Fio parser warnings are fatal\n");
        printf("\t--max-jobs\tMaximum number of threads/processes to support\n");
+       printf("\t--server\tStart a backend fio server\n");
+       printf("\t--client=hostname Talk to remove backend fio server at hostname\n");
+       printf("\t--net-port=port\tUse specified port for client/server connection\n");
        printf("\nFio was written by Jens Axboe <jens.axboe@oracle.com>");
        printf("\n                   Jens Axboe <jaxboe@fusionio.com>\n");
 }
@@ -1304,8 +1309,27 @@ static int parse_cmd_line(int argc, char *argv[])
                        }
                        break;
                case 'S':
+                       if (is_client) {
+                               log_err("fio: can't be both client and server\n");
+                               do_exit++;
+                               exit_val = 1;
+                               break;
+                       }
                        is_backend = 1;
                        break;
+               case 'P':
+                       fio_net_port = atoi(optarg);
+                       break;
+               case 'C':
+                       if (is_backend) {
+                               log_err("fio: can't be both client and server\n");
+                               do_exit++;
+                               exit_val = 1;
+                               break;
+                       }
+                       is_client = 1;
+                       client = strdup(optarg);
+                       break;
                default:
                        do_exit++;
                        exit_val = 1;
@@ -1316,6 +1340,12 @@ static int parse_cmd_line(int argc, char *argv[])
        if (do_exit)
                exit(exit_val);
 
+       if (is_client && fio_client_connect(client)) {
+               do_exit++;
+               exit_val = 1;
+               return 1;
+       }
+
        if (is_backend)
                return fio_server();
 
@@ -1354,8 +1384,13 @@ int parse_options(int argc, char *argv[])
        for (i = 0; i < job_files; i++) {
                if (fill_def_thread())
                        return 1;
-               if (parse_jobs_ini(ini_file[i], 0, i))
-                       return 1;
+               if (is_client) {
+                       if (fio_client_send_ini(ini_file[i]))
+                               return 1;
+               } else {
+                       if (parse_jobs_ini(ini_file[i], 0, i))
+                               return 1;
+               }
                free(ini_file[i]);
        }
 
@@ -1367,7 +1402,7 @@ int parse_options(int argc, char *argv[])
                        return 0;
                if (exec_profile)
                        return 0;
-               if (is_backend)
+               if (is_backend || is_client)
                        return 0;
 
                log_err("No jobs(s) defined\n\n");