From: Stephen M. Cameron Date: Fri, 24 Feb 2012 07:17:31 +0000 (+0100) Subject: fio: capture thread status display X-Git-Tag: gfio-0.1~307 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=ba936c4b474bd4c5d4b07127561d07644823bc65;p=fio.git fio: capture thread status display The thread status display uses printf to stdout. Need a way to capture it for the gui. Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- diff --git a/client.c b/client.c index c794d9b1..1b7dee66 100644 --- a/client.c +++ b/client.c @@ -21,6 +21,8 @@ #include "flist.h" #include "hash.h" +extern void (*update_thread_status)(char *status_message); + 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, + NULL, /* status display, if NULL, printf is used */ }; 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); + /* 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; diff --git a/client.h b/client.h index b91b7421..dea35bb7 100644 --- 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_thread_status_display_op)(char *status_message); + 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_thread_status_display_op thread_status_display; }; extern struct client_ops fio_client_ops; diff --git a/eta.c b/eta.c index 6118d1af..0833d341 100644 --- a/eta.c +++ b/eta.c @@ -7,6 +7,8 @@ #include "fio.h" +void (*update_thread_status)(char *status_message) = NULL; + static char run_str[REAL_MAX_JOBS + 1]; /* @@ -411,8 +413,12 @@ void display_thread_status(struct jobs_eta *je) } 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)