X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=gfio.c;h=544d96aae03763ff89e3ba78459d47a854ad24d6;hp=cf6b5090e26c9e945eb8f6e8ab7b5959237b14c0;hb=753e9e642f1cf7aa6e46a31aeebc65da26c8bf2e;hpb=b98ab718031a25ecfd3fa64df3f9992baa83b5ac diff --git a/gfio.c b/gfio.c index cf6b5090..544d96aa 100644 --- a/gfio.c +++ b/gfio.c @@ -41,7 +41,7 @@ static int gfio_server_running; static unsigned int gfio_graph_limit = 100; GdkColor gfio_color_white; -const char *gfio_graph_font; +const char *gfio_graph_font = GRAPH_DEFAULT_FONT; typedef void (*clickfunction)(GtkWidget *widget, gpointer data); @@ -75,43 +75,45 @@ static struct button_spec { }, }; -static struct graph *setup_iops_graph(void) +static void setup_iops_graph(struct gfio_graphs *gg) { struct graph *g; g = graph_new(DRAWING_AREA_XDIM / 2.0, DRAWING_AREA_YDIM, gfio_graph_font); graph_title(g, "IOPS (IOs/sec)"); graph_x_title(g, "Time (secs)"); - graph_add_label(g, "Read IOPS"); - graph_add_label(g, "Write IOPS"); - graph_set_color(g, "Read IOPS", 0.13, 0.54, 0.13); - graph_set_color(g, "Write IOPS", 1.0, 0.0, 0.0); + gg->read_iops = graph_add_label(g, "Read IOPS"); + gg->write_iops = graph_add_label(g, "Write IOPS"); + graph_set_color(g, gg->read_iops, 0.13, 0.54, 0.13); + graph_set_color(g, gg->write_iops, 1.0, 0.0, 0.0); line_graph_set_data_count_limit(g, gfio_graph_limit); graph_add_extra_space(g, 0.0, 0.0, 0.0, 0.0); - return g; + graph_set_graph_all_zeroes(g, 0); + gg->iops_graph = g; } -static struct graph *setup_bandwidth_graph(void) +static void setup_bandwidth_graph(struct gfio_graphs *gg) { struct graph *g; g = graph_new(DRAWING_AREA_XDIM / 2.0, DRAWING_AREA_YDIM, gfio_graph_font); graph_title(g, "Bandwidth (bytes/sec)"); graph_x_title(g, "Time (secs)"); - graph_add_label(g, "Read Bandwidth"); - graph_add_label(g, "Write Bandwidth"); - graph_set_color(g, "Read Bandwidth", 0.13, 0.54, 0.13); - graph_set_color(g, "Write Bandwidth", 1.0, 0.0, 0.0); + gg->read_bw = graph_add_label(g, "Read Bandwidth"); + gg->write_bw = graph_add_label(g, "Write Bandwidth"); + graph_set_color(g, gg->read_bw, 0.13, 0.54, 0.13); + graph_set_color(g, gg->write_bw, 1.0, 0.0, 0.0); graph_set_base_offset(g, 1); line_graph_set_data_count_limit(g, 100); graph_add_extra_space(g, 0.0, 0.0, 0.0, 0.0); - return g; + graph_set_graph_all_zeroes(g, 0); + gg->bandwidth_graph = g; } static void setup_graphs(struct gfio_graphs *g) { - g->iops_graph = setup_iops_graph(); - g->bandwidth_graph = setup_bandwidth_graph(); + setup_iops_graph(g); + setup_bandwidth_graph(g); } void clear_ge_ui_info(struct gui_entry *ge) @@ -428,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; @@ -614,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) @@ -810,6 +834,12 @@ static int do_file_open(struct gui_entry *ge, const gchar *uri) client = fio_client_add_explicit(&gfio_client_ops, ge->host, ge->type, ge->port); if (client) { + char *label = strdup(uri); + + basename(label); + gtk_label_set_text(GTK_LABEL(ge->page_label), basename(label)); + free(label); + gfio_client_added(ge, client); file_add_recent(ge->ui, uri); return 0; @@ -1008,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) @@ -1039,26 +1069,38 @@ static void view_results(GtkWidget *w, gpointer data) gfio_display_end_results(gc); } -static void __update_graph_limits(struct gfio_graphs *g) +static void __update_graph_settings(struct gfio_graphs *g) { line_graph_set_data_count_limit(g->iops_graph, gfio_graph_limit); + graph_set_font(g->iops_graph, gfio_graph_font); line_graph_set_data_count_limit(g->bandwidth_graph, gfio_graph_limit); + graph_set_font(g->bandwidth_graph, gfio_graph_font); } -static void ge_update_lim_fn(gpointer key, gpointer value, gpointer data) +static void ge_update_settings_fn(gpointer key, gpointer value, gpointer data) { struct gui_entry *ge = (struct gui_entry *) value; + GdkEvent *ev; + + __update_graph_settings(&ge->graphs); - __update_graph_limits(&ge->graphs); + ev = gdk_event_new(GDK_EXPOSE); + g_signal_emit_by_name(G_OBJECT(ge->graphs.drawing_area), "expose_event", GTK_WIDGET(ge->graphs.drawing_area), ev, &ge->graphs); + gdk_event_free(ev); } static void update_graph_limits(void) { struct gui *ui = &main_ui; + GdkEvent *ev; - __update_graph_limits(&ui->graphs); + __update_graph_settings(&ui->graphs); - g_hash_table_foreach(ui->ge_hash, ge_update_lim_fn, NULL); + ev = gdk_event_new(GDK_EXPOSE); + g_signal_emit_by_name(G_OBJECT(ui->graphs.drawing_area), "expose_event", GTK_WIDGET(ui->graphs.drawing_area), ev, &ui->graphs); + gdk_event_free(ev); + + g_hash_table_foreach(ui->ge_hash, ge_update_settings_fn, NULL); } static void preferences(GtkWidget *w, gpointer data) @@ -1085,7 +1127,7 @@ static void preferences(GtkWidget *w, gpointer data) entry = gtk_label_new("Font face to use for graph labels"); gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 5); - font = gtk_font_button_new(); + font = gtk_font_button_new_with_font(gfio_graph_font); gtk_box_pack_start(GTK_BOX(hbox), font, FALSE, FALSE, 5); box = gtk_vbox_new(FALSE, 6); @@ -1383,7 +1425,7 @@ static GtkWidget *new_client_page(struct gui_entry *ge) gtk_container_add(GTK_CONTAINER(bottom_align), ge->buttonbox); gtk_box_pack_start(GTK_BOX(main_vbox), bottom_align, FALSE, FALSE, 0); - add_buttons(ge, buttonspeclist, ARRAYSIZE(buttonspeclist)); + add_buttons(ge, buttonspeclist, ARRAY_SIZE(buttonspeclist)); /* * Set up thread status progress bar @@ -1668,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); @@ -1678,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; }