qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Samuel Thibault <samuel.thibault@gnu.org>
Cc: kraxel@redhat.com, qemu-devel@nongnu.org,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] usb: Remove legacy -usbdevice option
Date: Thu, 4 Jan 2018 16:01:24 +0100	[thread overview]
Message-ID: <a3431b44-d061-e8f6-a0f4-4f7c8a98a062@redhat.com> (raw)
In-Reply-To: <20180104142356.6hoar52jcoxrobgn@var.youpi.perso.aquilenet.fr>

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	other threads:[~2018-01-04 15:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-04 12:27 [Qemu-devel] [PATCH] usb: Remove legacy -usbdevice option Thomas Huth
2018-01-04 12:33 ` Peter Maydell
2018-01-04 12:44   ` Thomas Huth
2018-01-04 12:49     ` Peter Maydell
2018-01-04 12:50       ` Thomas Huth
2018-01-04 17:38     ` Eric Blake
2018-01-04 13:26 ` Samuel Thibault
2018-01-04 14:22   ` Thomas Huth
2018-01-04 14:23     ` Samuel Thibault
2018-01-04 15:01       ` Thomas Huth [this message]
2018-01-04 15:22         ` Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a3431b44-d061-e8f6-a0f4-4f7c8a98a062@redhat.com \
    --to=thuth@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).