usb patch queue
Hi,
Here comes the usb patch queue, with a bugfix collection and a documentation update.
please pull,
Gerd
The following changes since commit 76d20ea0f1b26ebd5da2f5fb2fdf3250cde887bb:
Merge remote-tracking branch 'armbru/tags/pull-qapi-2017-05-04-v3' into staging (2017-05-09 15:49:14 -0400)
are available in the git repository at:
git://git.kraxel.org/qemu tags/pull-usb-20170512-1
for you to fetch changes up to aa612b364ecbe1dc034efcabb04526f24e56c145:
hw/usb/dev-serial: Do not try to set vendorid or productid properties (2017-05-12 12:30:23 +0200)
----------------------------------------------------------------
usb: bugfixes, doc update
----------------------------------------------------------------
Gerd Hoffmann (1):
usb-redir: fix stack overflow in usbredir_log_data
Ladi Prosek (3):
xhci: fix logging
usb-hub: clear PORT_STAT_SUSPEND on wakeup
xhci: relax link check
Thomas Huth (2):
qemu-doc: Update to use the new way of attaching USB devices hw/usb/dev-serial: Do not try to set vendorid or productid properties
docs/qdev-device-use.txt | 6 ++-- hw/usb/dev-hub.c | 1 + hw/usb/dev-serial.c | 24 ++++--------- hw/usb/hcd-xhci.c | 9 ++--- hw/usb/redirect.c | 13 +------ qemu-doc.texi | 91 +++++++++++++++++++++++++++--------------------- 6 files changed, 64 insertions(+), 80 deletions(-)
[Qemu-devel] [PULL 2/6] usb-redir: fix stack overflow in usbredir_log_data
Don't reinvent a broken wheel, just use the hexdump function we have.
Impact: low, broken code doesn't run unless you have debug logging enabled.
Message-id: [email protected]
--- hw/usb/redirect.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
hw/usb/redirect.c +1 -12
@@ -229,21 +229,10 @@ static void usbredir_log(void *priv, int level, const char *msg)static void usbredir_log_data (USBRedirDevice *dev,const char *desc,const uint8_t *data,int len) { -int i, j, n; -if (dev->debug < usbredirparser_debug_data) {return ; } - -for (i =0 ; i < len; i += j) { -char buf[128 ]; - - n =sprintf (buf,"%s" , desc); -for (j =0 ; j <8 && i + j < len; j++) { - n +=sprintf (buf + n," %02X" , data[i + j]); - } -error_report ("%s" , buf); - } +qemu_hexdump ((char *)data, stderr, desc, len); }/*
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 3/6] xhci: fix logging
In reply to Gerd HoffmannFrom: Ladi Prosek <[email protected]>
slotid and epid were deleted from XHCITransfer in commit d6fcb29. Also deleting one unused forward declaration.
Message-id: [email protected]
--- hw/usb/hcd-xhci.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
hw/usb/hcd-xhci.c +2 -5
@@ -1790,9 +1790,6 @@ static void xhci_stall_ep(XHCITransfer *xfer) } } -static int xhci_submit (XHCIState *xhci,XHCITransfer *xfer, -XHCIEPContext *epctx); -static int xhci_setup_packet (XHCITransfer *xfer) {USBEndpoint *ep;
@@ -1806,7 +1803,7 @@ static int xhci_setup_packet(XHCITransfer *xfer) ep =xhci_epid_to_usbep (xfer->epctx);if (!ep) {DPRINTF ("xhci: slot %d has no device\n" , - xfer->slotid); + xfer->epctx->slotid);return -1 ; } }
@@ -1980,7 +1977,7 @@ static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer, XHCIEPContext *epctx {uint64_t mfindex; -DPRINTF ("xhci_submit(slotid=%d,epid=%d)\n" , xfer->slotid, xfer->epid); +DPRINTF ("xhci_submit(slotid=%d,epid=%d)\n" , epctx->slotid, epctx->epid); xfer->in_xfer = epctx->type>>2 ;
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 4/6] usb-hub: clear PORT_STAT_SUSPEND on wakeup
In reply to Gerd HoffmannFrom: Ladi Prosek <[email protected]>
The spec says:
Suspend: (PORT_SUSPEND) This field indicates whether or not the device on this port is suspended. Setting this field causes the device to suspend by not propagating bus traffic downstream. This field may be reset by a request or by resume signaling from the device attached to the port.
I can't find any specific statement like "the PORT_SUSPEND field is reset automatically on remote wakeup", but without this patch, the only way to reset it is via the ClearPortFeature request so the ".. or by resume signaling from the device" clause is clearly not implemented on the remote wakeup path.
The default xhci Windows driver does not issue the ClearPortFeature request and suspended devices attached to a hub don't properly get out of the suspended state. Interestingly, the default uhci Windows driver *does* issue the ClearPortFeature request and does not exhibit this problem.
Message-id: [email protected]
--- hw/usb/dev-hub.c | 1 + 1 file changed, 1 insertion(+)
hw/usb/dev-hub.c +1 -0
@@ -208,6 +208,7 @@ static void usb_hub_wakeup(USBPort *port1)USBHubPort *port = &s->ports[port1->index];if (port->wPortStatus &PORT_STAT_SUSPEND ) { + port->wPortStatus &= ~PORT_STAT_SUSPEND ; port->wPortChange |=PORT_STAT_C_SUSPEND ;usb_wakeup (s->intr,0 ); }
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 1/6] qemu-doc: Update to use the new way of attaching USB devices
In reply to Gerd HoffmannFrom: Thomas Huth <[email protected]>
The preferred way of adding USB devices is via "-device" and "device_add" nowadays, so let's start to get rid of "-usbdevice" and "usb_add" in the documentation. While we're at it, also add the new USB devices there which have been added to QEMU during the last years, and get rid of the old "vendorid" and "productid" parameters of "-usbdevice serial" which have been removed in QEMU version 0.14.0 already.
Message-id: [email protected]
--- docs/qdev-device-use.txt | 6 ++-- qemu-doc.texi | 91 +++++++++++++++++++++++++++--------------------- 2 files changed, 53 insertions(+), 44 deletions(-)
docs/qdev-device-use.txt +2 -4
@@ -182,15 +182,13 @@ The appropriate DEVNAME depends on the machine type. For type "pc": This lets you control I/O ports and IRQs. -* -usbdevice serial:vendorid=VID,productid=PRID becomes - -device usb-serial,vendorid=VID,productid=PRID +* -usbdevice serial::chardev becomes -device usb-serial,chardev=dev. * -usbdevice braille doesn't support LEGACY-CHARDEV syntax. It always uses "braille". With -device, this useful default is gone, so you have to use something like - -device usb-braille,chardev=braille,vendorid=VID,productid=PRID - -chardev braille,id=braille + -device usb-braille,chardev=braille -chardev braille,id=braille * -virtioconsole becomes -device virtio-serial-pci,class=C,vectors=V,ioeventfd=IOEVENTFD,max_ports=N
qemu-doc.texi +51 -40
132 lines not on this page · raw message
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 5/6] xhci: relax link check
In reply to Gerd HoffmannFrom: Ladi Prosek <[email protected]>
The strict td link limit added by commit "05f43d4 xhci: limit the number of link trbs we are willing to process" causes problems with Windows guests. Let's raise the limit.
This change is analogous to:
commit ab6b1105a2259c7072905887f71caa850ce63190
Author: Gerd Hoffmann <[email protected]>
Date: Tue Mar 7 09:40:18 2017 +0100
ohci: relax link check
Message-id: [email protected]
--- hw/usb/hcd-xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-xhci.c +1 -1
@@ -50,7 +50,7 @@/* Very pessimistic, let's hope it's enough for all cases */ #define EV_QUEUE (((3 * 24) + 16) * MAXSLOTS) -#define TRB_LINK_LIMIT 4 +#define TRB_LINK_LIMIT 32#define COMMAND_LIMIT 256#define TRANSFER_LIMIT 256
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 6/6] hw/usb/dev-serial: Do not try to set vendorid or productid properties
In reply to Gerd HoffmannFrom: Thomas Huth <[email protected]>
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).
Message-id: [email protected]
--- hw/usb/dev-serial.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)
hw/usb/dev-serial.c +6 -18
@@ -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 ;
@@ -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; }
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PULL 6/6] hw/usb/dev-serial: Do not try to set vendorid or productid properties
Quoted 51 lines · Gerd Hoffmann
From: Thomas Huth <[email protected]>
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()atqemu/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 <[email protected]>Message-id: [email protected]
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/usb/dev-serial.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)hw/usb/dev-serial.c +3
-9@@ -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 );
hw/usb/dev-serial.c static USBDevice *usb_serial_init(USBBus *bus, const char *filename) · line 530
Quoted 10 lines
hw/usb/dev-serial.c +2
-5-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
Quoted 13 lines
hw/usb/dev-serial.c +1
-4@@ -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; }
Re: [Qemu-devel] [PULL 6/6] hw/usb/dev-serial: Do not try to set vendorid or productid properties
Quoted 68 lines · Paolo Bonzini
Quoted 51 lines · Gerd Hoffmann
From: Thomas Huth <[email protected]>
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()atqemu/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 <[email protected]>Message-id: [email protected]
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/usb/dev-serial.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)hw/usb/dev-serial.c +3
-9@@ -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 );hw/usb/dev-serial.c static USBDevice *usb_serial_init(USBBus *bus, const char *filename) · line 530
Quoted 10 lines
hw/usb/dev-serial.c +2
-5-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
Quoted 7 lines
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.
Feel free to send an additional cleanup patch ... otherwise, I'd say let it bitrot for another year and we then remove it completely together with all the other "-usbdevice" functions...
Thomas
Re: [Qemu-devel] [PULL 6/6] hw/usb/dev-serial: Do not try to set vendorid or productid properties
Quoted 72 lines · Thomas Huth
Quoted 71 lines · Paolo Bonzini
Quoted 51 lines · Gerd Hoffmann
From: Thomas Huth <[email protected]>
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()atqemu/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 <[email protected]>Message-id: [email protected]
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/usb/dev-serial.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)hw/usb/dev-serial.c +3
-9@@ -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 );hw/usb/dev-serial.c static USBDevice *usb_serial_init(USBBus *bus, const char *filename) · line 530
Quoted 10 lines
hw/usb/dev-serial.c +2
-5-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 != ':') { }
Quoted 8 lines
Quoted 4 lines
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.
Feel free to send an additional cleanup patch ... otherwise, I'd say let it bitrot for another year and we then remove it completely together with all the other "-usbdevice" functions...
Well, Coverity reports it so I'd rather keep it clean...
Paolo
Re: [Qemu-devel] [PULL 6/6] hw/usb/dev-serial: Do not try to set vendorid or productid properties
Quoted 78 lines · Paolo Bonzini
Quoted 75 lines · Thomas Huth
Quoted 74 lines · Paolo Bonzini
Quoted 51 lines · Gerd Hoffmann
From: Thomas Huth <[email protected]>
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()atqemu/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 <[email protected]>Message-id: [email protected]
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/usb/dev-serial.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)hw/usb/dev-serial.c +3
-9@@ -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 );hw/usb/dev-serial.c static USBDevice *usb_serial_init(USBBus *bus, const char *filename) · line 530
Quoted 10 lines
hw/usb/dev-serial.c +2
-5-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".
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Even better, the "if (!*filename)" if just below can be moved first.
Feel free to send an additional cleanup patch ... otherwise, I'd say let it bitrot for another year and we then remove it completely together with all the other "-usbdevice" functions...
Well, Coverity reports it so I'd rather keep it clean...
Hmm, maybe we should simply remove "-usbdevice serial" right now already ... ? The vendorid/productid parameter handling has been broken since QEMU v0.14 already and nobody ever complained, so I guess hardly anybody is using "-usbdevice serial" anymore ... so I tend to simply remove it directly instead of going through the typical "mark-as-deprecated -> wait-two-release-cycles -> finally-remove-it" process here...
Paolo, Gerd, what do you think?
Thomas
Re: [Qemu-devel] [PULL 6/6] hw/usb/dev-serial: Do not try to set vendorid or productid properties
Hi,
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Feel free to send an additional cleanup patch ... otherwise, I'd say let it bitrot for another year and we then remove it completely together with all the other "-usbdevice" functions...
Well, Coverity reports it so I'd rather keep it clean...
It will be clean once removed, I likewise wouldn't put too much effort into code which is scheduled for removal anyway, especially for more or less cosmetic issues like unreachable code.
Quoted 6 lines
Hmm, maybe we should simply remove "-usbdevice serial" right now already ... ? The vendorid/productid parameter handling has been broken since QEMU v0.14 already and nobody ever complained, so I guess hardly anybody is using "-usbdevice serial" anymore ... so I tend to simply remove it directly instead of going through the typical "mark-as-deprecated -> wait-two-release-cycles -> finally-remove-it" process here...
Hmm, there is little reason to set vendorid + productid, so that alone is no strong indication that -usbdevice serial is unused. But nevertheless I think it usb-serial is one of the rarely used devices, so we could try ...
Order is probably along these lines:
usb hid devices are used alot (tablet on x86, all on !x86). usb-storage comes next I guess.
usb-host (aka pass-through) is important too of course.
Everything else (serial, net, bluetooth) is largely unused I guess.
ccid, uas and mtp are new enough to not carry around -usbdevice compatibility support.
cheers,
Gerd
Re: [Qemu-devel] [PULL 6/6] hw/usb/dev-serial: Do not try to set vendorid or productid properties
In reply to Thomas HuthQuoted 87 lines · Thomas Huth
Quoted 78 lines · Paolo Bonzini
Quoted 75 lines · Thomas Huth
Quoted 74 lines · Paolo Bonzini
Quoted 51 lines · Gerd Hoffmann
From: Thomas Huth <[email protected]>
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()atqemu/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 <[email protected]>Message-id: [email protected]
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/usb/dev-serial.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)hw/usb/dev-serial.c +3
-9@@ -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 );hw/usb/dev-serial.c static USBDevice *usb_serial_init(USBBus *bus, const char *filename) · line 530
Quoted 10 lines
hw/usb/dev-serial.c +2
-5-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".
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Even better, the "if (!*filename)" if just below can be moved first.
Feel free to send an additional cleanup patch ... otherwise, I'd say let it bitrot for another year and we then remove it completely together with all the other "-usbdevice" functions...
Well, Coverity reports it so I'd rather keep it clean...
Quoted 8 lines
Hmm, maybe we should simply remove "-usbdevice serial" right now already ... ? The vendorid/productid parameter handling has been broken since QEMU v0.14 already and nobody ever complained, so I guess hardly anybody is using "-usbdevice serial" anymore ... so I tend to simply remove it directly instead of going through the typical "mark-as-deprecated -> wait-two-release-cycles -> finally-remove-it" process here...
Paolo, Gerd, what do you think?
Being broken counts as being deprecated, I'd say.
But was -usbdevice serial broken? Or just its two optional (and somewhat exotic) parameters?
Re: [Qemu-devel] [PULL 6/6] hw/usb/dev-serial: Do not try to set vendorid or productid properties
Quoted 96 lines · Markus Armbruster
Quoted 94 lines · Thomas Huth
Quoted 78 lines · Paolo Bonzini
Quoted 75 lines · Thomas Huth
Quoted 74 lines · Paolo Bonzini
Quoted 51 lines · Gerd Hoffmann
From: Thomas Huth <[email protected]>
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()atqemu/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 <[email protected]>Message-id: [email protected]
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/usb/dev-serial.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)hw/usb/dev-serial.c +3
-9@@ -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 );hw/usb/dev-serial.c static USBDevice *usb_serial_init(USBBus *bus, const char *filename) · line 530
Quoted 10 lines
hw/usb/dev-serial.c +2
-5-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".
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Even better, the "if (!*filename)" if just below can be moved first.
Feel free to send an additional cleanup patch ... otherwise, I'd say let it bitrot for another year and we then remove it completely together with all the other "-usbdevice" functions...
Well, Coverity reports it so I'd rather keep it clean...
Hmm, maybe we should simply remove "-usbdevice serial" right now already ... ? The vendorid/productid parameter handling has been broken since QEMU v0.14 already and nobody ever complained, so I guess hardly anybody is using "-usbdevice serial" anymore ... so I tend to simply remove it directly instead of going through the typical "mark-as-deprecated -> wait-two-release-cycles -> finally-remove-it" process here...
Quoted 6 lines
Quoted 1 line
Paolo, Gerd, what do you think?
Being broken counts as being deprecated, I'd say.
But was -usbdevice serial broken? Or just its two optional (and somewhat exotic) parameters?
Just the two exotic parameters. But I agree with Gerd: If you google for the option to see how people are using the usbdevice option, you almost only find pages that describe "-usbdevice mouse/keyboard/tablet" or host passthrough. Sometimes also "storage". But hardly anything about "serial". However, I've now also found a bug where someone complains about the vendorid/productid problem:
https://bugs.launchpad.net/qemu/+bug/1180924
So that's an indication that at least some few people used "-usbdevice serial" in the past ... so let's fix that coverity warning now instead, then add some proper deprecation warnings to the "-usbdevice" parameter and remove all that legacy stuff next year...
Thomas
Stefan Hajnoczi
AppliedQuoted 36 lines · Gerd Hoffmann
Hi,
Here comes the usb patch queue, with a bugfix collection and a documentation update.
please pull,
GerdThe following changes since commit
76d20ea0f1b26ebd5da2f5fb2fdf3250cde887bb:Merge remote-tracking branch 'armbru/tags/pull-qapi-2017-05-04-v3' into staging (2017-05-09 15:49:14 -0400)
are available in the git repository at:
git://git.kraxel.org/qemutags/pull-usb-20170512-1for you to fetch changes up to
aa612b364ecbe1dc034efcabb04526f24e56c145:hw/usb/dev-serial: Do not try to set vendorid or productid properties (2017-05-12 12:30:23 +0200)
----------------------------------------------------------------
usb: bugfixes, doc update----------------------------------------------------------------
Gerd Hoffmann (1):
usb-redir: fix stack overflow inusbredir_log_dataLadi Prosek (3):
xhci: fix logging
usb-hub: clearPORT_STAT_SUSPENDon wakeup
xhci: relax link checkThomas Huth (2):
qemu-doc: Update to use the new way of attaching USB devices hw/usb/dev-serial: Do not try to set vendorid or productid properties
Quoted 8 lines
docs/qdev-device-use.txt | 6 ++-- hw/usb/dev-hub.c | 1 + hw/usb/dev-serial.c | 24 ++++--------- hw/usb/hcd-xhci.c | 9 ++--- hw/usb/redirect.c | 13 +------ qemu-doc.texi | 91 +++++++++++++++++++++++++++--------------------- 6 files changed, 64 insertions(+), 80 deletions(-)
Thanks, applied to my staging tree:
https://github.com/stefanha/qemu/commits/staging
Stefan