|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH V4 3/7] libxl: add pvusb API
On 06/15/2015 04:17 PM, George Dunlap wrote: On Wed, Jun 10, 2015 at 4:20 AM, Chunyan Liu <cyliu@xxxxxxxx> wrote: A patch for qemu to support the busid is trivial, as the structures already contain the necessary elements: --- a/hw/usb/host-legacy.c +++ b/hw/usb/host-legacy.c@@ -53,11 +53,6 @@ static int parse_filter(const char *spec, struct USBAutoFilter *f)
const char *p = spec;
int i;
- f->bus_num = 0;
- f->addr = 0;
- f->vendor_id = 0;
- f->product_id = 0;
-
for (i = BUS; i < DONE; i++) {
p = strpbrk(p, ":.");
if (!p) {
@@ -100,32 +95,47 @@ USBDevice *usb_host_device_open(USBBus *bus, const
char *devname)
dev = usb_create(bus, "usb-host");
+ memset(&filter, 0, sizeof(filter));
+
if (strstr(devname, "auto:")) {
if (parse_filter(devname, &filter) < 0) {
goto fail;
}
- } else {
- p = strchr(devname, '.');
- if (p) {
- filter.bus_num = strtoul(devname, NULL, 0);
- filter.addr = strtoul(p + 1, NULL, 0);
- filter.vendor_id = 0;
- filter.product_id = 0;
- } else {
- p = strchr(devname, ':');
- if (p) {
- filter.bus_num = 0;
- filter.addr = 0;
- filter.vendor_id = strtoul(devname, NULL, 16);
- filter.product_id = strtoul(p + 1, NULL, 16);
- } else {
- goto fail;
- }
- }
+ goto out;
}
+ /* Check for <bus>-<port> specification. */
+ p = strchr(devname, '-');
+ if (p && p != devname) {
+ filter.bus_num = strtoul(devname, NULL, 0);
+ filter.port = p + 1;
+ goto out;
+ }
+
+ /* Check for <bus>.<addr> specification. */
+ p = strchr(devname, '.');
+ if (p) {
+ filter.bus_num = strtoul(devname, NULL, 0);
+ filter.addr = strtoul(p + 1, NULL, 0);
+ goto out;
+ }
+
+ /* Check for <vendorid>:<productid> specification. */
+ p = strchr(devname, ':');
+ if (p) {
+ filter.vendor_id = strtoul(devname, NULL, 16);
+ filter.product_id = strtoul(p + 1, NULL, 16);
+ goto out;
+ }
+
+ goto fail;
+
+out:
qdev_prop_set_uint32(&dev->qdev, "hostbus", filter.bus_num);
qdev_prop_set_uint32(&dev->qdev, "hostaddr", filter.addr);
+ if (filter.port) {
+ qdev_prop_set_string(&dev->qdev, "port", filter.port);
+ }
qdev_prop_set_uint32(&dev->qdev, "vendorid", filter.vendor_id);
qdev_prop_set_uint32(&dev->qdev, "productid", filter.product_id);
qdev_init_nofail(&dev->qdev);
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |