Message ID | a3431b44-d061-e8f6-a0f4-4f7c8a98a062@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hello, Thomas Huth, on jeu. 04 janv. 2018 16:01:24 +0100, wrote: > On 04.01.2018 15:23, Samuel Thibault wrote: > > 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. > > It's pretty much untested, but would a patch like this help? Completely! -usb -device usb-braille just work fine with it :) Thanks, Samuel
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -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; }