diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libxl/libxl.h | 16 | ||||
-rw-r--r-- | tools/libxl/libxl_dm.c | 38 | ||||
-rw-r--r-- | tools/libxl/libxl_types.idl | 1 |
3 files changed, 53 insertions, 2 deletions
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 030aa86d52..d18d22c0c1 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -273,6 +273,22 @@ #endif #endif +/* + * LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST + * + * If this is defined, then the libxl_domain_build_info structure will + * contain hvm.usbdevice_list, a libxl_string_list type that contains + * a list of USB devices to specify on the qemu command-line. + * + * If it is set, callers may use either hvm.usbdevice or + * hvm.usbdevice_list, but not both; if both are set, libxl will + * throw an error. + * + * If this is not defined, callers can only use hvm.usbdevice. Note + * that this means only one device can be added at domain build time. + */ +#define LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST 1 + /* Functions annotated with LIBXL_EXTERNAL_CALLERS_ONLY may not be * called from within libxl itself. Callers outside libxl, who * do not #include libxl_internal.h, are fine. */ diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 82e30df6be..d10a58fc02 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -198,11 +198,28 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc, if (b_info->u.hvm.boot) { flexarray_vappend(dm_args, "-boot", b_info->u.hvm.boot, NULL); } - if (libxl_defbool_val(b_info->u.hvm.usb) || b_info->u.hvm.usbdevice) { + if (libxl_defbool_val(b_info->u.hvm.usb) + || b_info->u.hvm.usbdevice + || b_info->u.hvm.usbdevice_list) { + if ( b_info->u.hvm.usbdevice && b_info->u.hvm.usbdevice_list ) + { + LOG(ERROR, "%s: Both usbdevice and usbdevice_list set", + __func__); + return NULL; + } flexarray_append(dm_args, "-usb"); if (b_info->u.hvm.usbdevice) { flexarray_vappend(dm_args, "-usbdevice", b_info->u.hvm.usbdevice, NULL); + } else if (b_info->u.hvm.usbdevice_list) { + char **p; + for (p = b_info->u.hvm.usbdevice_list; + *p; + p++) { + flexarray_vappend(dm_args, + "-usbdevice", + *p, NULL); + } } } if (b_info->u.hvm.soundhw) { @@ -479,11 +496,28 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc, flexarray_vappend(dm_args, "-boot", libxl__sprintf(gc, "order=%s", b_info->u.hvm.boot), NULL); } - if (libxl_defbool_val(b_info->u.hvm.usb) || b_info->u.hvm.usbdevice) { + if (libxl_defbool_val(b_info->u.hvm.usb) + || b_info->u.hvm.usbdevice + || b_info->u.hvm.usbdevice_list) { + if ( b_info->u.hvm.usbdevice && b_info->u.hvm.usbdevice_list ) + { + LOG(ERROR, "%s: Both usbdevice and usbdevice_list set", + __func__); + return NULL; + } flexarray_append(dm_args, "-usb"); if (b_info->u.hvm.usbdevice) { flexarray_vappend(dm_args, "-usbdevice", b_info->u.hvm.usbdevice, NULL); + } else if (b_info->u.hvm.usbdevice_list) { + char **p; + for (p = b_info->u.hvm.usbdevice_list; + *p; + p++) { + flexarray_vappend(dm_args, + "-usbdevice", + *p, NULL); + } } } if (b_info->u.hvm.soundhw) { diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index f3c212bc8c..6cb6de613c 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -330,6 +330,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("usbdevice", string), ("soundhw", string), ("xen_platform_pci", libxl_defbool), + ("usbdevice_list", libxl_string_list), ])), ("pv", Struct(None, [("kernel", string), ("slack_memkb", MemKB), |