qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] qemu qmp [info usb] and [info hostusb]


From: Pascal Heinrich
Subject: Re: [Qemu-devel] qemu qmp [info usb] and [info hostusb]
Date: Tue, 15 Jul 2014 22:12:26 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

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 = QTAILQ_HEAD_INITIALIZER(busses);


...

UsbInfoList *qmp_query_usb(Error **errp)
{

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

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

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

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

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

            entry->value->desc = g_strdup(dev->product_desc);
            entry->value->hostbus = bus->busnr;
            entry->value->hostaddr = dev->addr;
            entry->value->vendorID = 1;
            entry->value->productID = 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 <address@hidden> 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?

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]