From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X795d-0004Ad-7v for qemu-devel@nongnu.org; Tue, 15 Jul 2014 16:12:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X795W-0004cF-9r for qemu-devel@nongnu.org; Tue, 15 Jul 2014 16:12:41 -0400 Received: from mail-qc0-x230.google.com ([2607:f8b0:400d:c01::230]:60292) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X795W-0004cB-3n for qemu-devel@nongnu.org; Tue, 15 Jul 2014 16:12:34 -0400 Received: by mail-qc0-f176.google.com with SMTP id i17so2919932qcy.35 for ; Tue, 15 Jul 2014 13:12:33 -0700 (PDT) Message-ID: <53C58B2A.7050900@googlemail.com> Date: Tue, 15 Jul 2014 22:12:26 +0200 From: Pascal Heinrich MIME-Version: 1.0 References: <53C05C97.9070509@googlemail.com> <87mwccjtu4.fsf@blackfin.pond.sub.org> In-Reply-To: <87mwccjtu4.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="giNaA69j4p4ms3uaQUOprvo2iIal0mom9" Subject: Re: [Qemu-devel] qemu qmp [info usb] and [info hostusb] List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, =?ISO-8859-1?Q?Andreas_F=E4rber?= This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --giNaA69j4p4ms3uaQUOprvo2iIal0mom9 Content-Type: multipart/alternative; boundary="------------030707000008060109060000" This is a multi-part message in MIME format. --------------030707000008060109060000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable The only problem I have is to get already bind device id's so I can unbind them. I do not find a qmp command where the binded usb devices show up. With query-pci I do not get all devices. I implemented a new command "query-usb" and copied the logic from hw/usb/bus.c But it seems that the QTAILQ macros doesn't work is this context. #include "qemu-common.h" #include "sysemu/sysemu.h" #include "qmp-commands.h" #include "sysemu/char.h" #include "ui/qemu-spice.h" #include "ui/vnc.h" #include "sysemu/kvm.h" #include "sysemu/arch_init.h" #include "hw/qdev.h" #include "sysemu/blockdev.h" #include "qom/qom-qobject.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp-input-visitor.h" #include "hw/boards.h" #include "qom/object_interfaces.h" #include "hw/mem/pc-dimm.h" #include "hw/acpi/acpi_dev_interface.h" #include "include/hw/usb.h" static QTAILQ_HEAD(, USBBus) busses =3D QTAILQ_HEAD_INITIALIZER(busses); =2E.. UsbInfoList *qmp_query_usb(Error **errp) { UsbInfoList *infos =3D NULL; USBBus *bus; USBDevice *dev; USBPort *port; QTAILQ_FOREACH(bus, &busses, next) { QTAILQ_FOREACH(port, &bus->used, next) { dev =3D port->dev; if (!dev) continue; UsbInfoList *entry =3D g_malloc0(sizeof(*entry)); entry->value =3D g_malloc0(sizeof(UsbInfo)); entry->next =3D infos; infos =3D entry; entry->value->desc =3D g_strdup(dev->product_desc); entry->value->hostbus =3D bus->busnr; entry->value->hostaddr =3D dev->addr; entry->value->vendorID =3D 1; entry->value->productID =3D 1; // monitor_printf(mon, " Device %d.%d, Port %s, Speed %s Mb/s, Product %s\n", bus->busnr, dev->addr, port->path, usb_speed(dev->speed), dev->product_desc); } } return infos; } any ideas? thanks :) On 07/14/14 09:13, Markus Armbruster wrote: > Pascal Heinrich writes: > >> Hi, >> >> I am trying to implement a qtprogram to bind and unbind usb devices fr= om >> an qemu instance. >> >> Via device_add I am able to bind a device to the vm but there is no >> command in qmp to list binded devices or I do not find them. >> >> I am searching for something like >"query-usb"< >> >> Is there something implemented like that? > In the human monitor, there's "info qtree", but programs really should > use QMP. It provides qom-list and qom-get, but that's rather low level= =2E > Andreas, any further advice? --------------030707000008060109060000 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable The only problem I have is to get already bind device id's so I can unbind them.

I do not find a qmp command where the binded usb devices show up.
= With query-pci I do not get all devices.

I implemented a new command "query-usb" and copied the logic from hw/usb/bus.c

But it seems that the QTAILQ macros doesn't work is this context.
=
#include "qemu-common.h"
#include "sysemu/sysemu.h"
#include "qmp-commands.h"
#include "sysemu/char.h"
#include "ui/qemu-spice.h"
#include "ui/vnc.h"
#include "sysemu/kvm.h"
#include "sysemu/arch_init.h"
#include "hw/qdev.h"
#include "sysemu/blockdev.h"
#include "qom/qom-qobject.h"
#include "qapi/qmp/qobject.h"
#include "qapi/qmp-input-visitor.h"
#include "hw/boards.h"
#include "qom/object_interfaces.h"
#include "hw/mem/pc-dimm.h"
#include "hw/acpi/acpi_dev_interface.h"
#include "include/hw/usb.h"

static QTAILQ_HEAD(, USBBus) busses =3D QTAILQ_HEAD_INITIALIZER(busses);


...

UsbInfoList *qmp_query_usb(Error **errp)
{

    UsbInfoList *infos =3D NULL;
    USBBus *bus;
    USBDevice *dev;
    USBPort *port;

    QTAILQ_FOREACH(bus, &busses, next) {
        QTAILQ_FOREACH(port, &= amp;bus->used, next) {

           = ; dev =3D port->dev;
           = ; if (!dev)
           = ;     continue;

           = ; UsbInfoList *entry =3D g_malloc0(sizeof(*entry));

           = ; entry->value =3D g_malloc0(sizeof(UsbInfo));
           = ; entry->next =3D infos;
           = ; infos =3D entry;

           = ; entry->value->desc =3D g_strdup(dev->product_desc);
           = ; entry->value->hostbus =3D bus->busnr;
           = ; entry->value->hostaddr =3D dev->addr;
           = ; entry->value->vendorID =3D 1;
           = ; entry->value->productID =3D 1;

//          &nb= sp; monitor_printf(mon, "  Device %d.%d, Port %s, Speed %s Mb/s, Product %s\n", bus->busnr, dev->addr, port->path, usb_speed(dev->speed), dev->product_desc);
        }
    }

    return infos;

}


any ideas?

thanks :)

On 07/14/14 09:13, Markus Armbruster wrote:
Pascal Heinrich <pascalheinrich.de@goo=
glemail.com> writes:

Hi,

I am trying to implement a qtprogram to bind and unbind usb devices from
an qemu instance.

Via device_add I am able to bind a device to the vm but there is no
command in qmp to list binded devices or I do not find them.

I am searching for something like >"query-usb"<

Is there something implemented like that?
In the human monitor, there's "info qtree", but programs really should
use QMP.  It provides qom-list and qom-get, but that's rather low level.
Andreas, any further advice?
--------------030707000008060109060000-- --giNaA69j4p4ms3uaQUOprvo2iIal0mom9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCgAGBQJTxYsuAAoJEHuumw9gopMhIa0QAISrrRaDU2ibwUINBiz4nZwL 9rw9V0KzVm+wNIsSz8k8AhvEr+P20nP8ZosL4J/RO8slOu0U6Z3Tsxr7QpQ9eG94 5ZQHJweKQinzBRzT1uIJHY5wbEKOXbG38+pobHqwS2ZpaIuVIXG6A95bGqrFC4OT GHEOr2f1YdK3rG1EK/zkCzlEkxVhbGE98NtgIeF2AGyJzBP5pNZ0oqoQUzvUZ/nx bnrDYcVhxFabm/I4JrWa86055eQUoL153YzMtyB+/Mmd5TdE+GQOyn8L/z2L12Xd zJCJaIc25dF5xWeTH5vhOR0LL3T7JAbnQiXTylbNCkLjcyF8RwqCr5O4ll/JJq1U OuGDiPyCjmC2jr4OoUDlO6cm/qlpEXfhAXd8/SPMXVlzbo4MuxcIGVT23t/nsnyD JzsREhiZ2w/F3e+zN9y1ooclm9/iXmgKD2Wl2OLEqLzENnBaDRZzFybtUIJP8coY XcqDfikOp68VcmHeNJXzb4anpJv0Zqu3pcaLiDnf9z9JYwegDguCtRUQc3HqJcIu JavsrcYyLvNAFVNfRYAAKPstuRW5eFRD2eZnVmZqKKkE5/08LPiL53EuQUXCHYFP 00dDEIUtBnmMShd+tNGlK+8RFB/YFhE1FqMLrXbTnyCY3Mef6EceugLNlUJ7SvCL 4CCgxHpPWI8M1WBmcAm0 =UinF -----END PGP SIGNATURE----- --giNaA69j4p4ms3uaQUOprvo2iIal0mom9--