| 53 | } |
| 54 | |
| 55 | static int |
| 56 | parse_args(int argc, char **argv) |
| 57 | { |
| 58 | static const char *short_option = "i"; |
| 59 | static struct option long_option[] = { |
| 60 | {"iface", required_argument, NULL, 0}, |
| 61 | {"interactive", no_argument, &interactive, 1}, |
| 62 | {"client", no_argument, &client_mode, 1}, |
| 63 | {NULL, 0, 0, 0}, |
| 64 | }; |
| 65 | int opt, idx; |
| 66 | char *prgname = argv[0]; |
| 67 | |
| 68 | while ((opt = getopt_long(argc, argv, short_option, long_option, &idx)) |
| 69 | != EOF) { |
| 70 | switch (opt) { |
| 71 | case 'i': |
| 72 | printf("Interactive-mode selected\n"); |
| 73 | interactive = 1; |
| 74 | break; |
| 75 | /* long options */ |
| 76 | case 0: |
| 77 | if (strncmp(long_option[idx].name, "iface", |
| 78 | MAX_PATH_LEN) == 0) { |
| 79 | rte_strscpy(iface, optarg, MAX_PATH_LEN); |
| 80 | printf("iface %s\n", iface); |
| 81 | } |
| 82 | if (!strcmp(long_option[idx].name, "interactive")) { |
| 83 | printf("Interactive-mode selected\n"); |
| 84 | interactive = 1; |
| 85 | } |
| 86 | break; |
| 87 | |
| 88 | default: |
| 89 | vdpa_usage(prgname); |
| 90 | return -1; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | if (iface[0] == '\0' && interactive == 0) { |
| 95 | vdpa_usage(prgname); |
| 96 | return -1; |
| 97 | } |
| 98 | |
| 99 | return 0; |
| 100 | } |
| 101 | |
| 102 | static int |
| 103 | new_device(int vid) |
no test coverage detected