Clean up the -usbdevice mess
PATCH 1/4 usb: remove support for -usbdevice parameters
In reply to Thomas HuthFrom: Paolo Bonzini <[email protected]>
No device needs them anymore and in fact they're undocumented. Remove the code. The only change in behavior is that "-usbdevice braille:hello" now reports an error, which is a bugfix.
--- hw/usb/bus.c | 32 +++++++------------------------- hw/usb/dev-serial.c | 2 +- include/hw/usb.h | 2 +- 3 files changed, 9 insertions(+), 27 deletions(-)
hw/usb/bus.c +7 -25
@@ -312,13 +312,13 @@ typedef struct LegacyUSBFactory {const char *name;const char *usbdevice_name; -USBDevice *(*usbdevice_init)(const char *params); + USBDevice *(*usbdevice_init)(void); } LegacyUSBFactory;static GSList *legacy_usb_factory;void usb_legacy_register (const char *typename,const char *usbdevice_name, -USBDevice *(*usbdevice_init)(const char *params)) +USBDevice *(*usbdevice_init)(void )) {if (usbdevice_name) {LegacyUSBFactory *f =g_malloc0 (sizeof (*f));
@@ -663,27 +663,17 @@ void hmp_info_usb(Monitor *mon, const QDict *qdict) }/* handle legacy -usbdevice cmd line option */ -USBDevice *usbdevice_create (const char *cmdline) +USBDevice *usbdevice_create (const char *driver) {USBBus *bus =usb_bus_find (-1 /* any */ );LegacyUSBFactory *f =NULL ;Error *err =NULL ;GSList *i; -char driver[32 ]; -const char *params; -int len;USBDevice *dev; - params =strchr (cmdline,':' ); -if (params) { - params++; - len = params - cmdline; -if (len >sizeof (driver)) - len =sizeof (driver); -pstrcpy (driver, len, cmdline); - }else { - params ="" ; -pstrcpy (driver,sizeof (driver), cmdline); +if (strchr (driver,':' )) { +error_report ("usbdevice parameters are not supported anymore" ); +return NULL ; }for (i = legacy_usb_factory; i; i = i->next) {
@@ -707,15 +697,7 @@ USBDevice *usbdevice_create(const char *cmdline)return NULL ; } -if (f->usbdevice_init) { - dev = f->usbdevice_init (params); - }else { -if (*params) { -error_report ("usbdevice %s accepts no params" , driver); -return NULL ; - } - dev =usb_new (f->name); - } + dev = f->usbdevice_init ? f->usbdevice_init () :usb_new (f->name);if (!dev) {error_report ("Failed to create USB device '%s'" , f->name);return NULL ;
hw/usb/dev-serial.c +1 -1
@@ -614,7 +614,7 @@ static void usb_serial_realize(USBDevice *dev, Error **errp) s->intr =usb_ep_get (dev,USB_TOKEN_IN ,1 ); } -static USBDevice *usb_braille_init (const char *unused) +static USBDevice *usb_braille_init (void ) {USBDevice *dev;Chardev *cdrv;
include/hw/usb.h +1 -1
@@ -500,7 +500,7 @@ void usb_bus_new(USBBus *bus, size_t bus_size,void usb_bus_release (USBBus *bus);USBBus *usb_bus_find (int busnr);void usb_legacy_register (const char *typename,const char *usbdevice_name, -USBDevice *(*usbdevice_init)(const char *params)); +USBDevice *(*usbdevice_init)(void ));USBDevice *usb_new (const char *name);bool usb_realize_and_unref (USBDevice *dev,USBBus *bus,Error **errp);USBDevice *usb_create_simple (USBBus *bus,const char *name);
Signature · 1 line
2.27.0
PATCH 3/4 usb: Un-deprecate -usbdevice (except for -usbdevice audio which gets removed)
In reply to Thomas HuthWhen trying to remove the -usbdevice option, there were complaints that "-usbdevice braille" is still a very useful shortcut for some people. Thus we never remove this option. Since it's not such a big burden to keep it around, and it's also convenient in the sense that you don't have to worry to enable a host controller explicitly with this option, we should remove it from he deprecation list again.
However, there is one exception: "-usbdevice audio" should go away, since audio devices without "audiodev=..." parameter are also on the deprecation list and you cannot use "-usbdevice audio" with "audiodev".
--- docs/system/deprecated.rst | 9 --------- docs/system/removed-features.rst | 8 ++++++++ hw/usb/dev-audio.c | 1 - softmmu/vl.c | 2 -- 4 files changed, 8 insertions(+), 12 deletions(-)
docs/system/deprecated.rst +0 -9
@@ -21,15 +21,6 @@ deprecated. System emulator command line arguments -------------------------------------- -``-usbdevice`` (since 2.10.0) -''''''''''''''''''''''''''''' - -The ``-usbdevice DEV`` argument is now a synonym for setting -the ``-device usb-DEV`` argument instead. The deprecated syntax -would automatically enable USB support on the machine type. -If using the new syntax, USB support must be explicitly -enabled via the ``-machine usb=on`` argument. - ``-drive file=json:{...{'driver':'file'}}`` (since 3.0) '''''''''''''''''''''''''''''''''''''''''''''''''''''''
docs/system/removed-features.rst +8 -0
@@ -38,6 +38,14 @@ or ``-display default,show-cursor=on`` instead. QEMU 5.0 introduced an alternative syntax to specify the size of the translation block cache, ``-accel tcg,tb-size=``. +``-usbdevice audio`` (removed in 6.0) +''''''''''''''''''''''''''''''''''''' + +This option lacked the possibility to specify an audio backend device. +Use ``-device usb-audio`` now instead (and specify a corresponding USB +host controller or ``-usb`` if necessary). + + QEMU Machine Protocol (QMP) commands ------------------------------------
hw/usb/dev-audio.c +0 -1
@@ -1024,7 +1024,6 @@ static const TypeInfo usb_audio_info = {static void usb_audio_register_types (void ) {type_register_static (&usb_audio_info); -usb_legacy_register (TYPE_USB_AUDIO ,"audio" ,NULL ); }type_init (usb_audio_register_types)
softmmu/vl.c +0 -2
@@ -3180,8 +3180,6 @@ void qemu_init(int argc, char **argv, char **envp)qemu_opts_parse_noisily (olist,"usb=on" , false);break ;case QEMU_OPTION_usbdevice: -error_report ("'-usbdevice' is deprecated, please use " -"'-device usb-...' instead" ); olist =qemu_find_opts ("machine" );qemu_opts_parse_noisily (olist,"usb=on" , false);add_device_config (DEV_USB , optarg);
Signature · 1 line
2.27.0
PATCH 2/4 usb: remove '-usbdevice u2f-key'
In reply to Thomas HuthFrom: Paolo Bonzini <[email protected]>
It never worked.
--- hw/usb/u2f.c | 1 - 1 file changed, 1 deletion(-)
hw/usb/u2f.c +0 -1
@@ -346,7 +346,6 @@ static const TypeInfo u2f_key_info = {static void u2f_key_register_types (void ) {type_register_static (&u2f_key_info); -usb_legacy_register (TYPE_U2F_KEY ,"u2f-key" ,NULL ); }type_init (u2f_key_register_types)
Signature · 1 line
2.27.0
PATCH 4/4 usb: Document the missing -usbdevice options
In reply to Thomas HuthThere are some more -usbdevice options that have never been mentioned in the documentation. Now that we removed -usbdevice from the list of deprecated features again, we should document them properly.
While we're at it, also sort them alphabetically.
--- qemu-options.hx | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
qemu-options.hx +29 -6
@@ -1705,7 +1705,7 @@ ERST DEFHEADING() -DEFHEADING(USB options:) +DEFHEADING(USB convenience options:) DEF("usb", 0, QEMU_OPTION_usb, "-usb enable on-board USB host controller (if not enabled by default)\n",
@@ -1723,9 +1723,31 @@ DEF("usbdevice", HAS_ARG, QEMU_OPTION_usbdevice, QEMU_ARCH_ALL) SRST ``-usbdevice devname`` - Add the USB device devname. Note that this option is deprecated, - please use ``-device usb-...`` instead. See the chapter about + Add the USB device devname, and enable an on-board USB controller + if possible and necessary (just like it can be done via + ``-machine usb=on``). Note that this option is mainly intended for + the user's convenience only. More fine-grained control can be + achieved by selecting a USB host controller (if necessary) and the + desired USB device via the ``-device`` option instead. For example, + instead of using ``-usbdevice mouse`` it is possible to use + ``-device qemu-xhci -device usb-mouse`` to connect the USB mouse + to a USB 3.0 controller instead (at least on machines that support + PCI and do not have an USB controller enabled by default yet). + For more details, see the chapter about :ref:`Connecting USB devices` in the System Emulation Users Guide. + Possible devices for devname are: + + ``braille`` + Braille device. This will use BrlAPI to display the braille + output on a real or fake device (i.e. it also creates a + corresponding ``braille`` chardev automatically beside the + ``usb-braille`` USB device). + + ``ccid`` + Smartcard reader device + + ``keyboard`` + Standard USB keyboard. Will override the PS/2 keyboard (if present). ``mouse`` Virtual Mouse. This will override the PS/2 mouse emulation when
@@ -1737,9 +1759,10 @@ SRST position without having to grab the mouse. Also overrides the PS/2 mouse emulation when activated. - ``braille`` - Braille device. This will use BrlAPI to display the braille - output on a real or fake device. + ``wacom-tablet`` + Wacom PenPartner USB tablet. + + ERST DEFHEADING()
Signature · 1 line
2.27.0
cover Clean up the -usbdevice mess
"-usbdevice" is still useful for some users. Thus let's clean up the unwanted parts and make sure that the rest is in a better shape again.
Paolo Bonzini (2):
usb: remove support for -usbdevice parameters
usb: remove '-usbdevice u2f-key'
Thomas Huth (2):
usb: Un-deprecate -usbdevice (except for -usbdevice audio which gets
removed)
usb: Document the missing -usbdevice options
docs/system/deprecated.rst | 9 -------- docs/system/removed-features.rst | 8 ++++++++ hw/usb/bus.c | 32 +++++++---------------------- hw/usb/dev-audio.c | 1 - hw/usb/dev-serial.c | 2 +- hw/usb/u2f.c | 1 - include/hw/usb.h | 2 +- qemu-options.hx | 35 ++++++++++++++++++++++++++------ softmmu/vl.c | 2 -- 9 files changed, 46 insertions(+), 46 deletions(-)
Signature · 1 line
2.27.0
Re: [PATCH 1/4] usb: remove support for -usbdevice parameters
In reply to Thomas HuthQuoted 16 lines · Thomas Huth
From: Paolo Bonzini <[email protected]>
No device needs them anymore and in fact they're undocumented. Remove the code. The only change in behavior is that "-usbdevice braille:hello" now reports an error, which is a bugfix.
Signed-off-by Paolo Bonzini <[email protected]>Cc Gerd Hoffmann <[email protected]>Signed-off-by Thomas Huth <[email protected]>--- hw/usb/bus.c | 32 +++++++------------------------- hw/usb/dev-serial.c | 2 +- include/hw/usb.h | 2 +- 3 files changed, 9 insertions(+), 27 deletions(-)
hw/usb/bus.c void hmp_info_usb(Monitor *mon, const QDict *qdict) · line 675
Quoted 2 lines
hw/usb/bus.c +2
-0+if (strchr (driver,':' )) { +error_report ("usbdevice parameters are not supported anymore" );
Although wiktionary says it is a valid word in the US, 'anymore' feels colloquial compared to 'any more'.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH 3/4] usb: Un-deprecate -usbdevice (except for -usbdevice audio which gets removed)
In reply to Thomas HuthQuoted 7 lines · Thomas Huth
When trying to remove the -usbdevice option, there were complaints that "-usbdevice braille" is still a very useful shortcut for some people. Thus we never remove this option. Since it's not such a big burden to keep it around, and it's also convenient in the sense that you don't have to worry to enable a host controller explicitly with this option, we should remove it from he deprecation list again.
Quoted 5 lines
However, there is one exception: "-usbdevice audio" should go away, since audio devices without "audiodev=..." parameter are also on the deprecation list and you cannot use "-usbdevice audio" with "audiodev".
Signed-off-by Thomas Huth <[email protected]>
I accept the complaint that the replacement of "-usbdevice braille" is less convenient. This is not the case for the -usbdevice tablet, mouse, keyboard, ccid, and wacom-tablet. It is arguably the case for disk, serial, net, and host, yet we removed those anyway, to make the regular and more expressive interface the only one.
Perhaps braille is special enough to justify sugar. Paolo wrote:
Braille is worth a special case because a subset of our user base (blind people) will use it 100% of the time, plus it is not supported by libvirt and hence virt-manager
I'm not against extending the grace period to give libvirt (and hence virt-manager) more time to transition to the regular interface. For libvirt, the regular (and often more expressive) interface is almost always preferable to sugared interfaces.
I'm not even against braille sugar if our human users of braille truly need it, as long as it's reasonably unobtrusive. Straightforward macro expansion is.
However, "braille is special" is only an argument for *braille* sugar. It doesn't extend to -usbdevice tablet, mouse etc. I am against undeprecating these.
If we decide we want braille sugar, we then need to decide whether it should be -usbdevice braille or something else, like -braille.
If we decide we want something else, keep -usbdevice braille deprecated until something else is ready, then keep it deprecated for a sensible grace period, then remove it. Flip-flopping deprecation in between is not helpful.
If we can't make up our minds, keep it deprecated until we do.
Only if we decide the sugar should remain -usbdevice braille, we should undeprecate it now.
The road to the CLI hell we're in is paved with "convenience".
Quoted 11 lines · Thomas Huth
"-usbdevice" is still useful for some users. Thus let's clean up the unwanted parts and make sure that the rest is in a better shape again.
Paolo Bonzini (2):
usb: remove support for -usbdevice parameters
usb: remove '-usbdevice u2f-key'Thomas Huth (2):
usb: Un-deprecate -usbdevice (except for -usbdevice audio which gets
removed)
usb: Document the missing -usbdevice options
Added to usb queue (and unqueued the obsoleted patch of course).
thanks,
Gerd
Re: [PATCH 3/4] usb: Un-deprecate -usbdevice (except for -usbdevice audio which gets removed)
In reply to Markus ArmbrusterQuoted 13 lines · Markus Armbruster
Quoted 11 lines · Thomas Huth
When trying to remove the -usbdevice option, there were complaints that "-usbdevice braille" is still a very useful shortcut for some people. Thus we never remove this option. Since it's not such a big burden to keep it around, and it's also convenient in the sense that you don't have to worry to enable a host controller explicitly with this option, we should remove it from he deprecation list again.
However, there is one exception: "-usbdevice audio" should go away, since audio devices without "audiodev=..." parameter are also on the deprecation list and you cannot use "-usbdevice audio" with "audiodev".
Quoted 5 lines
Quoted 1 line
Signed-off-by Thomas Huth <[email protected]>I accept the complaint that the replacement of "-usbdevice braille" is less convenient. This is not the case for the -usbdevice tablet, mouse, keyboard, ccid, and wacom-tablet.
Well, if we keep "-usbdevice braille" (which we should unless somebody comes up with another easy to use replacement for blind people), then it also does not hurt too much to keep tablet, mouse, keyboard and wacom-tablet, since the code for these is rather simple and thus not a great burden to maintain. And these are mentioned in a lot of documents, scripts and howtos out there, so users are used to them.
However, searching for "-usbdevice ccid", I hardly get any results, so I guess we could also simply remove that one.
Quoted 3 lines
It is arguably the case for disk,
serial, net, and host, yet we removed those anyway, to make the regular and more expressive interface the only one.
The problem with those devices was that they used their own parameter parsing code, including bugs we had to take care about, so there was a higher level of maintenance involved there. I think that alone justified their removal.
Quoted 6 lines
However, "braille is special" is only an argument for *braille* sugar. It doesn't extend to -usbdevice tablet, mouse etc. I am against undeprecating these.
If we decide we want braille sugar, we then need to decide whether it should be -usbdevice braille or something else, like -braille.
I've raised that question three years ago already. Nobody stepped forward to implement -braille, so I think we should keep -usbdevice braille for now.
Quoted 1 line
If we can't make up our minds, keep it deprecated until we do.
We didn't make up our minds for three years now. In my eyes that's a decision for keeping -usbdevice braille around.
Thomas
[PATCH 5/4] usb: Remove "-usbdevice ccid"
In reply to Thomas Huth"-usbdevice ccid" was not documented and -usbdevice itself was marked as deprecated before QEMU v6.0. And searching for "-usbdevice ccid" in the internet does not show any useful results, so likely nobody was using the ccid device via the -usbdevice option. Remove it now.
--- docs/system/removed-features.rst | 6 ++++++ hw/usb/dev-smartcard-reader.c | 1 - qemu-options.hx | 3 --- 3 files changed, 6 insertions(+), 4 deletions(-)
docs/system/removed-features.rst +6 -0
@@ -45,6 +45,12 @@ This option lacked the possibility to specify an audio backend device. Use ``-device usb-audio`` now instead (and specify a corresponding USB host controller or ``-usb`` if necessary). +``-usbdevice ccid`` (removed in 6.0) +''''''''''''''''''''''''''''''''''''' + +This option was undocumented and not used in the field. +Use `-device usb-ccid`` instead. + QEMU Machine Protocol (QMP) commands ------------------------------------
hw/usb/dev-smartcard-reader.c +0 -1
@@ -1492,7 +1492,6 @@ static void ccid_register_types(void)type_register_static (&ccid_bus_info);type_register_static (&ccid_card_type_info);type_register_static (&ccid_info); -usb_legacy_register (TYPE_USB_CCID_DEV ,"ccid" ,NULL ); }type_init (ccid_register_types)
qemu-options.hx +0 -3
@@ -1743,9 +1743,6 @@ SRST corresponding ``braille`` chardev automatically beside the ``usb-braille`` USB device). - ``ccid`` - Smartcard reader device - ``keyboard`` Standard USB keyboard. Will override the PS/2 keyboard (if present).
Signature · 1 line
2.27.0
Re: [PATCH 3/4] usb: Un-deprecate -usbdevice (except for -usbdevice audio which gets removed)
In reply to Markus ArmbrusterQuoted 6 lines · Markus Armbruster
If we decide we want something else, keep -usbdevice braille deprecated until something else is ready, then keep it deprecated for a sensible grace period, then remove it. Flip-flopping deprecation in between is not helpful.
Quoted 6 lines
If we can't make up our minds, keep it deprecated until we do.
Only if we decide the sugar should remain -usbdevice braille, we should undeprecate it now.
The road to the CLI hell we're in is paved with "convenience".
A lot of the work I did in 6.0 on vl.c and friends was exactly to figure out:
- which of our CLI interfaces are a maintainability issue and really need deprecation
- which of our CLI interfaces can be modified to improve maintainability and simplify the addition of new interfaces
- how machine creation *really* works, so that it's easy to add things at the right spot.
Of course _everything_ is a maintenance cost, but you can at least make sure that the cost is not visible to most developers. This series, as well as the previous removal of parameterized -usbdevice is just doing that: keep the decent parts that do not hamper maintainability, deprecate/remove the rest.
Paolo
Re: [PATCH 3/4] usb: Un-deprecate -usbdevice (except for -usbdevice audio which gets removed)
In reply to Thomas HuthHi,
Quoted 6 lines
Quoted 3 lines
It is arguably the case for disk,
serial, net, and host, yet we removed those anyway, to make the regular and more expressive interface the only one.The problem with those devices was that they used their own parameter parsing code,
Yes, that was IMHO the most important issue. Two ways to configure devices, the usual properties and the hand-crafted and often buggy device-specific parsers.
Now we are down to simple aliasing without parameter support, except for braille which has the special chardev handling. Given we keep braille support anyway there is little reason to drop the aliasing support for the other devices which don't require parameters. It's literally a single line of code per device, hardly a big maintainance burden. The benefit is we don't invalidate tons of webpages which document "-usbdevice tablet" and the like.
Quoted 2 lines
We didn't make up our minds for three years now. In my eyes that's a decision for keeping -usbdevice braille around.
Another option could be to integrate the braille bits into the usb-braille device, then kill the separate chardev. Which would also drop support for serial braille devices. Not sure how much of a problem that would be these days. But that likewise needs someone to step up doing the work ...
take care,
Gerd
Re: [PATCH 3/4] usb: Un-deprecate -usbdevice (except for -usbdevice audio which gets removed)
Gerd Hoffmann, le jeu. 11 mars 2021 12:37:38 +0100, a ecrit:
Quoted 2 lines
Which would also drop support for serial braille devices. Not sure how much of a problem that would be these days.
It is an important concern: we also need to be able to test braille devices connected through serial.
Samuel
Re: [PATCH 5/4] usb: Remove "-usbdevice ccid"
In reply to Thomas HuthQuoted 4 lines · Thomas Huth
"-usbdevice ccid" was not documented and -usbdevice itself was marked as deprecated before QEMU v6.0. And searching for "-usbdevice ccid" in the internet does not show any useful results, so likely nobody was using the ccid device via the -usbdevice option. Remove it now.
Any comments on this one? Shall we keep it? Or shall we remove it?
Thomas
Quoted 51 lines
Signed-off-by Thomas Huth <[email protected]>--- docs/system/removed-features.rst | 6 ++++++ hw/usb/dev-smartcard-reader.c | 1 - qemu-options.hx | 3 --- 3 files changed, 6 insertions(+), 4 deletions(-)docs/system/removed-features.rst +6
-0@@ -45,6 +45,12 @@ This option lacked the possibility to specify an audio backend device. Use ``-device usb-audio`` now instead (and specify a corresponding USB host controller or ``-usb`` if necessary). +``-usbdevice ccid`` (removed in 6.0) +''''''''''''''''''''''''''''''''''''' + +This option was undocumented and not used in the field. +Use `-device usb-ccid`` instead. + QEMU Machine Protocol (QMP) commands ------------------------------------hw/usb/dev-smartcard-reader.c +0
-1@@ -1492,7 +1492,6 @@ static void ccid_register_types(void)type_register_static (&ccid_bus_info);type_register_static (&ccid_card_type_info);type_register_static (&ccid_info); -usb_legacy_register (TYPE_USB_CCID_DEV ,"ccid" ,NULL ); }type_init (ccid_register_types)qemu-options.hx +0
-3@@ -1743,9 +1743,6 @@ SRST corresponding ``braille`` chardev automatically beside the ``usb-braille`` USB device). - ``ccid`` - Smartcard reader device - ``keyboard`` Standard USB keyboard. Will override the PS/2 keyboard (if present).
Re: [PATCH 5/4] usb: Remove "-usbdevice ccid"
Quoted 7 lines · Thomas Huth
Quoted 4 lines · Thomas Huth
"-usbdevice ccid" was not documented and -usbdevice itself was marked as deprecated before QEMU v6.0. And searching for "-usbdevice ccid" in the internet does not show any useful results, so likely nobody was using the ccid device via the -usbdevice option. Remove it now.
Any comments on this one? Shall we keep it? Or shall we remove it?
Queued. ccid is not useful standalone[1], you need hook up something to the ccid bus it provides, which is probably the reason why -usbdevice ccid is not used in the wild.
take care,
Gerd
[1] Well, it'll work fine, but the guest will only see a smartcard reader device without smardcard plugged in ...