Start of client/server
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/init.c b/init.c
index 62c070e..5d57091 100644
--- a/init.c
+++ b/init.c
@@ -19,6 +19,7 @@
#include "filehash.h"
#include "verify.h"
#include "profile.h"
+#include "server.h"
#include "lib/getopt.h"
@@ -44,6 +45,7 @@
char *exec_profile = NULL;
int warnings_fatal = 0;
int terse_version = 2;
+int is_backend = 0;
int write_bw_log = 0;
int read_only = 0;
@@ -154,6 +156,11 @@
.val = 'V',
},
{
+ .name = (char *) "server",
+ .has_arg = no_argument,
+ .val = 'S',
+ },
+ {
.name = NULL,
},
};
@@ -799,7 +806,7 @@
/*
* This is our [ini] type file parser.
*/
-static int parse_jobs_ini(char *file, int stonewall_flag)
+int parse_jobs_ini(char *file, int is_buf, int stonewall_flag)
{
unsigned int global;
struct thread_data *td;
@@ -813,14 +820,18 @@
char **opts;
int i, alloc_opts, num_opts;
- if (!strcmp(file, "-"))
- f = stdin;
- else
- f = fopen(file, "r");
+ if (is_buf)
+ f = NULL;
+ else {
+ if (!strcmp(file, "-"))
+ f = stdin;
+ else
+ f = fopen(file, "r");
- if (!f) {
- perror("fopen job file");
- return 1;
+ if (!f) {
+ perror("fopen job file");
+ return 1;
+ }
}
string = malloc(4096);
@@ -842,7 +853,10 @@
* haven't handled.
*/
if (!skip_fgets) {
- p = fgets(string, 4095, f);
+ if (is_buf)
+ p = strsep(&file, "\n");
+ else
+ p = fgets(string, 4095, f);
if (!p)
break;
}
@@ -896,7 +910,14 @@
num_opts = 0;
memset(opts, 0, alloc_opts * sizeof(char *));
- while ((p = fgets(string, 4096, f)) != NULL) {
+ while (1) {
+ if (is_buf)
+ p = strsep(&file, "\n");
+ else
+ p = fgets(string, 4096, f);
+ if (!p)
+ break;
+
if (is_empty_or_comment(p))
continue;
@@ -949,7 +970,7 @@
free(string);
free(name);
free(opts);
- if (f != stdin)
+ if (!is_buf && f != stdin)
fclose(f);
return ret;
}
@@ -1282,6 +1303,9 @@
exit_val = 1;
}
break;
+ case 'S':
+ is_backend = 1;
+ break;
default:
do_exit++;
exit_val = 1;
@@ -1292,6 +1316,9 @@
if (do_exit)
exit(exit_val);
+ if (is_backend)
+ fio_server();
+
if (td) {
if (!ret)
ret = add_job(td, td->o.name ?: "fio", 0);
@@ -1327,7 +1354,7 @@
for (i = 0; i < job_files; i++) {
if (fill_def_thread())
return 1;
- if (parse_jobs_ini(ini_file[i], i))
+ if (parse_jobs_ini(ini_file[i], 0, i))
return 1;
free(ini_file[i]);
}