usb: Remove legacy -usbdevice option
PATCH 1/1 usb: Remove legacy -usbdevice option
The option has been marked as deprecated since QEMU 2.10, and so far nobody complained that it is urgently required anymore. So let's now get rid of this legacy pile, to simplify the usb code quite a bit.
--- hw/usb/Makefile.objs | 2 +- hw/usb/bus.c | 98 ---------------------------- hw/usb/dev-audio.c | 1 - hw/usb/dev-bluetooth.c | 22 ------- hw/usb/dev-hid.c | 3 - hw/usb/dev-network.c | 26 -------- hw/usb/dev-serial.c | 45 ------------- hw/usb/dev-smartcard-reader.c | 1 - hw/usb/dev-storage.c | 58 ----------------- hw/usb/dev-wacom.c | 1 - hw/usb/host-legacy.c | 144 ------------------------------------------ include/hw/usb.h | 5 -- qemu-doc.texi | 8 --- qemu-options.hx | 46 -------------- vl.c | 57 ----------------- 15 files changed, 1 insertion(+), 516 deletions(-) delete mode 100644 hw/usb/host-legacy.c
hw/usb/Makefile.objs +1 -1
@@ -43,7 +43,7 @@ redirect.o-libs = $(USB_REDIR_LIBS) # usb pass-through ifeq ($(CONFIG_USB_LIBUSB)$(CONFIG_USB),yy) -common-obj-y += host-libusb.o host-legacy.o +common-obj-y += host-libusb.o else common-obj-y += host-stub.o endif
hw/usb/bus.c +0 -98
110 lines not on this page · raw message
hw/usb/dev-audio.c +0 -1
@@ -697,7 +697,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)
hw/usb/dev-bluetooth.c +0 -22
@@ -522,27 +522,6 @@ static void usb_bt_realize(USBDevice *dev, Error **errp) s->intr =usb_ep_get (dev,USB_TOKEN_IN ,USB_EVT_EP ); } -static USBDevice *usb_bt_init (USBBus *bus,const char *cmdline) -{ -USBDevice *dev; -struct USBBtState *s; -HCIInfo *hci; -const char *name =TYPE_USB_BT ; - -if (*cmdline) { - hci =hci_init (cmdline); - }else { - hci =bt_new_hci (qemu_find_bt_vlan (0 )); - } -if (!hci) -return NULL ; - - dev =usb_create (bus, name); - s =USB_BT (dev); - s->hci = hci; -return dev; -} -static const VMStateDescription vmstate_usb_bt = { .name ="usb-bt" , .unmigratable =1 ,
@@ -574,7 +553,6 @@ static const TypeInfo bt_info = {static void usb_bt_register_types (void ) {type_register_static (&bt_info); -usb_legacy_register (TYPE_USB_BT ,"bt" , usb_bt_init); }type_init (usb_bt_register_types)
hw/usb/dev-hid.c +0 -3
@@ -873,11 +873,8 @@ static void usb_hid_register_types(void) {type_register_static (&usb_hid_type_info);type_register_static (&usb_tablet_info); -usb_legacy_register ("usb-tablet" ,"tablet" ,NULL );type_register_static (&usb_mouse_info); -usb_legacy_register ("usb-mouse" ,"mouse" ,NULL );type_register_static (&usb_keyboard_info); -usb_legacy_register ("usb-kbd" ,"keyboard" ,NULL ); }type_init (usb_hid_register_types)
hw/usb/dev-network.c +0 -26
@@ -1382,31 +1382,6 @@ static void usb_net_instance_init(Object *obj) &dev->qdev, NULL); } -static USBDevice *usb_net_init (USBBus *bus,const char *cmdline) -{ -Error *local_err =NULL ; -USBDevice *dev; -QemuOpts *opts; -int idx; - - opts =qemu_opts_parse_noisily (qemu_find_opts ("net" ), cmdline, false); -if (!opts) { -return NULL ; - } -qemu_opt_set (opts,"type" ,"nic" , &error_abort); -qemu_opt_set (opts,"model" ,"usb" , &error_abort); - - idx =net_client_init (opts, false, &local_err); -if (local_err) { -error_report_err (local_err); -return NULL ; - } - - dev =usb_create (bus,"usb-net" ); -qdev_set_nic_properties (&dev->qdev, &nd_table[idx]); -return dev; -} -static const VMStateDescription vmstate_usb_net = { .name ="usb-net" , .unmigratable =1 ,
@@ -1446,7 +1421,6 @@ static const TypeInfo net_info = {static void usb_net_register_types (void ) {type_register_static (&net_info); -usb_legacy_register (TYPE_USB_NET ,"net" , usb_net_init); }type_init (usb_net_register_types)
hw/usb/dev-serial.c +0 -45
58 lines not on this page · raw message
hw/usb/dev-smartcard-reader.c +0 -1
@@ -1496,7 +1496,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 (CCID_DEV_NAME ,"ccid" ,NULL ); }type_init (ccid_register_types)
hw/usb/dev-storage.c +0 -58
70 lines not on this page · raw message
hw/usb/dev-wacom.c +0 -1
@@ -380,7 +380,6 @@ static const TypeInfo wacom_info = {static void usb_wacom_register_types (void ) {type_register_static (&wacom_info); -usb_legacy_register (TYPE_USB_WACOM ,"wacom-tablet" ,NULL ); }type_init (usb_wacom_register_types)
hw/usb/host-legacy.c deleted +0 -144
144 lines not on this page · raw message
include/hw/usb.h +0 -5
@@ -531,12 +531,7 @@ void usb_bus_new(USBBus *bus, size_t bus_size, USBBusOps *ops, DeviceState *host);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)(USBBus *bus, -const char *params)); -USBDevice *usb_create (USBBus *bus,const char *name);USBDevice *usb_create_simple (USBBus *bus,const char *name); -USBDevice *usbdevice_create (const char *cmdline);void usb_register_port (USBBus *bus,USBPort *port,void *opaque,int index,USBPortOps *ops,int speedmask); void usb_register_companion(const char *masterbus, USBPort *ports[],
qemu-doc.texi +0 -8
@@ -2700,14 +2700,6 @@ on the ``ide-hd'' device using the ``-device'' argument. The new syntax allows different settings to be provided per disk. -@subsection -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. - @subsection -nodefconfig (since 2.11.0) The ``-nodefconfig`` argument is a synonym for ``-no-user-config``.
qemu-options.hx +0 -46
52 lines not on this page · raw message
vl.c +0 -57
81 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 5 lines · Thomas Huth
The option has been marked as deprecated since QEMU 2.10, and so far nobody complained that it is urgently required anymore. So let's now get rid of this legacy pile, to simplify the usb code quite a bit.
Signed-off-by Thomas Huth <[email protected]>
The diffstat is nice, but can we retain the "please use $NEWOPTION instead of $OLDOPTION" message for a bit? I'm pretty sure there will be users out there who've been happily ignoring deprecation notices, and I think we'll reduce the amount of support traffic if they get a new QEMU with a specific error message telling them what they need to fix, rather than one which just prints a generic "unknown option" message.
thanks
-- PMM
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Thomas Huth
The option has been marked as deprecated since QEMU 2.10, and so far nobody complained that it is urgently required anymore. So let's now get rid of this legacy pile, to simplify the usb code quite a bit.
Signed-off-by Thomas Huth <[email protected]>
Quoted 8 lines
The diffstat is nice, but can we retain the "please use $NEWOPTION instead of $OLDOPTION" message for a bit? I'm pretty sure there will be users out there who've been happily ignoring deprecation notices, and I think we'll reduce the amount of support traffic if they get a new QEMU with a specific error message telling them what they need to fix, rather than one which just prints a generic "unknown option" message.
Sounds like a good idea at the first glance ... but at a second thought:
Don't we confuse the management layers like libvirt this way, which might probe for the availability of this option by executing QEMU with this parameter?
Thomas
Quoted 10 lines · Thomas Huth
Quoted 8 lines · Peter Maydell
The diffstat is nice, but can we retain the "please use $NEWOPTION instead of $OLDOPTION" message for a bit? I'm pretty sure there will be users out there who've been happily ignoring deprecation notices, and I think we'll reduce the amount of support traffic if they get a new QEMU with a specific error message telling them what they need to fix, rather than one which just prints a generic "unknown option" message.
Quoted 4 lines
Sounds like a good idea at the first glance ... but at a second thought:
Don't we confuse the management layers like libvirt this way, which might probe for the availability of this option by executing QEMU with this parameter?
If they do (which I'd hope they don't) then QEMU will exit with a failure status code, which they ought to identify as "not supported".
thanks
-- PMM
Quoted 11 lines · Peter Maydell
Quoted 10 lines · Thomas Huth
Quoted 8 lines · Peter Maydell
The diffstat is nice, but can we retain the "please use $NEWOPTION instead of $OLDOPTION" message for a bit? I'm pretty sure there will be users out there who've been happily ignoring deprecation notices, and I think we'll reduce the amount of support traffic if they get a new QEMU with a specific error message telling them what they need to fix, rather than one which just prints a generic "unknown option" message.
Quoted 8 lines
Quoted 4 lines
Sounds like a good idea at the first glance ... but at a second thought:
Don't we confuse the management layers like libvirt this way, which might probe for the availability of this option by executing QEMU with this parameter?If they do (which I'd hope they don't) then QEMU will exit with a failure status code, which they ought to identify as "not supported".
OK, makes sense. I'll cook a v2 of the patch accordingly...
Thomas
Quoted 17 lines · Thomas Huth
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Thomas Huth
The option has been marked as deprecated since QEMU 2.10, and so far nobody complained that it is urgently required anymore. So let's now get rid of this legacy pile, to simplify the usb code quite a bit.
Signed-off-by Thomas Huth <[email protected]>Quoted 8 lines
The diffstat is nice, but can we retain the "please use $NEWOPTION instead of $OLDOPTION" message for a bit? I'm pretty sure there will be users out there who've been happily ignoring deprecation notices, and I think we'll reduce the amount of support traffic if they get a new QEMU with a specific error message telling them what they need to fix, rather than one which just prints a generic "unknown option" message.
Quoted 4 lines
Sounds like a good idea at the first glance ... but at a second thought:
Don't we confuse the management layers like libvirt this way, which might probe for the availability of this option by executing QEMU with this parameter?
At least for libvirt, probing for supported command line arguments is preferable via QMP commands; if there is an easy way to make the -usbdevice command line argument exist to emit the warning, but not show up in the list of commands exposed over QMP, that is nicest (but I don't know how that would interact with Markus' plans to make ALL command line arguments introspectible, instead of our current ad hoc mix where some are and others are not).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Hello,
I'm afraid I can't even work out how to replace -usbdevice braille (or -usbdevice serial, all questions below apply, except making chardev default to braille):
... -usbdevice braille
-usbdevice braille: '-usbdevice' is deprecated, please use '-device usb-...' instead
but -device usb-serial is not actually documented in the manual page (same for usb-keyboard, usb-tablet, etc. for instance I can't find in the manpage anything about replacement for -usbdevice host:nnnn:nnnn)
... -device usb-braille
-device usb-braille: No 'usb-bus' bus found for device 'usb-braille'
... -device usb-bus -device usb-braille
-device usb-bus: 'usb-bus' is not a valid device model name
So the error message above should suggest -usb.
But then
... -usb -device usb-braille
-device usb-braille: Property chardev is required
that used to be a default, could we keep it a default when using -device? Hardly anybody would want to use usb-braille with something else than chardev braille.
... -usb -device usb-braille,chardev=braille
-device usb-serial,chardev=braille: Property 'usb-serial.chardev' can't find value 'braille'
Uh? It seems there is a parsing issue here?
So I'm afraid a lot is still missing here.
Samuel
Quoted 6 lines · Samuel Thibault
Hello,
I'm afraid I can't even work out how to replace -usbdevice braille (or -usbdevice serial, all questions below apply, except making chardev default to braille):
Quoted 7 lines
... -usbdevice braille
-usbdevice braille: '-usbdevice' is deprecated, please use '-device usb-...' instead
but -device usb-serial is not actually documented in the manual page (same for usb-keyboard, usb-tablet, etc. for instance I can't find in the manpage anything about replacement for -usbdevice host:nnnn:nnnn)
As mentioned in my other mail, it's in the qemu-doc here:
https://qemu.weilnetz.de/doc/qemu-doc.html#usb_005fdevices
Quoted 9 lines
But then
... -usb -device usb-braille
-device usb-braille: Property chardev is required
that used to be a default, could we keep it a default when using -device? Hardly anybody would want to use usb-braille with something else than chardev braille.
I think it's more common to not do any magic default setup with "-device", but if you think this should be the case here, it can certainly be added again (not with this patch here, though, since this is a separate issue).
Quoted 5 lines
... -usb -device usb-braille,chardev=braille
-device usb-serial,chardev=braille: Property 'usb-serial.chardev' can't find value 'braille'
Uh? It seems there is a parsing issue here?
Chardevs have to be specified with the "-chardev" parameter:
... -usb -device usb-braille,chardev=br0 -chardev braille,id=br0
HTH,
Thomas
Quoted 4 lines · Thomas Huth, on jeu. 04 janv. 2018 15:22:25 +0100, wrote:
On 04.01.2018 14:26, Samuel Thibault wrote:
I think it's more common to not do any magic default setup with "-device", but if you think this should be the case here, it can certainly be added again
Yes, please: it will almost never be used differently than with just a fresh braille chardev.
Samuel
Quoted 8 lines · Samuel Thibault
Quoted 4 lines · Thomas Huth, on jeu. 04 janv. 2018 15:22:25 +0100, wrote:
On 04.01.2018 14:26, Samuel Thibault wrote:
I think it's more common to not do any magic default setup with "-device", but if you think this should be the case here, it can certainly be added againYes, please: it will almost never be used differently than with just a fresh braille chardev.
It's pretty much untested, but would a patch like this help?
hw/usb/dev-serial.c +14 -0
@@ -556,6 +556,19 @@ static const TypeInfo serial_info = { .class_init = usb_serial_class_initfn, }; +static void usb_braille_realize (USBDevice *dev,Error **errp) +{ +USBSerialState *uss =USB_SERIAL_DEV (dev); + +if (!qemu_chr_fe_backend_connected (&uss->cs)) { +/* Create a default braille chardev if user did not specify one */ +Chardev *cdrv =qemu_chr_new ("braille" ,"braille" ); +qdev_prop_set_chr (&dev->qdev,"chardev" , cdrv); + } + +usb_serial_realize (dev, errp); +} +static Property braille_properties[] = {DEFINE_PROP_CHR ("chardev" , USBSerialState, cs),DEFINE_PROP_END_OF_LIST (),
@@ -568,6 +581,7 @@ static void usb_braille_class_initfn(ObjectClass *klass, void *data) uc->product_desc ="QEMU USB Braille" ; uc->usb_desc = &desc_braille; + uc->realize = usb_braille_realize; dc->props = braille_properties; }
Thomas
Hello,
Quoted 11 lines · Thomas Huth, on jeu. 04 janv. 2018 16:01:24 +0100, wrote:
Quoted 8 lines · Samuel Thibault
Quoted 4 lines · Thomas Huth, on jeu. 04 janv. 2018 15:22:25 +0100, wrote:
On 04.01.2018 14:26, Samuel Thibault wrote:
I think it's more common to not do any magic default setup with "-device", but if you think this should be the case here, it can certainly be added againYes, please: it will almost never be used differently than with just a fresh braille chardev.
It's pretty much untested, but would a patch like this help?
Completely!
-usb -device usb-braille
just work fine with it :)
Thanks,
Samuel