mirror of
https://github.com/qemu/qemu.git
synced 2024-11-26 04:13:39 +08:00
hw/usb/dev-serial: Do not try to set vendorid or productid properties
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 f29783f72e
):
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>
This commit is contained in:
parent
99f9aeba5d
commit
aa612b364e
@ -513,27 +513,18 @@ static USBDevice *usb_serial_init(USBBus *bus, const char *filename)
|
|||||||
{
|
{
|
||||||
USBDevice *dev;
|
USBDevice *dev;
|
||||||
Chardev *cdrv;
|
Chardev *cdrv;
|
||||||
uint32_t vendorid = 0, productid = 0;
|
|
||||||
char label[32];
|
char label[32];
|
||||||
static int index;
|
static int index;
|
||||||
|
|
||||||
while (*filename && *filename != ':') {
|
while (*filename && *filename != ':') {
|
||||||
const char *p;
|
const char *p;
|
||||||
char *e;
|
|
||||||
if (strstart(filename, "vendorid=", &p)) {
|
if (strstart(filename, "vendorid=", &p)) {
|
||||||
vendorid = strtol(p, &e, 16);
|
error_report("vendorid is not supported anymore");
|
||||||
if (e == p || (*e && *e != ',' && *e != ':')) {
|
return NULL;
|
||||||
error_report("bogus vendor ID %s", p);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
filename = e;
|
|
||||||
} else if (strstart(filename, "productid=", &p)) {
|
} else if (strstart(filename, "productid=", &p)) {
|
||||||
productid = strtol(p, &e, 16);
|
error_report("productid is not supported anymore");
|
||||||
if (e == p || (*e && *e != ',' && *e != ':')) {
|
return NULL;
|
||||||
error_report("bogus product ID %s", p);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
filename = e;
|
|
||||||
} else {
|
} else {
|
||||||
error_report("unrecognized serial USB option %s", filename);
|
error_report("unrecognized serial USB option %s", filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -554,10 +545,7 @@ static USBDevice *usb_serial_init(USBBus *bus, const char *filename)
|
|||||||
|
|
||||||
dev = usb_create(bus, "usb-serial");
|
dev = usb_create(bus, "usb-serial");
|
||||||
qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
|
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;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user