qemu qmp [info usb] and [info hostusb]
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?
best regards,
Pascal
Quoted 13 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Pascal Heinrich
Sent: Saturday, July 12, 2014 5:52 AM
To: [email protected]
Subject: [Qemu-devel] qemu qmp [info usb] and [info hostusb]Hi,
I am trying to implement a qtprogram to bind and unbind usb devices from an qemu instance.
Quoted 7 lines
Via
device_addI 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?
AFAICT, there is nothing batch interface like that, not just usb device, but pci or all other devices.
BTW, I don't think this kind of interface is a good idea. Because the error process logic is troubled, about failure and revert.
Best regards,
-Gonglei
Quoted 11 lines · Pascal Heinrich
Hi,
I am trying to implement a qtprogram to bind and unbind usb devices from an qemu instance.
Via
device_addI 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?
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 :)
Quoted 16 lines · Markus Armbruster
Quoted 11 lines · Pascal Heinrich
Hi,
I am trying to implement a qtprogram to bind and unbind usb devices from an qemu instance.
Via
device_addI 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?