From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Daniel P. Berrange" Subject: Re: [PATCH 2/2] xen: add qemu device for each pvusb backend Date: Tue, 27 Sep 2016 10:00:42 +0100 Message-ID: <20160927090042.GF3967@redhat.com> References: <1474893837-13010-1-git-send-email-jgross@suse.com> <1474893837-13010-3-git-send-email-jgross@suse.com> Reply-To: "Daniel P. Berrange" Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Return-path: Content-Disposition: inline In-Reply-To: <1474893837-13010-3-git-send-email-jgross@suse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: "Qemu-devel" To: Juergen Gross Cc: anthony.perard@citrix.com, xen-devel@lists.xensource.com, sstabellini@kernel.org, qemu-devel@nongnu.org, kraxel@redhat.com List-Id: xen-devel@lists.xenproject.org On Mon, Sep 26, 2016 at 02:43:57PM +0200, Juergen Gross wrote: > In order to be able to specify to which pvusb controller a new pvusb > device should be added we need a qemu device for each pvusb controller > with an associated id. > > Add such a device when a new controller is requested and attach the > usb bus of that controller to the new device. Any device connected to > that controller can now specify the bus and port directly via its > properties. > > Signed-off-by: Juergen Gross > --- > hw/usb/xen-usb.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++--------- > 1 file changed, 68 insertions(+), 13 deletions(-) > > @@ -733,10 +740,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[32]; > > if (usbif->ports[port - 1].dev) { > return; > @@ -749,11 +756,14 @@ 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")); > + snprintf(tmp, sizeof(tmp), "%s.0", usbif->id); Don't snprintf into fixed length buffers. g_strdup_printf() does the right thing > + qdict_put(qdict, "bus", qstring_from_str(tmp)); > + snprintf(tmp, sizeof(tmp), "%s-%u", usbif->id, port); > + qdict_put(qdict, "id", qstring_from_str(tmp)); Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|