Skip to contentSkip to conversation

suggested patch to let fio accept client ips from a file

PATCH Ben England 1 participant 1 message Feb 15, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

The following patch will allow fio to accept server IPs from a file. This is particularly useful when you have large numbers of fio servers (example: virtual machine guests) that participate in a test. To use this, simply use the --client option but instead of specifying a host name or IP, provide a pathname for a file containing a list of host names/addresses, one host per line.

init.c renamed from init.c.sav +21 -0
@@ -2226,6 +2226,27 @@
 				exit_val = 1;
 				break;
 			}
+                        if (0 == access(optarg, R_OK)) {
+                                /* this is really a file containing a list of host addrs or names */
+                                char hostaddr[257] = {0};
+                                FILE * hostf = fopen(optarg, "r");
+                                if (!hostf) {
+                                        log_err("fio: could not open client list file %s for read\n", optarg);
+                                        do_exit++;
+                                        exit_val = 1;
+                                        break;
+                                }
+                                while (fscanf(hostf, "%s", hostaddr) == 1) {
+                                        if (fio_client_add(&fio_client_ops, hostaddr, &cur_client)) {
+                                                log_err("fio: failed adding client %s from file %s\n", hostaddr, optarg);
+                                                do_exit++;
+                                                exit_val = 1;
+                                                break;
+                                        }
+                                }
+                                fclose(hostf);
+                                break; /* no possibility of job file for "this client only" */
+                        }
 			if (fio_client_add(&fio_client_ops, optarg, &cur_client)) {
 				log_err("fio: failed adding client %s\n", optarg);
 				do_exit++;