client: duplicate arguments to "empty" clients

Now you can do:

fio --client=host1 --client=host2 --arg1 --arg2 --arg3

and arg1,2,3 are passed to both clients. If you do:

fio --client=host1 --arg1 --client=host2 --arg2 --arg3

then arg1 is passed to host1, while arg2,3 are passed to host2.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/client.c b/client.c
index 097fcc5..358903b 100644
--- a/client.c
+++ b/client.c
@@ -28,6 +28,7 @@
 struct fio_client {
 	struct flist_head list;
 	struct flist_head hash_list;
+	struct flist_head arg_list;
 	struct sockaddr_in addr;
 	struct sockaddr_un addr_un;
 	char *hostname;
@@ -61,6 +62,8 @@
 static FLIST_HEAD(client_list);
 static FLIST_HEAD(eta_list);
 
+static FLIST_HEAD(arg_list);
+
 #define FIO_CLIENT_HASH_BITS	7
 #define FIO_CLIENT_HASH_SZ	(1 << FIO_CLIENT_HASH_BITS)
 #define FIO_CLIENT_HASH_MASK	(FIO_CLIENT_HASH_SZ - 1)
@@ -143,22 +146,47 @@
 void fio_client_add_cmd_option(void *cookie, const char *opt)
 {
 	struct fio_client *client = cookie;
+	struct flist_head *entry;
 
 	if (!client || !opt)
 		return;
 
 	__fio_client_add_cmd_option(client, opt);
+
+	/*
+	 * Duplicate arguments to shared client group
+	 */
+	flist_for_each(entry, &arg_list) {
+		client = flist_entry(entry, struct fio_client, arg_list);
+
+		__fio_client_add_cmd_option(client, opt);
+	}
 }
 
 int fio_client_add(const char *hostname, void **cookie)
 {
+	struct fio_client *existing = *cookie;
 	struct fio_client *client;
 
+	if (existing) {
+		/*
+		 * We always add our "exec" name as the option, hence 1
+		 * means empty.
+		 */
+		if (existing->argc == 1)
+			flist_add_tail(&existing->arg_list, &arg_list);
+		else {
+			while (!flist_empty(&arg_list))
+				flist_del_init(arg_list.next);
+		}
+	}
+
 	client = malloc(sizeof(*client));
 	memset(client, 0, sizeof(*client));
 
 	INIT_FLIST_HEAD(&client->list);
 	INIT_FLIST_HEAD(&client->hash_list);
+	INIT_FLIST_HEAD(&client->arg_list);
 	INIT_FLIST_HEAD(&client->eta_list);
 
 	if (fio_server_parse_string(hostname, &client->hostname,