[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 4/4] xen: attach pvusb usb bus to backend qde
From: |
Stefano Stabellini |
Subject: |
Re: [Qemu-devel] [PATCH v2 4/4] xen: attach pvusb usb bus to backend qdev |
Date: |
Fri, 18 Nov 2016 20:34:29 -0800 (PST) |
User-agent: |
Alpine 2.10 (DEB 1266 2009-07-14) |
On Wed, 2 Nov 2016, Juergen Gross wrote:
> Attach the usb bus of a new pvusb controller to the qdev associated
> with the Xen backend. Any device connected to that controller can now
> specify the bus and port directly via its properties.
>
> Signed-off-by: Juergen Gross <address@hidden>
Reviewed-by: Stefano Stabellini <address@hidden>
> hw/usb/xen-usb.c | 23 ++++++++++-------------
> 1 file changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c
> index 1b3c2fb..8e676e6 100644
> --- a/hw/usb/xen-usb.c
> +++ b/hw/usb/xen-usb.c
> @@ -712,15 +712,10 @@ static void usbback_portid_detach(struct usbback_info
> *usbif, unsigned port)
>
> static void usbback_portid_remove(struct usbback_info *usbif, unsigned port)
> {
> - USBPort *p;
> -
> if (!usbif->ports[port - 1].dev) {
> return;
> }
>
> - p = &(usbif->ports[port - 1].port);
> - snprintf(p->path, sizeof(p->path), "%d", 99);
> -
> object_unparent(OBJECT(usbif->ports[port - 1].dev));
> usbif->ports[port - 1].dev = NULL;
> usbback_portid_detach(usbif, port);
> @@ -733,10 +728,10 @@ static void usbback_portid_add(struct usbback_info
> *usbif, unsigned port,
> {
> unsigned speed;
> char *portname;
> - USBPort *p;
> Error *local_err = NULL;
> QDict *qdict;
> QemuOpts *opts;
> + char *tmp;
>
> if (usbif->ports[port - 1].dev) {
> return;
> @@ -749,11 +744,16 @@ static void usbback_portid_add(struct usbback_info
> *usbif, unsigned port,
> return;
> }
> portname++;
> - p = &(usbif->ports[port - 1].port);
> - snprintf(p->path, sizeof(p->path), "%s", portname);
>
> qdict = qdict_new();
> qdict_put(qdict, "driver", qstring_from_str("usb-host"));
> + tmp = g_strdup_printf("%s.0", usbif->xendev.qdev.id);
> + qdict_put(qdict, "bus", qstring_from_str(tmp));
> + g_free(tmp);
> + tmp = g_strdup_printf("%s-%u", usbif->xendev.qdev.id, port);
> + qdict_put(qdict, "id", qstring_from_str(tmp));
> + g_free(tmp);
> + qdict_put(qdict, "port", qint_from_int(port));
> qdict_put(qdict, "hostbus", qint_from_int(atoi(busid)));
> qdict_put(qdict, "hostport", qstring_from_str(portname));
> opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_err);
> @@ -765,7 +765,6 @@ static void usbback_portid_add(struct usbback_info
> *usbif, unsigned port,
> goto err;
> }
> QDECREF(qdict);
> - snprintf(p->path, sizeof(p->path), "%d", port);
> speed = usbif->ports[port - 1].dev->speed;
> switch (speed) {
> case USB_SPEED_LOW:
> @@ -799,7 +798,6 @@ static void usbback_portid_add(struct usbback_info
> *usbif, unsigned port,
>
> err:
> QDECREF(qdict);
> - snprintf(p->path, sizeof(p->path), "%d", 99);
> xen_pv_printf(&usbif->xendev, 0, "device %s could not be opened\n",
> busid);
> }
>
> @@ -1012,13 +1010,13 @@ static void usbback_alloc(struct XenDevice *xendev)
>
> usbif = container_of(xendev, struct usbback_info, xendev);
>
> - usb_bus_new(&usbif->bus, sizeof(usbif->bus), &xen_usb_bus_ops,
> xen_sysdev);
> + usb_bus_new(&usbif->bus, sizeof(usbif->bus), &xen_usb_bus_ops,
> + DEVICE(&xendev->qdev));
> for (i = 0; i < USBBACK_MAXPORTS; i++) {
> p = &(usbif->ports[i].port);
> usb_register_port(&usbif->bus, p, usbif, i, &xen_usb_port_ops,
> USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL |
> USB_SPEED_MASK_HIGH);
> - snprintf(p->path, sizeof(p->path), "%d", 99);
> }
>
> QTAILQ_INIT(&usbif->req_free_q);
> @@ -1066,7 +1064,6 @@ static int usbback_free(struct XenDevice *xendev)
> }
>
> usb_bus_release(&usbif->bus);
> - object_unparent(OBJECT(&usbif->bus));
>
> TR_BUS(xendev, "finished\n");
>
> --
> 2.6.6
>
- [Qemu-devel] [PATCH v2 0/4] xed: add qdevs for each backend, correct pvUSB, Juergen Gross, 2016/11/02
- [Qemu-devel] [PATCH v2 3/4] xen: create qdev for each backend device, Juergen Gross, 2016/11/02
- [Qemu-devel] [PATCH v2 2/4] qdev: add function qdev_set_id(), Juergen Gross, 2016/11/02
- [Qemu-devel] [PATCH v2 1/4] xen: add an own bus for xen backend devices, Juergen Gross, 2016/11/02
- [Qemu-devel] [PATCH v2 4/4] xen: attach pvusb usb bus to backend qdev, Juergen Gross, 2016/11/02
- Re: [Qemu-devel] [PATCH v2 4/4] xen: attach pvusb usb bus to backend qdev,
Stefano Stabellini <=
- Re: [Qemu-devel] [PATCH v2 0/4] xed: add qdevs for each backend, correct pvUSB, Stefano Stabellini, 2016/11/21