aboutsummaryrefslogtreecommitdiff
path: root/src/userspace_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/userspace_io.c')
-rw-r--r--src/userspace_io.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/userspace_io.c b/src/userspace_io.c
index 4c34708..ef3bdc6 100644
--- a/src/userspace_io.c
+++ b/src/userspace_io.c
@@ -19,14 +19,21 @@
#include <drivers/driver_ops.h>
#include <vfio_api.h>
#include <mm_api.h>
+#include <common.h>
#include <drivers/r8169.h>
/* FIXME modularize driver load */
extern const struct driver_ops r8169_ops;
+static char help_msg[] = {
+ "\n"
+ " -d: device uuid\n"
+ " -i: device id in /dev/vfio\n"
+};
+
static void usage(char *name)
{
- printf("usage: %s <group id>\n", name);
+ printf("usage: %s [OPTIONS] \n%s\n", name, help_msg);
}
int main(int argc, char *argv[])
@@ -46,19 +53,22 @@ int main(int argc, char *argv[])
int ret, c;
struct driver_ops exec_ops = r8169_ops;
char *rx_buff[256];
+ uint32_t opts = 0;
- while ((c = getopt(argc, argv, "d:i:f:")) != -1) {
+ while ((c = getopt(argc, argv, "d:i:")) != -1) {
switch (c) {
case 'd':
+ strncpy(group_uuid, optarg, sizeof(group_uuid));
+ opts |= OPT_UUID;
break;
case 'i':
- break;
- case 'f':
+ group_id = atoi(optarg);
+ opts |= OPT_DEV;
break;
}
}
- if (argc != 3) {
+ if ((opts & (OPT_UUID | OPT_DEV)) != (OPT_UUID | OPT_DEV)) {
usage(argv[0]);
return -1;
}
@@ -73,12 +83,10 @@ int main(int argc, char *argv[])
if (container < 0)
goto out;
- group_id = atoi(argv[1]);
group = get_group(group_id);
if (group < 0)
goto out;
- strncpy(group_uuid, argv[2], sizeof(group_uuid));
device = vfio_init_dev(group, container, &group_status, &iommu_info,
&device_info, &region_info, group_uuid);