server: include number of CPUs in probe reply
[fio.git] / gclient.c
index aaecad61df8f3af329c40bc364c787fd9ac4c049..8675f617fb2d4dfd46d4326c16c5f88e8baf56bd 100644 (file)
--- a/gclient.c
+++ b/gclient.c
@@ -12,6 +12,7 @@
 #include "gerror.h"
 #include "graph.h"
 #include "gclient.h"
+#include "printing.h"
 
 static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
                            struct group_run_stats *rs);
@@ -33,9 +34,17 @@ static void results_close(GtkWidget *w, gpointer *data)
        gtk_widget_destroy(ge->results_window);
 }
 
+static void results_print(GtkWidget *w, gpointer *data)
+{
+       struct gui_entry *ge = (struct gui_entry *) data;
+
+       gfio_print_results(ge);
+}
+
 static GtkActionEntry results_menu_items[] = {
        { "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL},
        { "GraphMenuAction", GTK_STOCK_FILE, "Graph", NULL, NULL, NULL},
+       { "PrintFile", GTK_STOCK_PRINT, "Print", "<Control>P", NULL, G_CALLBACK(results_print) },
        { "CloseFile", GTK_STOCK_CLOSE, "Close", "<Control>W", NULL, G_CALLBACK(results_close) },
 };
 static gint results_nmenu_items = sizeof(results_menu_items) / sizeof(results_menu_items[0]);
@@ -44,6 +53,7 @@ static const gchar *results_ui_string = " \
        <ui> \
                <menubar name=\"MainMenu\"> \
                        <menu name=\"FileMenu\" action=\"FileMenuAction\"> \
+                               <menuitem name=\"Print\" action=\"PrintFile\" /> \
                                <menuitem name=\"Close\" action=\"CloseFile\" /> \
                        </menu> \
                        <menu name=\"GraphMenu\" action=\"GraphMenuAction\"> \
@@ -122,7 +132,7 @@ static void gfio_text_op(struct fio_client *client, struct fio_net_cmd *cmd)
        gtk_list_store_append(ui->log_model, &iter);
        gtk_list_store_set(ui->log_model, &iter, 0, timebuf, -1);
        gtk_list_store_set(ui->log_model, &iter, 1, client->hostname, -1);
-       gtk_list_store_set(ui->log_model, &iter, 2, p->level, -1);
+       gtk_list_store_set(ui->log_model, &iter, 2, log_get_level(p->level), -1);
        gtk_list_store_set(ui->log_model, &iter, 3, p->buf, -1);
 
        if (p->level == FIO_LOG_ERR)
@@ -416,7 +426,7 @@ static void gfio_update_client_eta(struct fio_client *client, struct jobs_eta *j
 
                sprintf(dst, " - %s", eta_str);
        }
-               
+
        gfio_update_thread_status(ge, output, perc);
        gdk_threads_leave();
 }
@@ -504,7 +514,7 @@ static void gfio_update_all_eta(struct jobs_eta *je)
 
                sprintf(dst, " - %s", eta_str);
        }
-               
+
        gfio_update_thread_status_all(ui, output, perc);
        gdk_threads_leave();
 }
@@ -528,6 +538,9 @@ static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd)
        if (!client->name)
                client->name = strdup((char *) probe->hostname);
 
+       gc->client_cpus = le32_to_cpu(probe->cpus);
+       gc->client_flags = le64_to_cpu(probe->flags);
+
        gdk_threads_enter();
 
        gtk_label_set_text(GTK_LABEL(ge->probe.hostname), (char *) probe->hostname);
@@ -550,22 +563,35 @@ static void gfio_quit_op(struct fio_client *client, struct fio_net_cmd *cmd)
        gdk_threads_leave();
 }
 
+static struct thread_options *gfio_client_add_job(struct gfio_client *gc,
+                       struct thread_options_pack *top)
+{
+       struct gfio_client_options *gco;
+
+       gco = calloc(1, sizeof(*gco));
+       convert_thread_options_to_cpu(&gco->o, top);
+       INIT_FLIST_HEAD(&gco->list);
+       flist_add_tail(&gco->list, &gc->o_list);
+       gc->o_list_nr = 1;
+       return &gco->o;
+}
+
 static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd)
 {
        struct cmd_add_job_pdu *p = (struct cmd_add_job_pdu *) cmd->payload;
        struct gfio_client *gc = client->client_data;
-       struct thread_options *o = &gc->o;
        struct gui_entry *ge = gc->ge;
+       struct thread_options *o;
        char *c1, *c2, *c3, *c4;
        char tmp[80];
 
        p->thread_number = le32_to_cpu(p->thread_number);
        p->groupid = le32_to_cpu(p->groupid);
-       convert_thread_options_to_cpu(o, &p->top);
+       o = gfio_client_add_job(gc, &p->top);
 
        gdk_threads_enter();
 
-       gtk_combo_box_append_text(GTK_COMBO_BOX(ge->eta.names), (gchar *) o->name);
+       gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(ge->eta.names), (gchar *) o->name);
        gtk_combo_box_set_active(GTK_COMBO_BOX(ge->eta.names), 0);
 
        sprintf(tmp, "%s %s", o->odirect ? "direct" : "buffered", ddir_str(o->td_ddir));
@@ -597,6 +623,16 @@ static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd)
        gdk_threads_leave();
 }
 
+static void gfio_update_job_op(struct fio_client *client,
+                              struct fio_net_cmd *cmd)
+{
+       uint32_t *pdu_error = (uint32_t *) cmd->payload;
+       struct gfio_client *gc = client->client_data;
+
+       gc->update_job_status = le32_to_cpu(*pdu_error);
+       gc->update_job_done = 1;
+}
+
 static void gfio_client_timed_out(struct fio_client *client)
 {
        struct gfio_client *gc = client->client_data;
@@ -879,7 +915,7 @@ static int on_expose_lat_drawing_area(GtkWidget *w, GdkEvent *event, gpointer p)
        struct graph *g = p;
        cairo_t *cr;
 
-       cr = gdk_cairo_create(w->window);
+       cr = gdk_cairo_create(gtk_widget_get_window(w));
 #if 0
        if (graph_has_tooltips(g)) {
                g_object_set(w, "has-tooltip", TRUE, NULL);
@@ -896,10 +932,12 @@ static int on_expose_lat_drawing_area(GtkWidget *w, GdkEvent *event, gpointer p)
 static gint on_config_lat_drawing_area(GtkWidget *w, GdkEventConfigure *event,
                                       gpointer data)
 {
+       guint width = gtk_widget_get_allocated_width(w);
+       guint height = gtk_widget_get_allocated_height(w);
        struct graph *g = data;
 
-       graph_set_size(g, w->allocation.width, w->allocation.height);
-       graph_set_size(g, w->allocation.width, w->allocation.height);
+       graph_set_size(g, width, height);
+       graph_set_size(g, width, height);
        graph_set_position(g, 0, 0);
        return TRUE;
 }
@@ -938,7 +976,7 @@ static void gfio_show_latency_buckets(struct gfio_client *gc, GtkWidget *vbox,
         */
        if (start == -1U)
                return;
-               
+
        tree_view = gfio_output_lat_buckets(&io_u_lat[start], &ranges[start], end - start + 1);
        ge->lat_bucket_graph = setup_lat_bucket_graph("Latency Buckets", &io_u_lat[start], &ranges[start], end - start + 1, 700.0, 300.0);
 
@@ -954,8 +992,8 @@ static void gfio_show_latency_buckets(struct gfio_client *gc, GtkWidget *vbox,
        gtk_widget_set_size_request(GTK_WIDGET(drawing_area), 700, 300);
        gtk_widget_modify_bg(drawing_area, GTK_STATE_NORMAL, &gfio_color_white);
        gtk_container_add(GTK_CONTAINER(completion_vbox), drawing_area);
-       g_signal_connect(G_OBJECT(drawing_area), "expose_event", G_CALLBACK(on_expose_lat_drawing_area), ge->lat_bucket_graph);
-        g_signal_connect(G_OBJECT(drawing_area), "configure_event", G_CALLBACK(on_config_lat_drawing_area), ge->lat_bucket_graph);
+       g_signal_connect(G_OBJECT(drawing_area), GFIO_DRAW_EVENT, G_CALLBACK(on_expose_lat_drawing_area), ge->lat_bucket_graph);
+       g_signal_connect(G_OBJECT(drawing_area), "configure_event", G_CALLBACK(on_config_lat_drawing_area), ge->lat_bucket_graph);
 
        gtk_box_pack_start(GTK_BOX(hbox), tree_view, TRUE, TRUE, 3);
 }
@@ -1110,7 +1148,7 @@ static void gfio_show_clat_percentiles(struct gfio_client *gc,
        gtk_widget_set_size_request(GTK_WIDGET(drawing_area), 700, 300);
        gtk_widget_modify_bg(drawing_area, GTK_STATE_NORMAL, &gfio_color_white);
        gtk_container_add(GTK_CONTAINER(completion_vbox), drawing_area);
-       g_signal_connect(G_OBJECT(drawing_area), "expose_event", G_CALLBACK(on_expose_lat_drawing_area), ge->clat_graph);
+       g_signal_connect(G_OBJECT(drawing_area), GFIO_DRAW_EVENT, G_CALLBACK(on_expose_lat_drawing_area), ge->clat_graph);
        g_signal_connect(G_OBJECT(drawing_area), "configure_event", G_CALLBACK(on_config_lat_drawing_area), ge->clat_graph);
 
        gtk_box_pack_start(GTK_BOX(hbox), tree_view, TRUE, TRUE, 3);
@@ -1153,7 +1191,7 @@ static void gfio_show_ddir_status(struct gfio_client *gc, GtkWidget *mbox,
        gtk_box_pack_start(GTK_BOX(mbox), box, TRUE, FALSE, 3);
 
        frame = gtk_frame_new(ddir_label[ddir]);
-       gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 5);
+       gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 5);
 
        main_vbox = gtk_vbox_new(FALSE, 3);
        gtk_container_add(GTK_CONTAINER(frame), main_vbox);
@@ -1338,6 +1376,7 @@ struct client_ops gfio_client_ops = {
        .probe                  = gfio_probe_op,
        .quit                   = gfio_quit_op,
        .add_job                = gfio_add_job_op,
+       .update_job             = gfio_update_job_op,
        .timed_out              = gfio_client_timed_out,
        .stop                   = gfio_client_stop,
        .start                  = gfio_client_start,