From: Paolo Bonzini <pbonzini@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>,
Thomas Huth <thuth@redhat.com>
Subject: Re: [Qemu-devel] [PULL 6/6] hw/usb/dev-serial: Do not try to set vendorid or productid properties
Date: Thu, 18 May 2017 14:00:58 +0200 [thread overview]
Message-ID: <a4f99c9b-1fb4-8a0c-ec3b-0cadc7dfd382@redhat.com> (raw)
In-Reply-To: <20170512122158.32032-7-kraxel@redhat.com>
On 12/05/2017 14:21, Gerd Hoffmann wrote:
> From: Thomas Huth <thuth@redhat.com>
>
> When starting QEMU with the legacy USB serial device like this:
>
> qemu-system-x86_64 -usbdevice serial:vendorid=0x1234:stdio
>
> it currently aborts since the vendorid property does not exist
> anymore (it has been removed by commit f29783f72ea77dfbd7ea0c9):
>
> Unexpected error in object_property_find() at qemu/qom/object.c:1008:
> qemu-system-x86_64: -usbdevice serial:vendorid=0x1234:stdio: Property
> '.vendorid' not found
> Aborted (core dumped)
>
> Fix this crash by issuing a more friendly error message instead
> (and simplify the code also a little bit this way).
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> Message-id: 1493883704-27604-1-git-send-email-thuth@redhat.com
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/usb/dev-serial.c | 24 ++++++------------------
> 1 file changed, 6 insertions(+), 18 deletions(-)
>
> diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
> index 6d5137383b..83a4f0e6fb 100644
> --- a/hw/usb/dev-serial.c
> +++ b/hw/usb/dev-serial.c
> @@ -513,27 +513,18 @@ static USBDevice *usb_serial_init(USBBus *bus, const char *filename)
> {
> USBDevice *dev;
> Chardev *cdrv;
> - uint32_t vendorid = 0, productid = 0;
> char label[32];
> static int index;
>
> while (*filename && *filename != ':') {
> const char *p;
> - char *e;
> +
> if (strstart(filename, "vendorid=", &p)) {
> - vendorid = strtol(p, &e, 16);
> - if (e == p || (*e && *e != ',' && *e != ':')) {
> - error_report("bogus vendor ID %s", p);
> - return NULL;
> - }
> - filename = e;
> + error_report("vendorid is not supported anymore");
> + return NULL;
> } else if (strstart(filename, "productid=", &p)) {
> - productid = strtol(p, &e, 16);
> - if (e == p || (*e && *e != ',' && *e != ':')) {
> - error_report("bogus product ID %s", p);
> - return NULL;
> - }
> - filename = e;
> + error_report("productid is not supported anymore");
> + return NULL;
> } else {
> error_report("unrecognized serial USB option %s", filename);
> return NULL;
All breanches of the "if" now return NULL, so the "while" loop in turn
can become an
if (*filename && *filename != ':') {
}
and the "while (*filename == ',')" subloop can go away, replaced by just
"return NULL".
Even better, the "if (!*filename)" if just below can be moved first.
Paolo
> @@ -554,10 +545,7 @@ static USBDevice *usb_serial_init(USBBus *bus, const char *filename)
>
> dev = usb_create(bus, "usb-serial");
> qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
> - if (vendorid)
> - qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
> - if (productid)
> - qdev_prop_set_uint16(&dev->qdev, "productid", productid);
> +
> return dev;
> }
>
>
next prev parent reply other threads:[~2017-05-18 12:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-12 12:21 [Qemu-devel] [PULL 0/6] usb patch queue Gerd Hoffmann
2017-05-12 12:21 ` [Qemu-devel] [PULL 1/6] qemu-doc: Update to use the new way of attaching USB devices Gerd Hoffmann
2017-05-12 12:21 ` [Qemu-devel] [PULL 2/6] usb-redir: fix stack overflow in usbredir_log_data Gerd Hoffmann
2017-05-12 12:21 ` [Qemu-devel] [PULL 3/6] xhci: fix logging Gerd Hoffmann
2017-05-12 12:21 ` [Qemu-devel] [PULL 4/6] usb-hub: clear PORT_STAT_SUSPEND on wakeup Gerd Hoffmann
2017-05-12 12:21 ` [Qemu-devel] [PULL 5/6] xhci: relax link check Gerd Hoffmann
2017-05-12 12:21 ` [Qemu-devel] [PULL 6/6] hw/usb/dev-serial: Do not try to set vendorid or productid properties Gerd Hoffmann
2017-05-18 12:00 ` Paolo Bonzini [this message]
2017-05-18 13:22 ` Thomas Huth
2017-05-18 13:35 ` Paolo Bonzini
2017-05-18 14:05 ` Thomas Huth
2017-05-18 16:12 ` Gerd Hoffmann
2017-05-19 5:54 ` Markus Armbruster
2017-05-19 6:20 ` Thomas Huth
2017-05-15 13:30 ` [Qemu-devel] [PULL 0/6] usb patch queue Stefan Hajnoczi
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=a4f99c9b-1fb4-8a0c-ec3b-0cadc7dfd382@redhat.com \
--to=pbonzini@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=samuel.thibault@ens-lyon.org \
--cc=thuth@redhat.com \
/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).