qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] usb: Remove legacy -usbdevice option


From: Thomas Huth
Subject: Re: [Qemu-devel] [PATCH] usb: Remove legacy -usbdevice option
Date: Thu, 4 Jan 2018 16:01:24 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

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?

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;
 }
 

 Thomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]