Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
Jens Axboe | 142575e | 2011-09-30 17:35:45 -0600 | [diff] [blame] | 3 | #include <stdarg.h> |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 4 | #include <unistd.h> |
| 5 | #include <limits.h> |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 6 | #include <errno.h> |
| 7 | #include <fcntl.h> |
| 8 | #include <sys/poll.h> |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 9 | #include <sys/types.h> |
| 10 | #include <sys/wait.h> |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 11 | #include <sys/mman.h> |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 12 | #include <netinet/in.h> |
| 13 | #include <arpa/inet.h> |
| 14 | #include <netdb.h> |
| 15 | |
| 16 | #include "fio.h" |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 17 | #include "server.h" |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 18 | #include "crc/crc16.h" |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 19 | |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 20 | int fio_net_port = 8765; |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 21 | |
Jens Axboe | 009b1be | 2011-09-29 18:27:02 -0600 | [diff] [blame] | 22 | int exit_backend = 0; |
| 23 | |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 24 | static char *job_buf; |
| 25 | static unsigned int job_cur_len; |
| 26 | static unsigned int job_max_len; |
| 27 | |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 28 | static int server_fd; |
| 29 | |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 30 | int fio_send_data(int sk, const void *p, unsigned int len) |
| 31 | { |
| 32 | do { |
| 33 | int ret = send(sk, p, len, 0); |
| 34 | |
| 35 | if (ret > 0) { |
| 36 | len -= ret; |
| 37 | if (!len) |
| 38 | break; |
| 39 | p += ret; |
| 40 | continue; |
| 41 | } else if (!ret) |
| 42 | break; |
| 43 | else if (errno == EAGAIN || errno == EINTR) |
| 44 | continue; |
| 45 | } while (!exit_backend); |
| 46 | |
| 47 | if (!len) |
| 48 | return 0; |
| 49 | |
| 50 | return 1; |
| 51 | } |
| 52 | |
| 53 | int fio_recv_data(int sk, void *p, unsigned int len) |
| 54 | { |
| 55 | do { |
| 56 | int ret = recv(sk, p, len, MSG_WAITALL); |
| 57 | |
| 58 | if (ret > 0) { |
| 59 | len -= ret; |
| 60 | if (!len) |
| 61 | break; |
| 62 | p += ret; |
| 63 | continue; |
| 64 | } else if (!ret) |
| 65 | break; |
| 66 | else if (errno == EAGAIN || errno == EINTR) |
| 67 | continue; |
| 68 | } while (!exit_backend); |
| 69 | |
| 70 | if (!len) |
| 71 | return 0; |
| 72 | |
| 73 | return -1; |
| 74 | } |
| 75 | |
| 76 | static int verify_convert_cmd(struct fio_net_cmd *cmd) |
| 77 | { |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 78 | uint16_t crc; |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 79 | |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 80 | cmd->cmd_crc16 = le16_to_cpu(cmd->cmd_crc16); |
| 81 | cmd->pdu_crc16 = le16_to_cpu(cmd->pdu_crc16); |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 82 | |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 83 | crc = crc16(cmd, FIO_NET_CMD_CRC_SZ); |
| 84 | if (crc != cmd->cmd_crc16) { |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 85 | log_err("fio: server bad crc on command (got %x, wanted %x)\n", |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 86 | cmd->cmd_crc16, crc); |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 87 | return 1; |
| 88 | } |
| 89 | |
| 90 | cmd->version = le16_to_cpu(cmd->version); |
| 91 | cmd->opcode = le16_to_cpu(cmd->opcode); |
| 92 | cmd->flags = le32_to_cpu(cmd->flags); |
| 93 | cmd->serial = le64_to_cpu(cmd->serial); |
| 94 | cmd->pdu_len = le32_to_cpu(cmd->pdu_len); |
| 95 | |
| 96 | switch (cmd->version) { |
| 97 | case FIO_SERVER_VER1: |
| 98 | break; |
| 99 | default: |
| 100 | log_err("fio: bad server cmd version %d\n", cmd->version); |
| 101 | return 1; |
| 102 | } |
| 103 | |
| 104 | if (cmd->pdu_len > FIO_SERVER_MAX_PDU) { |
| 105 | log_err("fio: command payload too large: %u\n", cmd->pdu_len); |
| 106 | return 1; |
| 107 | } |
| 108 | |
| 109 | return 0; |
| 110 | } |
| 111 | |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 112 | struct fio_net_cmd *fio_net_cmd_read(int sk) |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 113 | { |
| 114 | struct fio_net_cmd cmd, *ret = NULL; |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 115 | uint16_t crc; |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 116 | |
| 117 | if (fio_recv_data(sk, &cmd, sizeof(cmd))) |
| 118 | return NULL; |
| 119 | |
| 120 | /* We have a command, verify it and swap if need be */ |
| 121 | if (verify_convert_cmd(&cmd)) |
| 122 | return NULL; |
| 123 | |
| 124 | /* Command checks out, alloc real command and fill in */ |
| 125 | ret = malloc(sizeof(cmd) + cmd.pdu_len); |
| 126 | memcpy(ret, &cmd, sizeof(cmd)); |
| 127 | |
| 128 | if (!ret->pdu_len) |
| 129 | return ret; |
| 130 | |
| 131 | /* There's payload, get it */ |
| 132 | if (fio_recv_data(sk, (void *) ret + sizeof(*ret), ret->pdu_len)) { |
| 133 | free(ret); |
| 134 | return NULL; |
| 135 | } |
| 136 | |
| 137 | /* Verify payload crc */ |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 138 | crc = crc16(ret->payload, ret->pdu_len); |
| 139 | if (crc != ret->pdu_crc16) { |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 140 | log_err("fio: server bad crc on payload (got %x, wanted %x)\n", |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 141 | ret->pdu_crc16, crc); |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 142 | free(ret); |
| 143 | return NULL; |
| 144 | } |
| 145 | |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 146 | return ret; |
| 147 | } |
| 148 | |
| 149 | void fio_net_cmd_crc(struct fio_net_cmd *cmd) |
| 150 | { |
| 151 | uint32_t pdu_len; |
| 152 | |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 153 | cmd->cmd_crc16 = cpu_to_le16(crc16(cmd, FIO_NET_CMD_CRC_SZ)); |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 154 | |
| 155 | pdu_len = le32_to_cpu(cmd->pdu_len); |
| 156 | if (pdu_len) |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 157 | cmd->pdu_crc16 = cpu_to_le16(crc16(cmd->payload, pdu_len)); |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | static int send_simple_command(int sk, uint16_t opcode, uint64_t serial) |
| 161 | { |
| 162 | struct fio_net_cmd cmd = { |
| 163 | .version = cpu_to_le16(FIO_SERVER_VER1), |
| 164 | .opcode = cpu_to_le16(opcode), |
| 165 | .serial = cpu_to_le16(serial), |
| 166 | }; |
| 167 | |
| 168 | fio_net_cmd_crc(&cmd); |
| 169 | |
| 170 | return fio_send_data(sk, &cmd, sizeof(cmd)); |
| 171 | } |
| 172 | |
| 173 | /* |
| 174 | * Send an ack for this command |
| 175 | */ |
| 176 | static int ack_command(int sk, struct fio_net_cmd *cmd) |
| 177 | { |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 178 | #if 0 |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 179 | return send_simple_command(sk, FIO_NET_CMD_ACK, cmd->serial); |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 180 | #else |
| 181 | return 0; |
| 182 | #endif |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | #if 0 |
| 186 | static int nak_command(int sk, struct fio_net_cmd *cmd) |
| 187 | { |
| 188 | return send_simple_command(sk, FIO_NET_CMD_NAK, cmd->serial); |
| 189 | } |
| 190 | #endif |
| 191 | |
| 192 | static int handle_cur_job(struct fio_net_cmd *cmd, int done) |
| 193 | { |
| 194 | unsigned int left = job_max_len - job_cur_len; |
| 195 | int ret = 0; |
| 196 | |
| 197 | if (left < cmd->pdu_len) { |
| 198 | job_buf = realloc(job_buf, job_max_len + 2 * cmd->pdu_len); |
| 199 | job_max_len += 2 * cmd->pdu_len; |
| 200 | } |
| 201 | |
| 202 | memcpy(job_buf + job_cur_len, cmd->payload, cmd->pdu_len); |
| 203 | job_cur_len += cmd->pdu_len; |
| 204 | |
| 205 | if (done) { |
| 206 | parse_jobs_ini(job_buf, 1, 0); |
| 207 | ret = exec_run(); |
| 208 | reset_fio_state(); |
| 209 | free(job_buf); |
| 210 | job_buf = NULL; |
| 211 | job_cur_len = job_max_len = 0; |
| 212 | } |
| 213 | |
| 214 | return ret; |
| 215 | } |
| 216 | |
| 217 | static int handle_command(struct fio_net_cmd *cmd) |
| 218 | { |
| 219 | int ret; |
| 220 | |
| 221 | switch (cmd->opcode) { |
| 222 | case FIO_NET_CMD_QUIT: |
| 223 | exit_backend = 1; |
| 224 | return 1; |
| 225 | case FIO_NET_CMD_ACK: |
| 226 | return 0; |
| 227 | case FIO_NET_CMD_NAK: |
| 228 | return 1; |
| 229 | case FIO_NET_CMD_JOB: |
| 230 | ret = handle_cur_job(cmd, 0); |
| 231 | break; |
| 232 | case FIO_NET_CMD_JOB_END: |
| 233 | ret = handle_cur_job(cmd, 1); |
| 234 | break; |
| 235 | default: |
| 236 | log_err("fio: unknown opcode: %d\n", cmd->opcode); |
| 237 | ret = 1; |
| 238 | } |
| 239 | |
| 240 | return ret; |
| 241 | } |
| 242 | |
| 243 | static int handle_connection(int sk) |
| 244 | { |
| 245 | struct fio_net_cmd *cmd = NULL; |
| 246 | int ret = 0; |
| 247 | |
| 248 | /* read forever */ |
| 249 | while (!exit_backend) { |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 250 | cmd = fio_net_cmd_read(sk); |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 251 | if (!cmd) { |
| 252 | ret = 1; |
| 253 | break; |
| 254 | } |
| 255 | |
| 256 | ret = ack_command(sk, cmd); |
| 257 | if (ret) |
| 258 | break; |
| 259 | |
| 260 | ret = handle_command(cmd); |
| 261 | if (ret) |
| 262 | break; |
| 263 | |
| 264 | free(cmd); |
| 265 | } |
| 266 | |
| 267 | if (cmd) |
| 268 | free(cmd); |
| 269 | |
| 270 | return ret; |
| 271 | } |
| 272 | |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 273 | static int accept_loop(int listen_sk) |
| 274 | { |
| 275 | struct sockaddr addr; |
| 276 | unsigned int len = sizeof(addr); |
Jens Axboe | 009b1be | 2011-09-29 18:27:02 -0600 | [diff] [blame] | 277 | struct pollfd pfd; |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 278 | int ret, sk, flags, exitval = 0; |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 279 | |
Jens Axboe | 009b1be | 2011-09-29 18:27:02 -0600 | [diff] [blame] | 280 | flags = fcntl(listen_sk, F_GETFL); |
| 281 | flags |= O_NONBLOCK; |
| 282 | fcntl(listen_sk, F_SETFL, flags); |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 283 | again: |
Jens Axboe | 009b1be | 2011-09-29 18:27:02 -0600 | [diff] [blame] | 284 | pfd.fd = listen_sk; |
| 285 | pfd.events = POLLIN; |
| 286 | do { |
| 287 | ret = poll(&pfd, 1, 100); |
| 288 | if (ret < 0) { |
| 289 | if (errno == EINTR) |
| 290 | break; |
Jens Axboe | fcee5ff | 2011-09-30 22:50:39 -0600 | [diff] [blame^] | 291 | log_err("fio: poll: %s\n", strerror(errno)); |
Jens Axboe | 009b1be | 2011-09-29 18:27:02 -0600 | [diff] [blame] | 292 | goto out; |
| 293 | } else if (!ret) |
| 294 | continue; |
| 295 | |
| 296 | if (pfd.revents & POLLIN) |
| 297 | break; |
| 298 | } while (!exit_backend); |
| 299 | |
| 300 | if (exit_backend) |
| 301 | goto out; |
| 302 | |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 303 | sk = accept(listen_sk, &addr, &len); |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 304 | if (sk < 0) { |
Jens Axboe | 690e09a | 2011-09-29 18:38:08 -0600 | [diff] [blame] | 305 | log_err("fio: accept: %s\n", strerror(errno)); |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 306 | return -1; |
| 307 | } |
| 308 | |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 309 | server_fd = sk; |
| 310 | |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 311 | exitval = handle_connection(sk); |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 312 | |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 313 | server_fd = -1; |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 314 | close(sk); |
Jens Axboe | 5c341e9 | 2011-09-29 18:00:35 -0600 | [diff] [blame] | 315 | |
Jens Axboe | 009b1be | 2011-09-29 18:27:02 -0600 | [diff] [blame] | 316 | if (!exit_backend) |
Jens Axboe | 5c341e9 | 2011-09-29 18:00:35 -0600 | [diff] [blame] | 317 | goto again; |
| 318 | |
Jens Axboe | 009b1be | 2011-09-29 18:27:02 -0600 | [diff] [blame] | 319 | out: |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 320 | return exitval; |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | int fio_server(void) |
| 324 | { |
| 325 | struct sockaddr_in saddr_in; |
| 326 | struct sockaddr addr; |
| 327 | unsigned int len; |
Jens Axboe | afcf775 | 2011-09-29 18:28:46 -0600 | [diff] [blame] | 328 | int sk, opt, ret; |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 329 | |
| 330 | sk = socket(AF_INET, SOCK_STREAM, 0); |
| 331 | if (sk < 0) { |
Jens Axboe | 690e09a | 2011-09-29 18:38:08 -0600 | [diff] [blame] | 332 | log_err("fio: socket: %s\n", strerror(errno)); |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 333 | return -1; |
| 334 | } |
| 335 | |
| 336 | opt = 1; |
| 337 | if (setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) { |
Jens Axboe | 690e09a | 2011-09-29 18:38:08 -0600 | [diff] [blame] | 338 | log_err("fio: setsockopt: %s\n", strerror(errno)); |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 339 | return -1; |
| 340 | } |
| 341 | #ifdef SO_REUSEPORT |
| 342 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) < 0) { |
Jens Axboe | 690e09a | 2011-09-29 18:38:08 -0600 | [diff] [blame] | 343 | log_err("fio: setsockopt: %s\n", strerror(errno)); |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 344 | return 1; |
| 345 | } |
| 346 | #endif |
| 347 | |
| 348 | saddr_in.sin_family = AF_INET; |
| 349 | saddr_in.sin_addr.s_addr = htonl(INADDR_ANY); |
Jens Axboe | 132159a | 2011-09-30 15:01:32 -0600 | [diff] [blame] | 350 | saddr_in.sin_port = htons(fio_net_port); |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 351 | |
| 352 | if (bind(sk, (struct sockaddr *) &saddr_in, sizeof(saddr_in)) < 0) { |
Jens Axboe | 690e09a | 2011-09-29 18:38:08 -0600 | [diff] [blame] | 353 | log_err("fio: bind: %s\n", strerror(errno)); |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 354 | return -1; |
| 355 | } |
| 356 | |
| 357 | if (listen(sk, 1) < 0) { |
Jens Axboe | 690e09a | 2011-09-29 18:38:08 -0600 | [diff] [blame] | 358 | log_err("fio: listen: %s\n", strerror(errno)); |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 359 | return -1; |
| 360 | } |
| 361 | |
| 362 | len = sizeof(addr); |
| 363 | if (getsockname(sk, &addr, &len) < 0) { |
Jens Axboe | 690e09a | 2011-09-29 18:38:08 -0600 | [diff] [blame] | 364 | log_err("fio: getsockname: %s\n", strerror(errno)); |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 365 | return -1; |
| 366 | } |
| 367 | |
Jens Axboe | afcf775 | 2011-09-29 18:28:46 -0600 | [diff] [blame] | 368 | ret = accept_loop(sk); |
| 369 | close(sk); |
| 370 | return ret; |
Jens Axboe | 50d1697 | 2011-09-29 17:45:28 -0600 | [diff] [blame] | 371 | } |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 372 | |
Jens Axboe | 142575e | 2011-09-30 17:35:45 -0600 | [diff] [blame] | 373 | int fio_server_text_output(const char *buf, unsigned int len) |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 374 | { |
| 375 | struct fio_net_cmd *cmd; |
Jens Axboe | 142575e | 2011-09-30 17:35:45 -0600 | [diff] [blame] | 376 | int size = sizeof(*cmd) + len; |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 377 | |
Jens Axboe | 142575e | 2011-09-30 17:35:45 -0600 | [diff] [blame] | 378 | cmd = malloc(size); |
Jens Axboe | 4d8f878 | 2011-09-30 22:24:17 -0600 | [diff] [blame] | 379 | fio_init_net_cmd(cmd, FIO_NET_CMD_TEXT, buf, len); |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 380 | fio_net_cmd_crc(cmd); |
| 381 | |
Jens Axboe | 142575e | 2011-09-30 17:35:45 -0600 | [diff] [blame] | 382 | fio_send_data(server_fd, cmd, size); |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 383 | free(cmd); |
Jens Axboe | 142575e | 2011-09-30 17:35:45 -0600 | [diff] [blame] | 384 | return size; |
| 385 | } |
| 386 | |
| 387 | int fio_server_log(const char *format, ...) |
| 388 | { |
| 389 | char buffer[1024]; |
| 390 | va_list args; |
Jens Axboe | 82fa6b2 | 2011-09-30 22:29:08 -0600 | [diff] [blame] | 391 | size_t len; |
Jens Axboe | 142575e | 2011-09-30 17:35:45 -0600 | [diff] [blame] | 392 | |
| 393 | va_start(args, format); |
Jens Axboe | 82fa6b2 | 2011-09-30 22:29:08 -0600 | [diff] [blame] | 394 | len = vsnprintf(buffer, sizeof(buffer), format, args); |
Jens Axboe | 142575e | 2011-09-30 17:35:45 -0600 | [diff] [blame] | 395 | va_end(args); |
| 396 | |
Jens Axboe | 82fa6b2 | 2011-09-30 22:29:08 -0600 | [diff] [blame] | 397 | return fio_server_text_output(buffer, len); |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 398 | } |