aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2009-11-27 13:05:53 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-03 15:25:58 -0600
commit0745eb1e4336bf665a911754d18ddd63794b352d (patch)
tree24589140448c346f39cddd526b8ad164c4e31327 /usb-linux.c
parentFix description of size parameter in qemu-img's help text (diff)
downloadqemu-kvm-0745eb1e4336bf665a911754d18ddd63794b352d.tar.gz
qemu-kvm-0745eb1e4336bf665a911754d18ddd63794b352d.tar.bz2
qemu-kvm-0745eb1e4336bf665a911754d18ddd63794b352d.zip
Fix recently introduced bugs in -usbdevice host
Commit 26a9e82a has the following flaws: * It enabled DEBUG. * It referenced two properties by the wrong name in usb_host_device_open(), which crashes with "qdev_prop_set: property "USB Host Device.bus" not found". * It broke "-usbdevice host:auto:..." by calling parse_filter() incorrectly. * It broke parsing of "-usbdevice host:BUS.ADDR" and "-usbdevice host:VID:PRID" with a trivial pasto. * It broke wildcards in "-usbdevice host:auto:...". Before, the four filter components were stored as int, and the wildcard was encoded as -1. The faulty commit changed storage to uint32_t, and the wildcard encoding to 0. But it failed to update parse_filter() accordingly. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'usb-linux.c')
-rw-r--r--usb-linux.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/usb-linux.c b/usb-linux.c
index 96f9a27e8..285ac227a 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -65,7 +65,7 @@ typedef int USBScanFunc(void *opaque, int bus_num, int addr, int class_id,
int vendor_id, int product_id,
const char *product_name, int speed);
-#define DEBUG
+//#define DEBUG
#ifdef DEBUG
#define dprintf printf
@@ -1005,7 +1005,7 @@ device_init(usb_host_register_devices)
USBDevice *usb_host_device_open(const char *devname)
{
- struct USBAutoFilter filter = { 0, 0, 0, 0 };
+ struct USBAutoFilter filter;
USBDevice *dev;
USBHostDevice *s;
char *p;
@@ -1014,22 +1014,26 @@ USBDevice *usb_host_device_open(const char *devname)
s = DO_UPCAST(USBHostDevice, dev, dev);
if (strstr(devname, "auto:")) {
- if (parse_filter(devname+5, &filter) < 0)
+ if (parse_filter(devname, &filter) < 0)
goto fail;
} else {
if ((p = strchr(devname, '.'))) {
- filter.bus_num = strtoul(devname, NULL, 0);
- filter.addr = strtoul(devname, NULL, 0);
+ filter.bus_num = strtoul(devname, NULL, 0);
+ filter.addr = strtoul(p + 1, NULL, 0);
+ filter.vendor_id = 0;
+ filter.product_id = 0;
} else if ((p = strchr(devname, ':'))) {
+ filter.bus_num = 0;
+ filter.addr = 0;
filter.vendor_id = strtoul(devname, NULL, 16);
- filter.product_id = strtoul(devname, NULL, 16);
+ filter.product_id = strtoul(p + 1, NULL, 16);
} else {
goto fail;
}
}
- qdev_prop_set_uint32(&dev->qdev, "bus", filter.bus_num);
- qdev_prop_set_uint32(&dev->qdev, "addr", filter.addr);
+ qdev_prop_set_uint32(&dev->qdev, "hostbus", filter.bus_num);
+ qdev_prop_set_uint32(&dev->qdev, "hostaddr", filter.addr);
qdev_prop_set_uint32(&dev->qdev, "vendorid", filter.vendor_id);
qdev_prop_set_uint32(&dev->qdev, "productid", filter.product_id);
qdev_init(&dev->qdev);
@@ -1449,10 +1453,10 @@ static int parse_filter(const char *spec, struct USBAutoFilter *f)
const char *p = spec;
int i;
- f->bus_num = -1;
- f->addr = -1;
- f->vendor_id = -1;
- f->product_id = -1;
+ f->bus_num = 0;
+ f->addr = 0;
+ f->vendor_id = 0;
+ f->product_id = 0;
for (i = BUS; i < DONE; i++) {
p = strpbrk(p, ":.");