gfio: add per-job option view
[fio.git] / gfio.c
diff --git a/gfio.c b/gfio.c
index 6f313ed08490f6c314ce2fab91973191c209e2f7..544d96aae03763ff89e3ba78459d47a854ad24d6 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -430,6 +430,18 @@ static int send_job_file(struct gui_entry *ge)
        struct gfio_client *gc = ge->client;
        int ret = 0;
 
+       /*
+        * Prune old options, we are expecting the return options
+        * when the job file is parsed remotely and returned to us.
+        */
+       while (!flist_empty(&gc->o_list)) {
+               struct gfio_client_options *gco;
+
+               gco = flist_entry(gc->o_list.next, struct gfio_client_options, list);
+               flist_del(&gco->list);
+               free(gco);
+       }
+
        ret = fio_client_send_ini(gc->client, ge->job_file);
        if (!ret)
                return 0;
@@ -616,14 +628,24 @@ static void gfio_set_client(struct gfio_client *gc, struct fio_client *client)
 
 static void gfio_client_added(struct gui_entry *ge, struct fio_client *client)
 {
+       struct gfio_client_options *gco;
        struct gfio_client *gc;
 
-       gc = malloc(sizeof(*gc));
-       memset(gc, 0, sizeof(*gc));
-       options_default_fill(&gc->o);
+       gc = calloc(1, sizeof(*gc));
+       INIT_FLIST_HEAD(&gc->o_list);
        gc->ge = ge;
        ge->client = gc;
        gfio_set_client(gc, client);
+
+       /*
+        * Just add a default set of options, need to consider how best
+        * to handle this
+        */
+       gco = calloc(1, sizeof(*gco));
+       INIT_FLIST_HEAD(&gco->list);
+       options_default_fill(&gco->o);
+       flist_add_tail(&gco->list, &gc->o_list);
+       gc->o_list_nr++;
 }
 
 static void connect_clicked(GtkWidget *widget, gpointer data)
@@ -1016,7 +1038,7 @@ static void edit_job_entry(GtkWidget *w, gpointer data)
 
        ge = get_ge_from_cur_tab(ui);
        if (ge && ge->client)
-               gopt_get_options_window(ui->window, &ge->client->o);
+               gopt_get_options_window(ui->window, ge->client);
 }
 
 static void start_job_entry(GtkWidget *w, gpointer data)
@@ -1688,6 +1710,8 @@ int main(int argc, char *argv[], char *envp[])
        if (fio_init_options())
                return 1;
 
+       gopt_init();
+
        memset(&main_ui, 0, sizeof(main_ui));
        main_ui.ge_hash = g_hash_table_new(g_int_hash, g_int_equal);
 
@@ -1698,5 +1722,7 @@ int main(int argc, char *argv[], char *envp[])
        gdk_threads_leave();
 
        g_hash_table_destroy(main_ui.ge_hash);
+
+       gopt_exit();
        return 0;
 }