[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] libxl: Handle deprecation of QEMU's -usbdevice
-usbdevice is deprecated as of QEMU 2.10. This patch replace the few options documented in xl.cfg(5) by the recommanded syntax. And if the option isn't recognize, simply use -usbdevice with a warning, the options isn't entirely removed from QEMU upstream. Also, remove from the manual the sentence inviting to read QEMU's documentation. Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> --- docs/man/xl.cfg.pod.5.in | 3 -- tools/libxl/libxl_dm.c | 66 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in index 099a28dc7a..74375e0225 100644 --- a/docs/man/xl.cfg.pod.5.in +++ b/docs/man/xl.cfg.pod.5.in @@ -2468,9 +2468,6 @@ write "host:8.2". The form usbdevice=DEVICE is also accepted for backwards compatibility. -More valid options can be found in the "usbdevice" section of the QEMU -documentation. - =item B<vendor_device="VENDOR_DEVICE"> Selects which variant of the QEMU xen-pvdevice should be used for this diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index bd187463ec..36a778f200 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -910,6 +910,62 @@ static char *qemu_disk_ide_drive_string(libxl__gc *gc, const char *target_path, return drive; } +static int qemu_set_usbdevice_arg(libxl__gc *gc, int domid, + flexarray_t *dm_args, + char *usbdevice) +{ + /* + * -usbdevice is deprecated since QEMU 2.10, replace it by an equivalent if + * the option is recognized, otherwise use the deprecated -usbdevice and + * hope QEMU didn't remove it yet. + */ + + if (!strcmp(usbdevice, "tablet")) { + flexarray_append_pair(dm_args, "-device", "usb-tablet"); + return 0; + } else if (!strncmp(usbdevice, "host:", 5)) { + const char *params; + const char *p; + + params = strchr(usbdevice, ':'); + if (!params) + goto out; + + params++; + + flexarray_append(dm_args, "-device"); + + p = strchr(params, '.'); + if (p) { + uint32_t bus_num = strtoul(params, NULL, 0); + uint32_t addr = strtoul(p + 1, NULL, 0); + flexarray_append(dm_args, + GCSPRINTF("usb-host,hostbus=%d,hostaddr=%d", + bus_num, addr)); + return 0; + } else { + p = strchr(params, ':'); + if (p) { + uint32_t vendor_id = strtoul(params, NULL, 16); + uint32_t product_id = strtoul(p + 1, NULL, 16); + flexarray_append(dm_args, + GCSPRINTF("usb-host,vendorid=0x%x,productid=0x%x", + vendor_id, product_id)); + return 0; + } + } + } else { + /* fallback */ + LOGD(WARN, domid, "Attempt to use deprecated -usbdevice QEMU option"); + flexarray_append_pair(dm_args, "-usbdevice", usbdevice); + return 0; + } + +out: + LOGD(ERROR, domid, "Failed to parse usbdevice= option '%s'", usbdevice); + return ERROR_INVAL; +} + static int libxl__build_device_model_args_new(libxl__gc *gc, const char *dm, int guest_domid, const libxl_domain_config *guest_config, @@ -1171,16 +1227,16 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, } flexarray_append(dm_args, "-usb"); if (b_info->u.hvm.usbdevice) { - flexarray_vappend(dm_args, - "-usbdevice", b_info->u.hvm.usbdevice, NULL); + if (qemu_set_usbdevice_arg(gc, guest_domid, dm_args, + b_info->u.hvm.usbdevice)) + return ERROR_INVAL; } 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 (qemu_set_usbdevice_arg(gc, guest_domid, dm_args, *p)) + return ERROR_INVAL; } } } else if (b_info->u.hvm.usbversion) { -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |