fio: capture thread status display
authorStephen M. Cameron <stephenmcameron@gmail.com>
Fri, 24 Feb 2012 07:17:31 +0000 (08:17 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 24 Feb 2012 07:17:31 +0000 (08:17 +0100)
The thread status display uses printf to stdout.
Need a way to capture it for the gui.

Signed-off-by: Stephen M. Cameron <stephenmcameron@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
client.c
client.h
eta.c

index c794d9b1495d14c83eb8ec4f8ba7f70251552791..1b7dee66cb2f424afb29f07e225dbdc77c26af93 100644 (file)
--- a/client.c
+++ b/client.c
@@ -21,6 +21,8 @@
 #include "flist.h"
 #include "hash.h"
 
 #include "flist.h"
 #include "hash.h"
 
+extern void (*update_thread_status)(char *status_message);
+
 struct client_eta {
        struct jobs_eta eta;
        unsigned int pending;
 struct client_eta {
        struct jobs_eta eta;
        unsigned int pending;
@@ -88,6 +90,7 @@ struct client_ops fio_client_ops = {
        handle_gs,
        handle_eta,
        handle_probe,
        handle_gs,
        handle_eta,
        handle_probe,
+       NULL, /* status display, if NULL, printf is used */
 };
 
 static struct timeval eta_tv;
 };
 
 static struct timeval eta_tv;
@@ -1015,6 +1018,9 @@ int fio_handle_clients(struct client_ops *ops)
        init_thread_stat(&client_ts);
        init_group_run_stat(&client_gs);
 
        init_thread_stat(&client_ts);
        init_group_run_stat(&client_gs);
 
+       /* Used by eta.c:display_thread_status() */
+       update_thread_status = ops->thread_status_display;
+
        while (!exit_backend && nr_clients) {
                struct flist_head *entry, *tmp;
                struct fio_client *client;
        while (!exit_backend && nr_clients) {
                struct flist_head *entry, *tmp;
                struct fio_client *client;
index b91b7421e982deac5cbfb6356f31d4629ca668e8..dea35bb71f34f98b611a81a52edfe1a61caed76d 100644 (file)
--- a/client.h
+++ b/client.h
@@ -17,6 +17,8 @@ typedef void (*client_eta_op)(struct fio_client *client, struct fio_net_cmd *cmd
 
 typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *cmd);
 
 
 typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *cmd);
 
+typedef void (*client_thread_status_display_op)(char *status_message);
+
 struct client_ops {
        client_text_op_func text_op;
        client_disk_util_op_func disk_util;
 struct client_ops {
        client_text_op_func text_op;
        client_disk_util_op_func disk_util;
@@ -24,6 +26,7 @@ struct client_ops {
        client_group_stats_op group_stats;
        client_eta_op eta; 
        client_probe_op probe;
        client_group_stats_op group_stats;
        client_eta_op eta; 
        client_probe_op probe;
+       client_thread_status_display_op thread_status_display;
 };
 
 extern struct client_ops fio_client_ops;
 };
 
 extern struct client_ops fio_client_ops;
diff --git a/eta.c b/eta.c
index 6118d1af21b5afccee8c9f106bc4cbd93b557c61..0833d3412450a6ddd788369cf2c064f41918ef34 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -7,6 +7,8 @@
 
 #include "fio.h"
 
 
 #include "fio.h"
 
+void (*update_thread_status)(char *status_message) = NULL;
+
 static char run_str[REAL_MAX_JOBS + 1];
 
 /*
 static char run_str[REAL_MAX_JOBS + 1];
 
 /*
@@ -411,8 +413,12 @@ void display_thread_status(struct jobs_eta *je)
        }
        p += sprintf(p, "\r");
 
        }
        p += sprintf(p, "\r");
 
-       printf("%s", output);
-       fflush(stdout);
+       if (update_thread_status) {
+               update_thread_status(output);
+       } else {
+               printf("%s", output);
+               fflush(stdout);
+       }
 }
 
 void print_thread_status(void)
 }
 
 void print_thread_status(void)