* [PATCH] libxl: Handle deprecation of QEMU's -usbdevice
@ 2018-07-19 17:29 Anthony PERARD
2018-07-25 8:38 ` Wei Liu
0 siblings, 1 reply; 5+ messages in thread
From: Anthony PERARD @ 2018-07-19 17:29 UTC (permalink / raw)
To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Ian Jackson
-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@citrix.com>
---
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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] libxl: Handle deprecation of QEMU's -usbdevice
2018-07-19 17:29 [PATCH] libxl: Handle deprecation of QEMU's -usbdevice Anthony PERARD
@ 2018-07-25 8:38 ` Wei Liu
2018-07-25 10:43 ` Anthony PERARD
0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2018-07-25 8:38 UTC (permalink / raw)
To: Anthony PERARD; +Cc: xen-devel, Ian Jackson, Wei Liu
On Thu, Jul 19, 2018 at 06:29:29PM +0100, Anthony PERARD wrote:
> -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@citrix.com>
> ---
> 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.
> -
Does this mean we intend to only support the options listed in
xl.cfg(5)?
If so, I think we should make clear here -- this is a regression. And
tell users if they have appended their own options they should take
actions, like using device_model_extra_args or something else (?).
How does libvirt handle QEMU option deprecation?
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libxl: Handle deprecation of QEMU's -usbdevice
2018-07-25 8:38 ` Wei Liu
@ 2018-07-25 10:43 ` Anthony PERARD
2018-08-20 14:32 ` Wei Liu
0 siblings, 1 reply; 5+ messages in thread
From: Anthony PERARD @ 2018-07-25 10:43 UTC (permalink / raw)
To: Wei Liu; +Cc: xen-devel, Ian Jackson
On Wed, Jul 25, 2018 at 09:38:20AM +0100, Wei Liu wrote:
> On Thu, Jul 19, 2018 at 06:29:29PM +0100, Anthony PERARD wrote:
> > -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@citrix.com>
> > ---
> > 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.
> > -
>
> Does this mean we intend to only support the options listed in
> xl.cfg(5)?
I have no idea which options are supported. I can leave that extra
sentence in the manual, as the meaning change over time, outside of our
control. Right know, on my machine, in `man qemu`, it means
mouse/tablet/braille + it is deprecated.
Having a look into SUPPORT.md, I should also parse "mouse", as both
usbmouse and usbtablet are supported. There is also "Host USB
passthrough" for which support as been removed upstream. That's it,
nothing else is supported according to the document.
> If so, I think we should make clear here -- this is a regression. And
> tell users if they have appended their own options they should take
> actions, like using device_model_extra_args or something else (?).
"something else" could be send a msg to xen-devel, so that we can add
support for it, extra_args is a nice work around, at least, user should
know that the options might break if qemu change.
Also, you said we could parse few know options and reject the rest:
https://lists.xenproject.org/archives/html/xen-devel/2018-03/msg02770.html
As for what to do to tell the users to use the kitchen sink, I have no
idea.
> How does libvirt handle QEMU option deprecation?
I don't think they handle it very well. I think it's basicaly when the
deprecated option is removed from QEMU that they notice libvirt need to
be fixed (That's what I got from reading a thread on qemu-devel).
Thanks,
--
Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libxl: Handle deprecation of QEMU's -usbdevice
2018-07-25 10:43 ` Anthony PERARD
@ 2018-08-20 14:32 ` Wei Liu
2018-08-20 14:58 ` Anthony PERARD
0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2018-08-20 14:32 UTC (permalink / raw)
To: Anthony PERARD; +Cc: xen-devel, Wei Liu, Ian Jackson
On Wed, Jul 25, 2018 at 11:43:29AM +0100, Anthony PERARD wrote:
> On Wed, Jul 25, 2018 at 09:38:20AM +0100, Wei Liu wrote:
> > On Thu, Jul 19, 2018 at 06:29:29PM +0100, Anthony PERARD wrote:
> > > -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@citrix.com>
> > > ---
> > > 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.
> > > -
> >
> > Does this mean we intend to only support the options listed in
> > xl.cfg(5)?
>
> I have no idea which options are supported. I can leave that extra
> sentence in the manual, as the meaning change over time, outside of our
> control. Right know, on my machine, in `man qemu`, it means
> mouse/tablet/braille + it is deprecated.
>
> Having a look into SUPPORT.md, I should also parse "mouse", as both
> usbmouse and usbtablet are supported. There is also "Host USB
> passthrough" for which support as been removed upstream. That's it,
> nothing else is supported according to the document.
>
> > If so, I think we should make clear here -- this is a regression. And
> > tell users if they have appended their own options they should take
> > actions, like using device_model_extra_args or something else (?).
>
> "something else" could be send a msg to xen-devel, so that we can add
> support for it, extra_args is a nice work around, at least, user should
> know that the options might break if qemu change.
>
This is fair enough.
> Also, you said we could parse few know options and reject the rest:
> https://lists.xenproject.org/archives/html/xen-devel/2018-03/msg02770.html
>
I think this is the mostly sustainable way going forward.
> As for what to do to tell the users to use the kitchen sink, I have no
> idea.
>
> > How does libvirt handle QEMU option deprecation?
>
> I don't think they handle it very well. I think it's basicaly when the
> deprecated option is removed from QEMU that they notice libvirt need to
> be fixed (That's what I got from reading a thread on qemu-devel).
How do they fix this sort of things? Do they reject removed options or
try (as best effort) to translate?
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libxl: Handle deprecation of QEMU's -usbdevice
2018-08-20 14:32 ` Wei Liu
@ 2018-08-20 14:58 ` Anthony PERARD
0 siblings, 0 replies; 5+ messages in thread
From: Anthony PERARD @ 2018-08-20 14:58 UTC (permalink / raw)
To: Wei Liu; +Cc: xen-devel, Ian Jackson
On Mon, Aug 20, 2018 at 03:32:58PM +0100, Wei Liu wrote:
> On Wed, Jul 25, 2018 at 11:43:29AM +0100, Anthony PERARD wrote:
> > On Wed, Jul 25, 2018 at 09:38:20AM +0100, Wei Liu wrote:
> > > How does libvirt handle QEMU option deprecation?
> >
> > I don't think they handle it very well. I think it's basicaly when the
> > deprecated option is removed from QEMU that they notice libvirt need to
> > be fixed (That's what I got from reading a thread on qemu-devel).
>
> How do they fix this sort of things? Do they reject removed options or
> try (as best effort) to translate?
I don't think those questions make senses. What "sort of things" ? Which
"options", qemu command line/qmp options or user facing options?
In anycase, I don't think I know enough about libvirt (even as a user)
to be able to respond to those questions, but they would probably not
have exposed -usbdevice to users, like we do.
--
Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-08-20 14:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-19 17:29 [PATCH] libxl: Handle deprecation of QEMU's -usbdevice Anthony PERARD
2018-07-25 8:38 ` Wei Liu
2018-07-25 10:43 ` Anthony PERARD
2018-08-20 14:32 ` Wei Liu
2018-08-20 14:58 ` Anthony PERARD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).