Skip to contentSkip to conversation

usb: Remove legacy -usbdevice option

PATCH In review Thomas Huth 6 participants 33 messages Jan 4, 2018 – Jan 9, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
v2: Keep a stub in vl.c that still prints out an error message
with the hint to use -device instead.

 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               |  47 +-------------
 vl.c                          |  57 +----------------
 15 files changed, 5 insertions(+), 513 deletions(-)
 delete mode 100644 hw/usb/host-legacy.c
hw/usb/Makefile.objs +1 -1
index bdfead6..fbcd498 100644
@@ -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
index 3433452..ea4edd1 100644
@@ -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
index 443e3c3..2ed28c1 100644
@@ -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
index c40019d..5d74d5a 100644
@@ -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
index 85fc81b..aea7edc 100644
@@ -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
index e334d3b..aeadc86 100644
@@ -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
index bf70013..6371a24 100644
@@ -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
index 9dd9c6f..92318b2 100644
@@ -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
index 90bea73..e92fbc9 100644
@@ -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 +2 -45

53 lines not on this page · raw message

vl.c +2 -55

82 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#1 lore raw

qemu-options.hx STEXI · line 1251

Quoted 10 lines · Thomas Huth, on jeu. 04 janv. 2018 14:15:52 +0100, wrote:

-@item host:@var{bus}.@var{addr}

qemu-options.hx +0 -9
-Pass through the host device identified by @var{bus}.@var{addr} (Linux only).
-
-@item host:@var{vendor_id}:@var{product_id}
-Pass through the host device identified by @var{vendor_id}:@var{product_id}
-(Linux only).
-
-@item serial:[vendorid=@var{vendor_id}][,productid=@var{product_id}]:@var{dev}
-Serial converter to host character device @var{dev}, see @code{-serial} for the
-available devices.

as mentioned in my other mail, I don't find any place in the manpage where that is now documented. I believe this -usbdevice foo documentation needs to be converted to -device usb-foo instead of removed. Otherwise as it is now there is no way to even know that -device usb-mouse, -device usb-disk, etc. are available at all.

Samuel

#2 lore raw
Quoted 17 lines · Samuel Thibault

qemu-options.hx STEXI · line 1251

Quoted 10 lines · Thomas Huth, on jeu. 04 janv. 2018 14:15:52 +0100, wrote:

-@item host:@var{bus}.@var{addr}

qemu-options.hx +0 -9
-Pass through the host device identified by @var{bus}.@var{addr} (Linux only).
-
-@item host:@var{vendor_id}:@var{product_id}
-Pass through the host device identified by @var{vendor_id}:@var{product_id}
-(Linux only).
-
-@item serial:[vendorid=@var{vendor_id}][,productid=@var{product_id}]:@var{dev}
-Serial converter to host character device @var{dev}, see @code{-serial} for the
-available devices.

as mentioned in my other mail, I don't find any place in the manpage where that is now documented. I believe this -usbdevice foo documentation needs to be converted to -device usb-foo instead of removed. Otherwise as it is now there is no way to even know that -device usb-mouse, -device usb-disk, etc. are available at all.

I already did convert the chapter that describes the USB devices a couple of months ago, you can find it in our qemu-doc.html here:

https://qemu.weilnetz.de/doc/qemu-doc.html#usb_005fdevices

Thomas

#3 lore raw
Quoted 19 lines · Thomas Huth, on jeu. 04 janv. 2018 15:12:56 +0100, wrote:
Quoted 17 lines · Samuel Thibault

qemu-options.hx STEXI · line 1251

Quoted 10 lines · Thomas Huth, on jeu. 04 janv. 2018 14:15:52 +0100, wrote:

-@item host:@var{bus}.@var{addr}

qemu-options.hx +0 -9
-Pass through the host device identified by @var{bus}.@var{addr} (Linux only).
-
-@item host:@var{vendor_id}:@var{product_id}
-Pass through the host device identified by @var{vendor_id}:@var{product_id}
-(Linux only).
-
-@item serial:[vendorid=@var{vendor_id}][,productid=@var{product_id}]:@var{dev}
-Serial converter to host character device @var{dev}, see @code{-serial} for the
-available devices.

as mentioned in my other mail, I don't find any place in the manpage where that is now documented. I believe this -usbdevice foo documentation needs to be converted to -device usb-foo instead of removed. Otherwise as it is now there is no way to even know that -device usb-mouse, -device usb-disk, etc. are available at all.

Quoted 4 lines

I already did convert the chapter that describes the USB devices a couple of months ago, you can find it in our qemu-doc.html here:

https://qemu.weilnetz.de/doc/qemu-doc.html#usb_005fdevices

Ah, ok, thanks.

I'm however still unable to make usb-serial and usb-braille work, as mentioned in my other mail :)

Samuel

#4 lore raw
Quoted 2 lines · Samuel Thibault, on jeu. 04 janv. 2018 15:15:24 +0100, wrote:

I'm however still unable to make usb-serial and usb-braille work, as mentioned in my other mail :)

Ah, now with the documentation I understand, one has to also pass -chardev braille,chardev=foobar, and then
-device usb-braille,chardev=foobar works.

Would it be possible to make this automatic? Before I could tell people "use -usbdevice braille to test braille", and now it would be "use -chardev braille,chardev=foobar -device usb-braille,chardev=foobar"
...

Samuel

#5 lore raw
Quoted 11 lines · Samuel Thibault
Quoted 2 lines · Samuel Thibault, on jeu. 04 janv. 2018 15:15:24 +0100, wrote:

I'm however still unable to make usb-serial and usb-braille work, as mentioned in my other mail :)

Ah, now with the documentation I understand, one has to also pass

(quoted diff) +0 -2
-chardev braille,chardev=foobar, and then
-device usb-braille,chardev=foobar works.

Would it be possible to make this automatic? Before I could tell people "use -usbdevice braille to test braille", and now it would be "use -chardev braille,chardev=foobar -device usb-braille,chardev=foobar"

Maybe we can add "-braille" instead. Something like this:

hw/usb/dev-serial.c +19 -0
index 94b5c34afe..a5239b7fe7 100644
@@ -13,6 +13,7 @@
 #include "qemu-common.h"
 #include "qemu/cutils.h"
 #include "qemu/error-report.h"
+#include "sysemu/sysemu.h"
 #include "hw/usb.h"
 #include "hw/usb/desc.h"
 #include "chardev/char-serial.h"
@@ -552,6 +553,24 @@ static USBDevice *usb_braille_init(USBBus *bus, const char *unused)
     return dev;
 }
 
+void usb_braille_create(Error **errp)
+{
+    USBBus *bus = usb_bus_find(-1 /* any */);
+    USBDevice *dev = usb_braille_init(bus, "braille");
+    Error *local_err = NULL;
+
+    if (!dev) {
+        error_setg(errp, "Failed to create USB device");
+        return;
+    }
+    object_property_set_bool(OBJECT(dev), true, "realized", &local_err);
+    if (local_err) {
+        error_prepend(&local_err, "Failed to initialize USB device: ");
+        error_propagate(errp, local_err);
+        object_unparent(OBJECT(dev));
+    }
+}
+
 static const VMStateDescription vmstate_usb_serial = {
     .name = "usb-serial",
     .unmigratable = 1,
include/sysemu/sysemu.h +1 -0
index b4c10e62ba..eae3618735 100644
@@ -167,6 +167,7 @@ extern Chardev *serial_hds[MAX_SERIAL_PORTS];
 extern Chardev *parallel_hds[MAX_PARALLEL_PORTS];
 
 void hmp_info_usb(Monitor *mon, const QDict *qdict);
+void usb_braille_create(Error **errp);
 
 void add_boot_device_path(int32_t bootindex, DeviceState *dev,
                           const char *suffix);
qemu-options.hx +10 -0
index 94647e21e3..92886cb777 100644
@@ -1214,6 +1214,16 @@ STEXI
 Enable the USB driver (if it is not used by default yet).
 ETEXI
 
+DEF("braille", QEMU_OPTION_braille,
+    "-braille        add a USB braille reader\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -braille
+@findex -braille
+Add a USB Braille device.  The device will use BrlAPI to display the braille
+output on a real or fake device.
+ETEXI
+
 DEF("usbdevice", HAS_ARG, QEMU_OPTION_usbdevice,
     "-usbdevice name add the host or guest USB device 'name'\n",
     QEMU_ARCH_ALL)
roms/seabios +1 -1
index 63451fca13..cd47172a67 160000
@@ -1 +1 @@
-Subproject commit 63451fca13c75870e1703eb3e20584d91179aebc
+Subproject commit cd47172a673762a05a0c7bd27df6e3cc8febe8d6
vl.c +18 -0
index 5a8482a3a0..92d8775234 100644
@@ -1488,6 +1488,17 @@ static int usb_parse(const char *cmdline)
     return r;
 }
 
+static int do_braille(const char *unused)
+{
+    Error *err = NULL;
+    usb_braille_create(&err);
+    if (err) {
+        error_report_err(err);
+        return -1;
+    }
+    return 0;
+}
+
 /***********************************************************/
 /* machine registration */
 
@@ -2495,6 +2506,7 @@ struct device_config {
         DEV_DEBUGCON,  /* -debugcon */
         DEV_GDB,       /* -gdb, -s */
         DEV_SCLP,      /* s390 sclp */
+        DEV_BRAILLE,   /* -braille */
     } type;
     const char *cmdline;
     Location loc;
@@ -3411,6 +3423,9 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_no_fd_bootchk:
                 fd_bootchk = 0;
                 break;
+            case QEMU_OPTION_braille:
+                add_device_config(DEV_BRAILLE, "braille");
+                break;
             case QEMU_OPTION_netdev:
                 default_net = 0;
                 if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) {
@@ -4728,6 +4743,9 @@ int main(int argc, char **argv, char **envp)
         if (foreach_device_config(DEV_USB, usb_parse) < 0)
             exit(1);
     }
+    if (foreach_device_config(DEV_BRAILLE, do_braille) < 0) {
+        exit(1);
+    }
 
     /* Check if IGD GFX passthrough. */
     igd_gfx_passthru();

Untested, but it compiles (and it keeps syntactic sugar out of device code). It still would let Thomas remove over 400 lines of code, and would cater for the specific use case.

Paolo

#6 lore raw

Hello,

Quoted 9 lines · Paolo Bonzini, on jeu. 04 janv. 2018 16:19:02 +0100, wrote:
Quoted 8 lines · Samuel Thibault
Quoted 2 lines · Samuel Thibault, on jeu. 04 janv. 2018 15:15:24 +0100, wrote:

I'm however still unable to make usb-serial and usb-braille work, as mentioned in my other mail :)

Ah, now with the documentation I understand, one has to also pass

(quoted diff) +0 -2
-chardev braille,chardev=foobar, and then
-device usb-braille,chardev=foobar works.
Quoted 5 lines
Quoted 3 lines

Would it be possible to make this automatic? Before I could tell people "use -usbdevice braille to test braille", and now it would be "use -chardev braille,chardev=foobar -device usb-braille,chardev=foobar"

Maybe we can add "-braille" instead.

I guess such legacy-looking option would be frowned up :)

And anyway we need to be able to specify either -serial braille or -device usb-braille.

Samuel

#7 lore raw
Quoted 2 lines · Samuel Thibault
Quoted 1 line

Maybe we can add "-braille" instead.

I guess such legacy-looking option would be frowned up :)

Not really. As long as it doesn't propagate everywhere in device code, it's fine. We are not going to deprecate "-serial mon:stdio", so...

Quoted 2 lines

And anyway we need to be able to specify either -serial braille or -device usb-braille.

So "-braille serial" and "-braille usb"?

Paolo

#8 lore raw
Quoted 11 lines · Paolo Bonzini, on jeu. 04 janv. 2018 16:28:27 +0100, wrote:
Quoted 2 lines · Samuel Thibault
Quoted 1 line

Maybe we can add "-braille" instead.

I guess such legacy-looking option would be frowned up :)

Not really. As long as it doesn't propagate everywhere in device code, it's fine. We are not going to deprecate "-serial mon:stdio", so...

Quoted 2 lines

And anyway we need to be able to specify either -serial braille or -device usb-braille.

So "-braille serial" and "-braille usb"?

Well, why not, it just doesn't seem to me much simpler than "-serial braille" and "-device usb-braille" :)

Samuel

#9 lore raw
Quoted 5 lines · Samuel Thibault
Quoted 3 lines
Quoted 2 lines

And anyway we need to be able to specify either -serial braille or -device usb-braille.

So "-braille serial" and "-braille usb"?

Well, why not, it just doesn't seem to me much simpler than "-serial braille" and "-device usb-braille" :)

The difference is that "-device usb-braille" would have magic character backend creation in usb_braille_realize. *That* is what I really frown upon.

Paolo

#10 lore raw
In reply to Samuel Thibault
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Paolo Bonzini, on jeu. 04 janv. 2018 16:28:27 +0100, wrote:
Quoted 2 lines · Samuel Thibault
Quoted 1 line

Maybe we can add "-braille" instead.

I guess such legacy-looking option would be frowned up :)

Not really. As long as it doesn't propagate everywhere in device code, it's fine. We are not going to deprecate "-serial mon:stdio", so...

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

And anyway we need to be able to specify either -serial braille or -device usb-braille.

So "-braille serial" and "-braille usb"?

Well, why not, it just doesn't seem to me much simpler than "-serial braille" and "-device usb-braille" :)

FWIW, I think I'd also rather prefer to add some little bit of "magic" to "-device usb-braille" instead of introducing yet another command line parameter. QEMU's command line interface is already way too much overcrowded, so IMHO we should try to avoid new parameters if possible.

Thomas

#11 lore raw
Quoted 7 lines · Thomas Huth
Quoted 2 lines

Well, why not, it just doesn't seem to me much simpler than "-serial braille" and "-device usb-braille" :)

FWIW, I think I'd also rather prefer to add some little bit of "magic" to "-device usb-braille" instead of introducing yet another command line parameter. QEMU's command line interface is already way too much overcrowded, so IMHO we should try to avoid new parameters if possible.

The point of deprecation is not to make the interface simpler, it is to avoid cases where one option is doing too much and/or crossing abstraction boundaries, for example -net creating both a device and a hub port.

"-serial" is okay because it only creates the front-end, it's the board that decides how to attach it to the back-end.

-usbdevice creating both a front-end and a back-end is not a problem per se. The issue with -usbdevice is just that it's too much code.

However, adding magic to "-device usb-braille" that creates both a front-end and a back-end is completely the opposite of sane...

Paolo

#12 lore raw
Quoted 5 lines · Paolo Bonzini

The point of deprecation is not to make the interface simpler, it is to avoid cases where one option is doing too much and/or crossing abstraction boundaries, for example -net creating both a device and a hub port.

Quoted 8 lines

"-serial" is okay because it only creates the front-end, it's the board that decides how to attach it to the back-end.

-usbdevice creating both a front-end and a back-end is not a problem per se. The issue with -usbdevice is just that it's too much code.

However, adding magic to "-device usb-braille" that creates both a front-end and a back-end is completely the opposite of sane...

Agreed with this.

Is there any mileage in considering the idea of a generic bit in the option-parsing code that has a table of mappings from legacy-style-simple-option to complex-set-of-device-etc options, so we can retain userfriendliness without per-kind-of-thing special casing, or is that too simplistic to work ?

thanks
-- PMM

#13 lore raw
Quoted 15 lines · Peter Maydell
Quoted 5 lines · Paolo Bonzini

The point of deprecation is not to make the interface simpler, it is to avoid cases where one option is doing too much and/or crossing abstraction boundaries, for example -net creating both a device and a hub port.

Quoted 8 lines

"-serial" is okay because it only creates the front-end, it's the board that decides how to attach it to the back-end.

-usbdevice creating both a front-end and a back-end is not a problem per se. The issue with -usbdevice is just that it's too much code.

However, adding magic to "-device usb-braille" that creates both a front-end and a back-end is completely the opposite of sane...

Quoted 7 lines

Agreed with this.

Is there any mileage in considering the idea of a generic bit in the option-parsing code that has a table of mappings from legacy-style-simple-option to complex-set-of-device-etc options, so we can retain userfriendliness without per-kind-of-thing special casing, or is that too simplistic to work ?

The idea is great, and I wish all syntactic sugar would get expanded that way. However, a static table won't work when the expansion depends on other settings, such as the machine type. Extra fun when an expansion exists only for some machine types, say the ones where the devices to be created are qdevified.

#14 lore raw
In reply to Paolo Bonzini
Quoted 5 lines · Paolo Bonzini, on jeu. 04 janv. 2018 16:47:16 +0100, wrote:

The point of deprecation is not to make the interface simpler, it is to avoid cases where one option is doing too much and/or crossing abstraction boundaries, for example -net creating both a device and a hub port.

Quoted 8 lines

"-serial" is okay because it only creates the front-end, it's the board that decides how to attach it to the back-end.

-usbdevice creating both a front-end and a back-end is not a problem per se. The issue with -usbdevice is just that it's too much code.

However, adding magic to "-device usb-braille" that creates both a front-end and a back-end is completely the opposite of sane...

Well, this is also what happens with -device usb-mouse, usb-kbd etc.:
they also plug with keyboard & mouse pipes of the qemu graphical frontend. braille is just the same vein for the user.

Samuel

#15 lore raw
Quoted 5 lines · Samuel Thibault
Quoted 2 lines

However, adding magic to "-device usb-braille" that creates both a front-end and a back-end is completely the opposite of sane...

Well, this is also what happens with -device usb-mouse, usb-kbd etc.:
they also plug with keyboard & mouse pipes of the qemu graphical frontend. braille is just the same vein for the user.

No, they don't create a new UI object magically that wasn't there before. They just let you add a device, e.g. a USB tablet, that listens on an _existing_ UI (GTK+ or SDL or similar).

Paolo

#16 lore raw
Quoted 10 lines · Paolo Bonzini, on jeu. 04 janv. 2018 18:11:00 +0100, wrote:
Quoted 5 lines · Samuel Thibault
Quoted 2 lines

However, adding magic to "-device usb-braille" that creates both a front-end and a back-end is completely the opposite of sane...

Well, this is also what happens with -device usb-mouse, usb-kbd etc.:
they also plug with keyboard & mouse pipes of the qemu graphical frontend. braille is just the same vein for the user.

No, they don't create a new UI object magically that wasn't there before. They just let you add a device, e.g. a USB tablet, that listens on an _existing_ UI (GTK+ or SDL or similar).

Technically for the qemu developper, yes.

But for the user, no.

Samuel

#17 lore raw
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Paolo Bonzini, on jeu. 04 janv. 2018 18:11:00 +0100, wrote:
Quoted 5 lines · Samuel Thibault
Quoted 2 lines

However, adding magic to "-device usb-braille" that creates both a front-end and a back-end is completely the opposite of sane...

Well, this is also what happens with -device usb-mouse, usb-kbd etc.:
they also plug with keyboard & mouse pipes of the qemu graphical frontend. braille is just the same vein for the user.

Quoted 7 lines
Quoted 3 lines

No, they don't create a new UI object magically that wasn't there before. They just let you add a device, e.g. a USB tablet, that listens on an _existing_ UI (GTK+ or SDL or similar).

Technically for the qemu developper, yes.

But for the user, no.

That's not true. With or without "-usbdevice tablet", you use the same
mouse or keyboard device as the input source.

Paolo

#18 lore raw
Quoted 13 lines · Paolo Bonzini, on jeu. 04 janv. 2018 18:57:18 +0100, wrote:
Quoted 12 lines · Samuel Thibault
Quoted 10 lines · Paolo Bonzini, on jeu. 04 janv. 2018 18:11:00 +0100, wrote:
Quoted 5 lines · Samuel Thibault
Quoted 2 lines

However, adding magic to "-device usb-braille" that creates both a front-end and a back-end is completely the opposite of sane...

Well, this is also what happens with -device usb-mouse, usb-kbd etc.:
they also plug with keyboard & mouse pipes of the qemu graphical frontend. braille is just the same vein for the user.

No, they don't create a new UI object magically that wasn't there before. They just let you add a device, e.g. a USB tablet, that listens on an _existing_ UI (GTK+ or SDL or similar).

Quoted 6 lines
Quoted 3 lines

Technically for the qemu developper, yes.

But for the user, no.

That's not true. With or without "-usbdevice tablet", you use the same
mouse or keyboard device as the input source.

Yes, because it preexists in the mind of the user. That's the same for braille. The fact that braille has to go through a character-to-brlapi conversion is not the business of the user, he just wants braille out.

Samuel

#19 lore raw
In reply to Paolo Bonzini
Quoted 13 lines · Paolo Bonzini
Quoted 12 lines · Samuel Thibault
Quoted 10 lines · Paolo Bonzini, on jeu. 04 janv. 2018 18:11:00 +0100, wrote:
Quoted 5 lines · Samuel Thibault
Quoted 2 lines

However, adding magic to "-device usb-braille" that creates both a front-end and a back-end is completely the opposite of sane...

Well, this is also what happens with -device usb-mouse, usb-kbd etc.:
they also plug with keyboard & mouse pipes of the qemu graphical frontend. braille is just the same vein for the user.

No, they don't create a new UI object magically that wasn't there before. They just let you add a device, e.g. a USB tablet, that listens on an _existing_ UI (GTK+ or SDL or similar).

Quoted 6 lines
Quoted 3 lines

Technically for the qemu developper, yes.

But for the user, no.

That's not true. With or without "-usbdevice tablet", you use the same
mouse or keyboard device as the input source.

But from a users point of view: Why are the mouse and keyboard input sources available out of the box, while braille has to be specified manually? I think Samuel has a point here...

So just another idea: Instead of adding the magic sugar code to the usb-braille device, we could also add some code to vl.c or somewhere else that checks whether a braille guest device is available and then wires it up automatically with a braille host device (unless -no-defaults has been specified, or the user already set chardev=... there). Would that make more sense in your eyes than to put this code into the usb-braille device directly?

Thomas

#20 lore raw
Quoted 16 lines · Thomas Huth
Quoted 15 lines · Paolo Bonzini
Quoted 14 lines · Samuel Thibault
Quoted 10 lines · Paolo Bonzini, on jeu. 04 janv. 2018 18:11:00 +0100, wrote:
Quoted 5 lines · Samuel Thibault
Quoted 2 lines

However, adding magic to "-device usb-braille" that creates both a front-end and a back-end is completely the opposite of sane...

Well, this is also what happens with -device usb-mouse, usb-kbd etc.:
they also plug with keyboard & mouse pipes of the qemu graphical frontend. braille is just the same vein for the user.

No, they don't create a new UI object magically that wasn't there before. They just let you add a device, e.g. a USB tablet, that listens on an _existing_ UI (GTK+ or SDL or similar).

Technically for the qemu developper, yes.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

But for the user, no.

That's not true. With or without "-usbdevice tablet", you use the same
mouse or keyboard device as the input source.

But from a users point of view: Why are the mouse and keyboard input sources available out of the box, while braille has to be specified manually? I think Samuel has a point here...

There are two aspects of this:

1) You have specified the mouse and keyboard backends, actually---via "-display vnc" or "-display gtk" or "-display none".

2) The model for input backends is one-to-many (all guest mice/tablets/keyboards share the same backends), while the model for chardev backends is one-to-one.

Quoted 7 lines

So just another idea: Instead of adding the magic sugar code to the usb-braille device, we could also add some code to vl.c or somewhere else that checks whether a braille guest device is available and then wires it up automatically with a braille host device (unless -no-defaults has been specified, or the user already set chardev=... there). Would that make more sense in your eyes than to put this code into the usb-braille device directly?

I'm not sure how that would work. Also, if you use "-device" (or "-netdev", or "-blockdev", or "-chardev", or "-mon", or "-fsdev" or "-object") you are explicitly saying you don't want any magic.

Magic on the other hand is fully within the scope of legacy options ("-net", "-drive" especially without "if=none", "-usbdevice", "-serial", "-virtfs", etc.).

Paolo

#21 lore raw
In reply to Paolo Bonzini
Quoted 14 lines · Paolo Bonzini
Quoted 7 lines · Thomas Huth
Quoted 2 lines

Well, why not, it just doesn't seem to me much simpler than "-serial braille" and "-device usb-braille" :)

FWIW, I think I'd also rather prefer to add some little bit of "magic" to "-device usb-braille" instead of introducing yet another command line parameter. QEMU's command line interface is already way too much overcrowded, so IMHO we should try to avoid new parameters if possible.

The point of deprecation is not to make the interface simpler, it is to avoid cases where one option is doing too much and/or crossing abstraction boundaries, for example -net creating both a device and a hub port.

Quoted 8 lines

"-serial" is okay because it only creates the front-end, it's the board that decides how to attach it to the back-end.

-usbdevice creating both a front-end and a back-end is not a problem per se. The issue with -usbdevice is just that it's too much code.

However, adding magic to "-device usb-braille" that creates both a front-end and a back-end is completely the opposite of sane...

Ok, makes sense.

But instead of introducing a new "-braille" parameter, maybe we should rather keep some of the convenience "-usbdevice" possibilities around? E.g. keep "-usbdevice braille", "-usbdevice mouse", etc. but remove things like "-usbdevice serial" and "-usbdevice host" where the code is rather ugly and the user do not gain much in comparison to "-device" ?

Thomas

#22 lore raw
Quoted 6 lines · Thomas Huth

But instead of introducing a new "-braille" parameter, maybe we should rather keep some of the convenience "-usbdevice" possibilities around? E.g. keep "-usbdevice braille", "-usbdevice mouse", etc. but remove things like "-usbdevice serial" and "-usbdevice host" where the code is rather ugly and the user do not gain much in comparison to "-device" ?

That would work too. But I'm not sure why keep all the usbdevice infrastructure when we can do the same (at the price of a small cmdline incompatibility) with only 50 lines of code.

Paolo

#23 lore raw
Quoted 11 lines · Paolo Bonzini
Quoted 6 lines · Thomas Huth

But instead of introducing a new "-braille" parameter, maybe we should rather keep some of the convenience "-usbdevice" possibilities around? E.g. keep "-usbdevice braille", "-usbdevice mouse", etc. but remove things like "-usbdevice serial" and "-usbdevice host" where the code is rather ugly and the user do not gain much in comparison to "-device" ?

That would work too. But I'm not sure why keep all the usbdevice infrastructure when we can do the same (at the price of a small cmdline incompatibility) with only 50 lines of code.

I'm just afraid that we will end up with more new parameters in the end than just "-braille" - or do we feel confident enough that "-usbdevice braille" is the only one that would need a sugared replacement?

Thomas

#24 lore raw
Quoted 11 lines · Thomas Huth
Quoted 8 lines
Quoted 5 lines

But instead of introducing a new "-braille" parameter, maybe we should rather keep some of the convenience "-usbdevice" possibilities around? E.g. keep "-usbdevice braille", "-usbdevice mouse", etc. but remove things like "-usbdevice serial" and "-usbdevice host" where the code is rather ugly and the user do not gain much in comparison to "-device" ?

That would work too. But I'm not sure why keep all the usbdevice infrastructure when we can do the same (at the price of a small cmdline incompatibility) with only 50 lines of code.

I'm just afraid that we will end up with more new parameters in the end than just "-braille" - or do we feel confident enough that "-usbdevice braille" is the only one that would need a sugared replacement?

I agree that we should plan for suboptions, so it could be "-braille [serial|usb]" for now.

Paolo

#25 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 8 lines · Thomas Huth
Quoted 8 lines
Quoted 5 lines

But instead of introducing a new "-braille" parameter, maybe we should rather keep some of the convenience "-usbdevice" possibilities around? E.g. keep "-usbdevice braille", "-usbdevice mouse", etc. but remove things like "-usbdevice serial" and "-usbdevice host" where the code is rather ugly and the user do not gain much in comparison to "-device" ?

That would work too. But I'm not sure why keep all the usbdevice infrastructure when we can do the same (at the price of a small cmdline incompatibility) with only 50 lines of code.

Quoted 6 lines
Quoted 3 lines

I'm just afraid that we will end up with more new parameters in the end than just "-braille" - or do we feel confident enough that "-usbdevice braille" is the only one that would need a sugared replacement?

I agree that we should plan for suboptions, so it could be "-braille [serial|usb]" for now.

I'm rather afraid that someone else will also complain about the removal of the other usbdevice options, so that we'll finally end up with new -usbhost, -usbbt and -usbyounameit convenience options... in that case it might be better to keep "-usbdevice" instead?

Thomas

#26 lore raw
Quoted 14 lines · Thomas Huth
Quoted 13 lines · Paolo Bonzini
Quoted 11 lines · Thomas Huth
Quoted 8 lines
Quoted 5 lines

But instead of introducing a new "-braille" parameter, maybe we should rather keep some of the convenience "-usbdevice" possibilities around? E.g. keep "-usbdevice braille", "-usbdevice mouse", etc. but remove things like "-usbdevice serial" and "-usbdevice host" where the code is rather ugly and the user do not gain much in comparison to "-device" ?

That would work too. But I'm not sure why keep all the usbdevice infrastructure when we can do the same (at the price of a small cmdline incompatibility) with only 50 lines of code.

I'm just afraid that we will end up with more new parameters in the end than just "-braille" - or do we feel confident enough that "-usbdevice braille" is the only one that would need a sugared replacement?

Quoted 7 lines
Quoted 2 lines

I agree that we should plan for suboptions, so it could be "-braille [serial|usb]" for now.

I'm rather afraid that someone else will also complain about the removal of the other usbdevice options, so that we'll finally end up with new -usbhost, -usbbt and -usbyounameit convenience options... in that case it might be better to keep "-usbdevice" instead?

We can and should say no. Sometimes we can also say yes though. :)

I just think that 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.

Paolo

#27 lore raw
Quoted 23 lines · Paolo Bonzini
Quoted 14 lines · Thomas Huth
Quoted 13 lines · Paolo Bonzini
Quoted 11 lines · Thomas Huth
Quoted 8 lines
Quoted 5 lines

But instead of introducing a new "-braille" parameter, maybe we should rather keep some of the convenience "-usbdevice" possibilities around? E.g. keep "-usbdevice braille", "-usbdevice mouse", etc. but remove things like "-usbdevice serial" and "-usbdevice host" where the code is rather ugly and the user do not gain much in comparison to "-device" ?

That would work too. But I'm not sure why keep all the usbdevice infrastructure when we can do the same (at the price of a small cmdline incompatibility) with only 50 lines of code.

I'm just afraid that we will end up with more new parameters in the end than just "-braille" - or do we feel confident enough that "-usbdevice braille" is the only one that would need a sugared replacement?

Quoted 7 lines
Quoted 2 lines

I agree that we should plan for suboptions, so it could be "-braille [serial|usb]" for now.

I'm rather afraid that someone else will also complain about the removal of the other usbdevice options, so that we'll finally end up with new -usbhost, -usbbt and -usbyounameit convenience options... in that case it might be better to keep "-usbdevice" instead?

Quoted 5 lines

We can and should say no. Sometimes we can also say yes though. :)

I just think that 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.

OK, then let's go forward and use your "-braille serial|usb" patch, and nuke the -usbdevice option completely (assuming Gerd agrees, being the USB maintainer).

Thomas

#28 lore raw

Hi,

Quoted 9 lines
Quoted 5 lines

We can and should say no. Sometimes we can also say yes though. :)

I just think that 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.

OK, then let's go forward and use your "-braille serial|usb" patch, and nuke the -usbdevice option completely (assuming Gerd agrees, being the USB maintainer).

Hmm. I'm not sure it is a good idea to rush new convinience shortcuts.

In the discussion I've seen a bunch of different possible approaches ...

(1) new -braille option, hardcoded.
(2) new -braille option, with some "replace shortcuts with long versions" mechanism we could use for other shortcuts too.
(3) magically create chardev in usb-braille realize.
(4) allow chardev properties have a default.
(5) stick with -usbdevice.

... with no clear winnner.

I think nobody wants (5), but I think it is the best short-term option while we are busy hashing out which of options 1 ... 4 (or possibly something else) works best long-term.

Also it's not clear what is supposed to happen for "-braille serial". Will that effectively transform from one shortcut to another (-serial ...)?

So I'd suggest to simply drop the usb_legacy_register() calls + registered functions from most (all but braille?) devices.

cheers,
Gerd

#29 lore raw
In reply to Paolo Bonzini
Quoted 6 lines · Paolo Bonzini
Quoted 2 lines · Samuel Thibault
Quoted 1 line

Maybe we can add "-braille" instead.

I guess such legacy-looking option would be frowned up :)

Not really. As long as it doesn't propagate everywhere in device code, it's fine. We are not going to deprecate "-serial mon:stdio", so...

Hmm, maybe we could also introduce a "-serial usb:braille" command that automagically also creates an usb-braille device, to avoid to introduce a new "-braille" command? It's bending the meaning of "-serial" quite a bit, though...

Thomas

#30 lore raw
In reply to Paolo Bonzini
Quoted 9 lines · Paolo Bonzini
Quoted 8 lines · Samuel Thibault
Quoted 2 lines · Samuel Thibault, on jeu. 04 janv. 2018 15:15:24 +0100, wrote:

I'm however still unable to make usb-serial and usb-braille work, as mentioned in my other mail :)

Ah, now with the documentation I understand, one has to also pass

(quoted diff) +0 -2
-chardev braille,chardev=foobar, and then
-device usb-braille,chardev=foobar works.
Quoted 5 lines
Quoted 3 lines

Would it be possible to make this automatic? Before I could tell people "use -usbdevice braille to test braille", and now it would be "use -chardev braille,chardev=foobar -device usb-braille,chardev=foobar"

Maybe we can add "-braille" instead. Something like this:

More sugar, ugh!

What about giving braille property chardev a sensible default? Ideally in a self-documenting way, so that -device usb-braille,help shows the default.

#31 lore raw
Quoted 9 lines · Markus Armbruster
Quoted 4 lines
Quoted 3 lines

Would it be possible to make this automatic? Before I could tell people "use -usbdevice braille to test braille", and now it would be "use -chardev braille,chardev=foobar -device usb-braille,chardev=foobar"

Maybe we can add "-braille" instead. Something like this:

More sugar, ugh!

What about giving braille property chardev a sensible default? Ideally in a self-documenting way, so that -device usb-braille,help shows the default.

That would mean automatically creating a back-end in a device's realize property. I'd rather avoid that, sugar is not bad per se.

Paolo

#32 lore raw
Quoted 5 lines · Paolo Bonzini
Quoted 4 lines · Markus Armbruster
Quoted 4 lines
Quoted 3 lines

Would it be possible to make this automatic? Before I could tell people "use -usbdevice braille to test braille", and now it would be "use -chardev braille,chardev=foobar -device usb-braille,chardev=foobar"

Maybe we can add "-braille" instead. Something like this:

Quoted 8 lines
Quoted 5 lines

More sugar, ugh!

What about giving braille property chardev a sensible default? Ideally in a self-documenting way, so that -device usb-braille,help shows the default.

That would mean automatically creating a back-end in a device's realize property. I'd rather avoid that,

That's one way to do it. A perhaps less odious way would be to make qdev core support chardev defaults just like it supports integer defaults. For integers, we specify the default value as parameter for DEFINE_PROP_INT64() & friends. For chardevs, we'd can't specify the value, but we could specify the option string to use for creating it.

One reason I like sane defaults better than sugar: users can more easily grow from

-device usb-braille

to

-device usb-braille,chardev=braille-be -chardev id=braille-be,...

than from

-braille

Quoted 1 line

sugar is not bad per se.

Stirring a teaspoon of sugar into your tea may be of debatable taste, but I certainly wouldn't call it bad per se. However, we're already closer to upending the sugar bowl, then raiding the pantry for more.