Basic device state visualization
v3 cover Basic device state visualization
And here is v3. Dependencies remained, the changes are:
- disabled device_show for QMP use (due to protocol instability)
- reordered device tree path search: user-assigned ID comes last now
- added vmstate version-id to device_show output
- base64 cleanups according to review comments
- fixed an off-by-one in the qmp.py changes
Git url remained the same:
git://git.kiszka.org/qemu.git queues/device-show
Thanks again for the comments.
Jan Kiszka (17):
Add dependency of JSON unit tests on config-host.h
qdev: Fix scanning across single-bus devices
qdev: Allow device addressing via 'driver.instance'
qdev: Give qtree names precedence over user-assigned IDs
qdev: Convert device and bus lists to QTAILQ
qdev: Allow device specification by qtree path for device_del
qdev: Push QMP mode checks into qbus_list_bus/dev
monitor: Add completion for qdev paths
Add base64 encoder/decoder
QMP: Reserve namespace for complex object classes Add QBuffer
monitor: return length of printed string via monitor_[v]printf
monitor: Allow to exclude commands from QMP
monitor: Add basic device state visualization
QMP: Teach basic capability negotiation to python example
QMP: Fix python helper /wrt long return strings
QMP: Add support for buffer class to qmp python helper
Makefile | 5 +- Makefile.objs | 4 +- QMP/qmp-shell | 1 + QMP/qmp-spec.txt | 24 +++- QMP/qmp.py | 29 +++- QMP/vm-info | 1 + base64.c | 202 ++++++++++++++++++++++ base64.h | 19 ++ check-qbuffer.c | 172 +++++++++++++++++++ configure | 2 +- docs/qdev-device-use.txt | 20 ++- hw/acpi_piix4.c | 2 +- hw/hw.h | 2 + hw/i2c.c | 2 +- hw/pci-hotplug.c | 2 +- hw/qdev.c | 414 ++++++++++++++++++++++++++++++++++++++++----- hw/qdev.h | 12 +- hw/ssi.c | 6 +- monitor.c | 121 ++++++++++++-- monitor.h | 4 +- qbuffer.c | 116 +++++++++++++ qbuffer.h | 33 ++++ qemu-monitor.hx | 29 +++- qemu-tool.c | 6 +- qerror.c | 4 + qerror.h | 3 + qjson.c | 15 ++ qobject.h | 1 + 28 files changed, 1165 insertions(+), 86 deletions(-) create mode 100644 base64.c create mode 100644 base64.h create mode 100644 check-qbuffer.c create mode 100644 qbuffer.c create mode 100644 qbuffer.h
PATCH v3 2/17 qdev: Fix scanning across single-bus devices
From: Jan Kiszka <[email protected]>
As long as we allow /dev.1 as shortcut for /dev1/bus1, we also have to make sure that /dev1/dev2 works for /dev1/bus1/dev2/bus2 - as long as there is only one child bus per device.
--- docs/qdev-device-use.txt | 4 ++++ hw/qdev.c | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletions(-)
docs/qdev-device-use.txt +4 -0
@@ -20,6 +20,10 @@ bus named pci.0. To put a FOO device into its slot 4, use -device FOO,bus=/i440FX-pcihost/pci.0,addr=4. The abbreviated form bus=pci.0 also works as long as the bus name is unique. +Furthermore, if a device only hosts a single bus, the bus name can be +omitted in the path. Example: /i440FX-pcihost/PIIX3 abbreviates +/i440FX-pcihost/pci.0/PIIX3/isa.0 as none of the buses has siblings. + Note: the USB device address can't be controlled at this time. === Block Devices ===
hw/qdev.c +11 -1
@@ -557,7 +557,7 @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem)static BusState *qbus_find (const char *path) { -DeviceState *dev; +DeviceState *dev, *next_dev;BusState *bus;char elem[128 ];int pos, len;
@@ -603,6 +603,7 @@ static BusState *qbus_find(const char *path)return NULL ; } +search_dev_bus:assert (path[pos] =='/' || !path[pos]);while (path[pos] =='/' ) { pos++;
@@ -633,6 +634,15 @@ static BusState *qbus_find(const char *path) pos += len; bus =qbus_find_bus (dev, elem);if (!bus) { +if (dev->num_child_bus ==1 ) { +/* Last element might have been a short-cut to a device on +* the single child bus of the parent device. */ + next_dev =qbus_find_dev (QTAILQ_FIRST (&dev->child_bus), elem); +if (next_dev) { + dev = next_dev; + goto search_dev_bus; + } + }qerror_report (QERR_BUS_NOT_FOUND , elem);if (!monitor_cur_is_qmp ()) {qbus_list_bus (dev);
Signature · 1 line
1.6.0.2
PATCH v3 3/17 qdev: Allow device addressing via 'driver.instance'
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Extend qbus_find_dev to allow addressing of devices without an unique id via an optional per-bus instance number. The new formats are 'driver.instance' and 'alias.instance'.
--- docs/qdev-device-use.txt | 14 +++++++++++++- hw/qdev.c | 23 ++++++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-)
docs/qdev-device-use.txt +13 -1
@@ -1,6 +1,6 @@ = How to convert to -device & friends = -=== Specifying Bus and Address on Bus === +=== Specifying Bus, Address on Bus, and Devices === In qdev, each device has a parent bus. Some devices provide one or more buses for children. You can specify a device's parent bus with
@@ -24,6 +24,18 @@ Furthermore, if a device only hosts a single bus, the bus name can be omitted in the path. Example: /i440FX-pcihost/PIIX3 abbreviates /i440FX-pcihost/pci.0/PIIX3/isa.0 as none of the buses has siblings. +Existing devices can be addressed either via a unique ID if it was +assigned during creation or via the device tree path: + +/full_bus_address/driver_name[.instance_number] + or +abbreviated_bus_address/driver_name[.instance_number] + +The instance number is zero-based. + +Example: /i440FX-pcihost/pci.0/e1000.1 addresses the second e1000 +adapter on the bus 'pci.0'. + Note: the USB device address can't be controlled at this time. === Block Devices ===
hw/qdev.c +18 -5
@@ -527,28 +527,41 @@ static BusState *qbus_find_bus(DeviceState *dev, char *elem)return NULL ; } -static DeviceState *qbus_find_dev (BusState *bus,char *elem) +static DeviceState *qbus_find_dev (BusState *bus,const char *elem) {DeviceState *dev; +int instance, n; +char buf[128 ];/* * try to match in order: * (1) instance id, if present -* (2) driver name -* (3) driver alias, if present +* (2) driver name [.instance] +* (3) driver alias [.instance], if present */ QLIST_FOREACH(dev, &bus->children, sibling) {if (dev->id &&strcmp (dev->id, elem) ==0 ) {return dev; } } + +if (sscanf (elem,"%127[^.].%u" , buf, &instance) ==2 ) { + elem = buf; + }else { + instance =0 ; + } + + n =0 ; QLIST_FOREACH(dev, &bus->children, sibling) { -if (strcmp (dev->info->name, elem) ==0 ) { +if (strcmp (dev->info->name, elem) ==0 && n++ == instance) {return dev; } } + + n =0 ; QLIST_FOREACH(dev, &bus->children, sibling) { -if (dev->info->alias &&strcmp (dev->info->alias, elem) ==0 ) { +if (dev->info->alias &&strcmp (dev->info->alias, elem) ==0 && + n++ == instance) {return dev; } }
Signature · 1 line
1.6.0.2
PATCH v3 4/17 qdev: Give qtree names precedence over user-assigned IDs
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
As the user may specify ambiguous device IDs, let's search for their official names first before considering the user-supplied identifiers.
--- docs/qdev-device-use.txt | 4 +++- hw/qdev.c | 18 +++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-)
docs/qdev-device-use.txt +3 -1
@@ -25,7 +25,9 @@ omitted in the path. Example: /i440FX-pcihost/PIIX3 abbreviates /i440FX-pcihost/pci.0/PIIX3/isa.0 as none of the buses has siblings. Existing devices can be addressed either via a unique ID if it was -assigned during creation or via the device tree path: +assigned during creation or via the device tree path. In conflicts, +the latter has precedence. A device tree path has the following +structure: /full_bus_address/driver_name[.instance_number] or
hw/qdev.c +9 -9
@@ -535,16 +535,10 @@ static DeviceState *qbus_find_dev(BusState *bus, const char *elem)/* * try to match in order: -* (1) instance id, if present -* (2) driver name [.instance] -* (3) driver alias [.instance], if present +* (1) driver name [.instance] +* (2) driver alias [.instance], if present +* (3) instance id, if present */ - QLIST_FOREACH(dev, &bus->children, sibling) { -if (dev->id &&strcmp (dev->id, elem) ==0 ) { -return dev; - } - } -if (sscanf (elem,"%127[^.].%u" , buf, &instance) ==2 ) { elem = buf; }else {
@@ -565,6 +559,12 @@ static DeviceState *qbus_find_dev(BusState *bus, const char *elem)return dev; } } + + QLIST_FOREACH(dev, &bus->children, sibling) { +if (dev->id &&strcmp (dev->id, elem) ==0 ) { +return dev; + } + }return NULL ; }
Signature · 1 line
1.6.0.2
PATCH v3 6/17 qdev: Allow device specification by qtree path for device_del
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Allow to specify the device to be removed via device_del not only by ID but also by its full or abbreviated qtree path. For this purpose, qdev_find is introduced which combines walking the qtree with searching for device IDs if required.
--- hw/qdev.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ qemu-monitor.hx | 10 +++++----- 2 files changed, 48 insertions(+), 11 deletions(-)
hw/qdev.c +43 -6
@@ -469,7 +469,7 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name,return NULL ; } -static DeviceState *qdev_find_recursive (BusState *bus,const char *id) +static DeviceState *qdev_find_id_recursive (BusState *bus,const char *id) {DeviceState *dev, *ret;BusState *child;
@@ -478,7 +478,7 @@ static DeviceState *qdev_find_recursive(BusState *bus, const char *id)if (dev->id &&strcmp (dev->id, id) ==0 )return dev; QTAILQ_FOREACH(child, &dev->child_bus, sibling) { - ret =qdev_find_recursive (child, id); + ret =qdev_find_id_recursive (child, id);if (ret) {return ret; }
@@ -666,6 +666,43 @@ search_dev_bus: } } +static DeviceState *qdev_find (const char *path) +{ +const char *dev_name; +DeviceState *dev; +char *bus_path; +BusState *bus; + + dev_name =strrchr (path,'/' ); +if (!dev_name) { + bus = main_system_bus; + dev_name = path; + }else { + dev_name++; + bus_path =qemu_strdup (path); + bus_path[dev_name - path] =0 ; + + bus =qbus_find (bus_path); +qemu_free (bus_path); + +if (!bus) { +/* qbus_find already reported the error */ +return NULL ; + } + } + dev =qbus_find_dev (bus, dev_name); +if (!dev) { + dev =qdev_find_id_recursive (main_system_bus, path); +if (!dev) { +qerror_report (QERR_DEVICE_NOT_FOUND , dev_name); +if (!monitor_cur_is_qmp ()) { +qbus_list_dev (bus); + } + } + } +return dev; +} +void qbus_create_inplace (BusState *bus,BusInfo *info,DeviceState *parent,const char *name) {
@@ -824,12 +861,12 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)int do_device_del (Monitor *mon,const QDict *qdict,QObject **ret_data) { -const char *id =qdict_get_str (qdict,"id" ); +const char *path =qdict_get_str (qdict,"path" );DeviceState *dev; - dev =qdev_find_recursive (main_system_bus, id); -if (NULL == dev) { -qerror_report (QERR_DEVICE_NOT_FOUND , id); + dev =qdev_find (path); +if (!dev) { +qerror_report (QERR_DEVICE_NOT_FOUND , path);return -1 ; }return qdev_unplug (dev);
qemu-monitor.hx +5 -5
@@ -703,7 +703,7 @@ EQMP { .name = "device_del", - .args_type = "id:s", + .args_type = "path:s", .params = "device", .help = "remove device", .user_print = monitor_user_noop,
@@ -711,10 +711,10 @@ EQMP }, STEXI -@item device_del @var{id} +@item device_del @var{path} @findex device_del -Remove device @var{id}. +Remove device @var{path}. ETEXI SQMP device_del
@@ -724,11 +724,11 @@ Remove a device. Arguments: -- "id": the device's ID (json-string) +- "path": the device's qtree path or unique ID (json-string) Example: --> { "execute": "device_del", "arguments": { "id": "net1" } } +-> { "execute": "device_del", "arguments": { "path": "net1" } } <- { "return": {} } EQMP
Signature · 1 line
1.6.0.2
PATCH v3 1/17 Add dependency of JSON unit tests on config-host.h
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
--- Makefile | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Makefile +2 -0
@@ -144,6 +144,8 @@ qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(block-obj-y) $(qobj qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@," GEN $@") +check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o: $(GENERATED_HEADERS) + check-qint: check-qint.o qint.o qemu-malloc.o check-qstring: check-qstring.o qstring.o qemu-malloc.o check-qdict: check-qdict.o qdict.o qfloat.o qint.o qstring.o qbool.o qemu-malloc.o qlist.o
Signature · 1 line
1.6.0.2
PATCH v3 5/17 qdev: Convert device and bus lists to QTAILQ
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Cosmetic change to align the instance number assignment with bus ordering. The current ordering due to QLIST_INSERT_HEAD is a bit annoying when you dump the qtree or address devices via 'driver.instance'.
--- hw/acpi_piix4.c | 2 +- hw/i2c.c | 2 +- hw/pci-hotplug.c | 2 +- hw/qdev.c | 43 ++++++++++++++++++++++--------------------- hw/qdev.h | 8 ++++---- hw/ssi.c | 6 +++--- 6 files changed, 32 insertions(+), 31 deletions(-)
hw/acpi_piix4.c +1 -1
@@ -536,7 +536,7 @@ static void pciej_write(void *opaque, uint32_t addr, uint32_t val)PCIDevice *dev;int slot =ffs (val) -1 ; - QLIST_FOREACH_SAFE(qdev, &bus->children, sibling, next) { + QTAILQ_FOREACH_SAFE(qdev, &bus->children, sibling, next) { dev =DO_UPCAST (PCIDevice, qdev, qdev);if (PCI_SLOT (dev->devfn) == slot) {qdev_free (qdev);
hw/i2c.c +1 -1
@@ -84,7 +84,7 @@ int i2c_start_transfer(i2c_bus *bus, uint8_t address, int recv)DeviceState *qdev;i2c_slave *slave =NULL ; - QLIST_FOREACH(qdev, &bus->qbus.children, sibling) { + QTAILQ_FOREACH(qdev, &bus->qbus.children, sibling) {i2c_slave *candidate =I2C_SLAVE_FROM_QDEV (qdev);if (candidate->address == address) { slave = candidate;
hw/pci-hotplug.c +1 -1
@@ -77,7 +77,7 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,SCSIBus *scsibus;SCSIDevice *scsidev; - scsibus =DO_UPCAST (SCSIBus, qbus,QLIST_FIRST (&adapter->child_bus)); + scsibus =DO_UPCAST (SCSIBus, qbus,QTAILQ_FIRST (&adapter->child_bus));if (!scsibus ||strcmp (scsibus->qbus.info->name,"SCSI" ) !=0 ) {error_report ("Device is not a SCSI adapter" );return -1 ;
hw/qdev.c +22 -21
154 lines not on this page · raw message
hw/qdev.h +4 -4
@@ -41,9 +41,9 @@ struct DeviceState {qemu_irq *gpio_out;int num_gpio_in;qemu_irq *gpio_in; - QLIST_HEAD(, BusState) child_bus; + QTAILQ_HEAD(, BusState) child_bus;int num_child_bus; -QLIST_ENTRY (DeviceState) sibling; +QTAILQ_ENTRY (DeviceState) sibling;int instance_id_alias;int alias_required_for_version; };
@@ -62,8 +62,8 @@ struct BusState {const char *name;int allow_hotplug;int qdev_allocated; - QLIST_HEAD(, DeviceState) children; -QLIST_ENTRY (BusState) sibling; + QTAILQ_HEAD(, DeviceState) children; +QTAILQ_ENTRY (BusState) sibling; };struct Property {
hw/ssi.c +3 -3
@@ -25,8 +25,8 @@ static int ssi_slave_init(DeviceState *dev, DeviceInfo *base_info)SSIBus *bus; bus =FROM_QBUS (SSIBus,qdev_get_parent_bus (dev)); -if (QLIST_FIRST (&bus->qbus.children) != dev - ||QLIST_NEXT (dev, sibling) !=NULL ) { +if (QTAILQ_FIRST (&bus->qbus.children) != dev + ||QTAILQ_NEXT (dev, sibling) !=NULL ) {hw_error ("Too many devices on SSI bus" ); }
@@ -61,7 +61,7 @@ uint32_t ssi_transfer(SSIBus *bus, uint32_t val) {DeviceState *dev;SSISlave *slave; - dev =QLIST_FIRST (&bus->qbus.children); + dev =QTAILQ_FIRST (&bus->qbus.children);if (!dev) {return 0 ; }
Signature · 1 line
1.6.0.2
PATCH v3 9/17 Add base64 encoder/decoder
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Will be used by QBuffer.
--- Makefile.objs | 2 +- base64.c | 202 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ base64.h | 19 ++++++ 3 files changed, 222 insertions(+), 1 deletions(-) create mode 100644 base64.c create mode 100644 base64.h
Makefile.objs +1 -1
@@ -2,7 +2,7 @@ # QObject qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o -qobject-obj-y += qerror.o +qobject-obj-y += qerror.o base64.o ####################################################################### # block-obj-y is code used by both qemu system emulation and qemu-img
base64.c new file +202 -0
202 lines not on this page · raw message
base64.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Base64 encoder/decoder conforming to RFC 4648 +* (based on Mozilla's nsprpub/lib/libc/src/base64.c) +* +* Copyright (C) 2010 Siemens AG +* +* Authors: +* Jan Kiszka <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2.1 or later. +* See the COPYING.LIB file in the top-level directory. +* +*/ + +#include <inttypes.h> +#include <stddef.h> + +void base64_encode (const uint8_t *src,size_t srclen,char *dest); +int base64_decode (const char *src,size_t srclen,uint8_t *dest);
Signature · 1 line
1.6.0.2
PATCH v3 11/17 Add QBuffer
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This introduces a buffer object for use with QMP. As a buffer is not natively encodable in JSON, we encode it as a base64 string and encapsulate the result in the new QMP object class "buffer".
The first use case for this is pushing the content of buffers that are part of a device state into a qdict.
--- Makefile | 5 +- Makefile.objs | 2 +- QMP/qmp-spec.txt | 10 +++- check-qbuffer.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 2 +- qbuffer.c | 116 ++++++++++++++++++++++++++++++++++++ qbuffer.h | 33 ++++++++++ qjson.c | 15 +++++ qobject.h | 1 + 9 files changed, 351 insertions(+), 5 deletions(-) create mode 100644 check-qbuffer.c create mode 100644 qbuffer.c create mode 100644 qbuffer.h
Makefile +3 -2
@@ -144,14 +144,15 @@ qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(block-obj-y) $(qobj qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@," GEN $@") -check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o: $(GENERATED_HEADERS) +check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o check-qbuffer: $(GENERATED_HEADERS) check-qint: check-qint.o qint.o qemu-malloc.o check-qstring: check-qstring.o qstring.o qemu-malloc.o check-qdict: check-qdict.o qdict.o qfloat.o qint.o qstring.o qbool.o qemu-malloc.o qlist.o check-qlist: check-qlist.o qlist.o qint.o qemu-malloc.o check-qfloat: check-qfloat.o qfloat.o qemu-malloc.o -check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qjson.o json-streamer.o json-lexer.o json-parser.o qemu-malloc.o +check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qbuffer.o base64.o qjson.o json-streamer.o json-lexer.o json-parser.o qemu-malloc.o +check-qbuffer: check-qbuffer.o qbuffer.o base64.o qstring.o qemu-malloc.o clean: # avoid old build problems by removing potentially incorrect old files
Makefile.objs +1 -1
@@ -1,6 +1,6 @@ ####################################################################### # QObject -qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o +qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o qbuffer.o qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o qobject-obj-y += qerror.o base64.o
QMP/qmp-spec.txt +9 -1
@@ -153,7 +153,15 @@ JSON objects that contain the key-value pair '"__class__": json-string' are reserved for QMP-specific complex object classes that. QMP specifies which further keys each of these objects include and how they are encoded. -So far, no complex object class is specified. +2.6.1 Buffer class +------------------ + +This QMP object class allows to transport binary data. A buffer object +consists of the following keys: + +{ "__class__": "buffer", "data": json-string } + +The data string is base64 encoded according to RFC 4648. 3. QMP Examples ===============
check-qbuffer.c new file +172 -0
172 lines not on this page · raw message
configure +1 -1
@@ -2290,7 +2290,7 @@ if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then tools="qemu-nbd\$(EXESUF) $tools" if [ "$check_utests" = "yes" ]; then - tools="check-qint check-qstring check-qdict check-qlist $tools" + tools="check-qint check-qstring check-qdict check-qlist check-qbuffer $tools" tools="check-qfloat check-qjson $tools" fi fi
qbuffer.c new file +116 -0
116 lines not on this page · raw message
qbuffer.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* QBuffer Module +* +* Copyright (C) 2010 Siemens AG +* +* Authors: +* Jan Kiszka <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2.1 or later. +* See the COPYING.LIB file in the top-level directory. +* +*/ + +#ifndef QBUFFER_H +#define QBUFFER_H + +#include <stdint.h> +#include "qobject.h" +#include "qstring.h" + +typedef struct QBuffer { +QObject_HEAD ; +void *data; +size_t size; +}QBuffer ; + +QBuffer *qbuffer_from_data (const void *data,size_t size); +QBuffer *qbuffer_from_qstring (const QString *string); +const void *qbuffer_get_data (const QBuffer *qb); +size_t qbuffer_get_size (const QBuffer *qb); +QBuffer *qobject_to_qbuffer (const QObject *obj); + +#endif /* QBUFFER_H */
qjson.c +15 -0
@@ -19,7 +19,9 @@#include "qlist.h" #include "qbool.h" #include "qfloat.h" +#include "qbuffer.h" #include "qdict.h" +#include "base64.h" typedef struct JSONParsingState {
@@ -235,6 +237,19 @@ static void to_json(const QObject *obj, QString *str) }break ; } +case QTYPE_QBUFFER : { +QBuffer *val =qobject_to_qbuffer (obj); +size_t data_size =qbuffer_get_size (val); +size_t str_len = ((data_size +2 ) /3 ) *4 ; +char *buffer =qemu_malloc (str_len +1 ); + +base64_encode (qbuffer_get_data (val), data_size, buffer); +qstring_append (str,"{\"__class__\": \"buffer\", \"data\": \"" ); +qstring_append (str, buffer); +qstring_append (str,"\"}" ); +qemu_free (buffer); +break ; + }case QTYPE_QERROR :/* XXX: should QError be emitted? */ case QTYPE_NONE :
qobject.h +1 -0
@@ -44,6 +44,7 @@ typedef enum {QTYPE_QFLOAT ,QTYPE_QBOOL ,QTYPE_QERROR , +QTYPE_QBUFFER , } qtype_code;struct QObject ;
Signature · 1 line
1.6.0.2
PATCH v3 13/17 monitor: Allow to exclude commands from QMP
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Ported commands that are marked 'user_only' will not be considered for QMP monitor sessions. This allows to implement new commands that do not (yet) provide a sufficiently stable interface for QMP use (e.g. device_show).
--- monitor.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
monitor.c +10 -3
@@ -114,6 +114,7 @@ typedef struct mon_cmd_t { MonitorCompletion *cb, void *opaque); } mhandler;int async; +bool user_only; } mon_cmd_t;/* file descriptors passed via SCM_RIGHTS */
@@ -635,6 +636,11 @@ static int do_info(Monitor *mon, const QDict *qdict, QObject **ret_data) goto help; } +if (monitor_ctrl_mode (mon) && cmd->user_only) { +qerror_report (QERR_COMMAND_NOT_FOUND , item); +return -1 ; + } +if (monitor_handler_is_async (cmd)) {if (monitor_ctrl_mode (mon)) {qmp_async_info_handler (mon, cmd);
@@ -732,13 +738,14 @@ static void do_info_commands(Monitor *mon, QObject **ret_data) cmd_list =qlist_new ();for (cmd = mon_cmds; cmd->name !=NULL ; cmd++) { -if (monitor_handler_ported (cmd) && !compare_cmd (cmd->name,"info" )) { +if (monitor_handler_ported (cmd) && !cmd->user_only && + !compare_cmd (cmd->name,"info" )) {qlist_append_obj (cmd_list,get_cmd_dict (cmd->name)); } }for (cmd = info_cmds; cmd->name !=NULL ; cmd++) { -if (monitor_handler_ported (cmd)) { +if (monitor_handler_ported (cmd) && !cmd->user_only) {char buf[128 ];snprintf (buf,sizeof (buf),"query-%s" , cmd->name);qlist_append_obj (cmd_list,get_cmd_dict (buf));
@@ -4416,7 +4423,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) qobject_from_jsonf("{ 'item': %s }", info_item)); }else { cmd =monitor_find_command (cmd_name); -if (!cmd || !monitor_handler_ported (cmd)) { +if (!cmd || !monitor_handler_ported (cmd) || cmd->user_only) {qerror_report (QERR_COMMAND_NOT_FOUND , cmd_name); goto err_input; }
Signature · 1 line
1.6.0.2
PATCH v3 7/17 qdev: Push QMP mode checks into qbus_list_bus/dev
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Simplifies the usage.
--- hw/qdev.c | 22 ++++++++++------------ 1 files changed, 10 insertions(+), 12 deletions(-)
hw/qdev.c +10 -12
@@ -492,6 +492,9 @@ static void qbus_list_bus(DeviceState *dev)BusState *child;const char *sep =" " ; +if (monitor_cur_is_qmp ()) { +return ; + }error_printf ("child busses at \"%s\":" , dev->id ? dev->id : dev->info->name); QTAILQ_FOREACH(child, &dev->child_bus, sibling) {
@@ -506,6 +509,9 @@ static void qbus_list_dev(BusState *bus)DeviceState *dev;const char *sep =" " ; +if (monitor_cur_is_qmp ()) { +return ; + }error_printf ("devices at \"%s\":" , bus->name); QTAILQ_FOREACH(dev, &bus->children, sibling) {error_printf ("%s\"%s\"" , sep, dev->info->name);
@@ -611,9 +617,7 @@ static BusState *qbus_find(const char *path) dev =qbus_find_dev (bus, elem);if (!dev) {qerror_report (QERR_DEVICE_NOT_FOUND , elem); -if (!monitor_cur_is_qmp ()) { -qbus_list_dev (bus); - } +qbus_list_dev (bus);return NULL ; }
@@ -633,9 +637,7 @@ search_dev_bus:return QTAILQ_FIRST (&dev->child_bus);default :qerror_report (QERR_DEVICE_MULTIPLE_BUSSES , elem); -if (!monitor_cur_is_qmp ()) { -qbus_list_bus (dev); - } +qbus_list_bus (dev);return NULL ; } }
@@ -658,9 +660,7 @@ search_dev_bus: } }qerror_report (QERR_BUS_NOT_FOUND , elem); -if (!monitor_cur_is_qmp ()) { -qbus_list_bus (dev); - } +qbus_list_bus (dev);return NULL ; } }
@@ -695,9 +695,7 @@ static DeviceState *qdev_find(const char *path) dev =qdev_find_id_recursive (main_system_bus, path);if (!dev) {qerror_report (QERR_DEVICE_NOT_FOUND , dev_name); -if (!monitor_cur_is_qmp ()) { -qbus_list_dev (bus); - } +qbus_list_dev (bus); } }return dev;
Signature · 1 line
1.6.0.2
PATCH v3 8/17 monitor: Add completion for qdev paths
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Implement monitor command line completion for device tree paths. The first user is device_del.
--- hw/qdev.c | 50 ++++++++++++++++++++++---------- hw/qdev.h | 2 + monitor.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-monitor.hx | 2 +- 4 files changed, 123 insertions(+), 16 deletions(-)
hw/qdev.c +35 -15
@@ -39,7 +39,7 @@ DeviceInfo *device_info_list;static BusState *qbus_find_recursive (BusState *bus,const char *name,const BusInfo *info); -static BusState *qbus_find (const char *path); +static BusState *qbus_find_internal (const char *path,bool report_errors);/* Register a new device type. */ void qdev_register (DeviceInfo *info)
@@ -217,7 +217,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)/* find bus */ path =qemu_opt_get (opts,"bus" );if (path !=NULL ) { - bus =qbus_find (path); + bus =qbus_find_internal (path, true);if (!bus) {return NULL ; }
@@ -575,7 +575,7 @@ static DeviceState *qbus_find_dev(BusState *bus, const char *elem)return NULL ; } -static BusState *qbus_find (const char *path) +static BusState *qbus_find_internal (const char *path,bool report_errors) {DeviceState *dev, *next_dev;BusState *bus;
@@ -593,7 +593,9 @@ static BusState *qbus_find(const char *path) } bus =qbus_find_recursive (main_system_bus, elem,NULL );if (!bus) { -qerror_report (QERR_BUS_NOT_FOUND , elem); +if (report_errors) { +qerror_report (QERR_BUS_NOT_FOUND , elem); + }return NULL ; } pos = len;
@@ -616,8 +618,10 @@ static BusState *qbus_find(const char *path) pos += len; dev =qbus_find_dev (bus, elem);if (!dev) { -qerror_report (QERR_DEVICE_NOT_FOUND , elem); -qbus_list_dev (bus); +if (report_errors) { +qerror_report (QERR_DEVICE_NOT_FOUND , elem); +qbus_list_dev (bus); + }return NULL ; }
@@ -631,13 +635,17 @@ search_dev_bus:* one child bus accept it nevertheless */ switch (dev->num_child_bus) {case 0 : -qerror_report (QERR_DEVICE_NO_BUS , elem); +if (report_errors) { +qerror_report (QERR_DEVICE_NO_BUS , elem); + }return NULL ;case 1 :return QTAILQ_FIRST (&dev->child_bus);default : -qerror_report (QERR_DEVICE_MULTIPLE_BUSSES , elem); -qbus_list_bus (dev); +if (report_errors) { +qerror_report (QERR_DEVICE_MULTIPLE_BUSSES , elem); +qbus_list_bus (dev); + }return NULL ; } }
@@ -659,14 +667,21 @@ search_dev_bus: goto search_dev_bus; } } -qerror_report (QERR_BUS_NOT_FOUND , elem); -qbus_list_bus (dev); +if (report_errors) { +qerror_report (QERR_BUS_NOT_FOUND , elem); +qbus_list_bus (dev); + }return NULL ; } } } -static DeviceState *qdev_find (const char *path) +BusState *qbus_find (const char *path) +{ +return qbus_find_internal (path, false); +} + +static DeviceState *qdev_find_internal (const char *path,bool report_errors) {const char *dev_name;DeviceState *dev;
@@ -682,7 +697,7 @@ static DeviceState *qdev_find(const char *path) bus_path =qemu_strdup (path); bus_path[dev_name - path] =0 ; - bus =qbus_find (bus_path); + bus =qbus_find_internal (bus_path, report_errors);qemu_free (bus_path);if (!bus) {
@@ -693,7 +708,7 @@ static DeviceState *qdev_find(const char *path) dev =qbus_find_dev (bus, dev_name);if (!dev) { dev =qdev_find_id_recursive (main_system_bus, path); -if (!dev) { +if (!dev && report_errors) {qerror_report (QERR_DEVICE_NOT_FOUND , dev_name);qbus_list_dev (bus); }
@@ -701,6 +716,11 @@ static DeviceState *qdev_find(const char *path)return dev; } +DeviceState *qdev_find (const char *path) +{ +return qdev_find_internal (path, false); +} +void qbus_create_inplace (BusState *bus,BusInfo *info,DeviceState *parent,const char *name) {
@@ -862,7 +882,7 @@ int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data)const char *path =qdict_get_str (qdict,"path" );DeviceState *dev; - dev =qdev_find (path); + dev =qdev_find_internal (path, true);if (!dev) {qerror_report (QERR_DEVICE_NOT_FOUND , path);return -1 ;
hw/qdev.h +2 -0
@@ -165,6 +165,7 @@ void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);CharDriverState *qdev_init_chardev (DeviceState *dev);BusState *qdev_get_parent_bus (DeviceState *dev); +DeviceState *qdev_find (const char *path);/*** BUS API. ***/
@@ -172,6 +173,7 @@ void qbus_create_inplace(BusState *bus, BusInfo *info, DeviceState *parent, const char *name);BusState *qbus_create (BusInfo *info,DeviceState *parent,const char *name);void qbus_free (BusState *bus); +BusState *qbus_find (const char *path);#define FROM_QBUS (type, dev) DO_UPCAST(type, qbus, dev)
monitor.c +85 -0
121 lines not on this page · raw message
qemu-monitor.hx +1 -1
@@ -703,7 +703,7 @@ EQMP { .name = "device_del", - .args_type = "path:s", + .args_type = "path:Q", .params = "device", .help = "remove device", .user_print = monitor_user_noop,
Signature · 1 line
1.6.0.2
PATCH v3 10/17 QMP: Reserve namespace for complex object classes
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This reserves JSON objects that contain the key '__class__' for QMP-specific complex objects. First user will be the buffer class.
--- QMP/qmp-spec.txt | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)
QMP/qmp-spec.txt +13 -3
@@ -146,6 +146,15 @@ The format is: For a listing of supported asynchronous events, please, refer to the qmp-events.txt file. +2.6 Complex object classes +-------------------------- + +JSON objects that contain the key-value pair '"__class__": json-string' are +reserved for QMP-specific complex object classes that. QMP specifies which +further keys each of these objects include and how they are encoded. + +So far, no complex object class is specified. + 3. QMP Examples ===============
@@ -229,9 +238,10 @@ avoid modifying QMP. Both upstream and downstream need to take care to preserve long-term compatibility and interoperability. To help with that, QMP reserves JSON object member names beginning with -'__' (double underscore) for downstream use ("downstream names"). This -means upstream will never use any downstream names for its commands, -arguments, errors, asynchronous events, and so forth. +'__' (double underscore) for downstream use ("downstream names"). Downstream +names MUST NOT end with '__' as this pattern is reserved for QMP-defined JSON +object classes. Upstream will never use any downstream names for its +commands, arguments, errors, asynchronous events, and so forth. Any new names downstream wishes to add must begin with '__'. To ensure compatibility with other downstreams, it is strongly
Signature · 1 line
1.6.0.2
PATCH v3 15/17 QMP: Teach basic capability negotiation to python example
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
As sending "qmp_capabilities" on session start became mandatory, both python examples were broken.
--- QMP/qmp-shell | 1 + QMP/vm-info | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
QMP/qmp-shell +1 -0
@@ -42,6 +42,7 @@ def main(): qemu = qmp.QEMUMonitorProtocol(argv[1]) qemu.connect() + qemu.send("qmp_capabilities") print 'Connected!'
QMP/vm-info +1 -0
@@ -24,6 +24,7 @@ def main(): qemu = qmp.QEMUMonitorProtocol(argv[1]) qemu.connect() + qemu.send("qmp_capabilities") for cmd in [ 'version', 'hpet', 'kvm', 'status', 'uuid', 'balloon' ]: print cmd + ': ' + str(qemu.send('query-' + cmd))
Signature · 1 line
1.6.0.2
PATCH v3 12/17 monitor: return length of printed string via monitor_[v]printf
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This simply forwards the result of the internal vsnprintf to the callers of monitor_printf and monitor_vprintf. When invoked over a QMP session or in absence of an active monitor, -1 is returned.
--- monitor.c | 23 +++++++++++++++-------- monitor.h | 4 ++-- qemu-tool.c | 6 ++++-- 3 files changed, 21 insertions(+), 12 deletions(-)
monitor.c +15 -8
@@ -258,29 +258,36 @@ static void monitor_puts(Monitor *mon, const char *str) } } -void monitor_vprintf (Monitor *mon,const char *fmt,va_list ap) +int monitor_vprintf (Monitor *mon,const char *fmt,va_list ap) {char buf[4096 ]; +int ret; -if (!mon) -return ; - +if (!mon) { +return -1 ; + }mon_print_count_inc (mon);if (monitor_ctrl_mode (mon)) { -return ; +return -1 ; } -vsnprintf (buf,sizeof (buf), fmt, ap); + ret =vsnprintf (buf,sizeof (buf), fmt, ap);monitor_puts (mon, buf); + +return ret; } -void monitor_printf (Monitor *mon,const char *fmt, ...) +int monitor_printf (Monitor *mon,const char *fmt, ...) {va_list ap; +int ret; +va_start (ap, fmt); -monitor_vprintf (mon, fmt, ap); + ret =monitor_vprintf (mon, fmt, ap);va_end (ap); + +return ret; }void monitor_print_filename (Monitor *mon,const char *filename)
monitor.h +2 -2
@@ -45,8 +45,8 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,int monitor_get_fd (Monitor *mon,const char *fdname); -void monitor_vprintf (Monitor *mon,const char *fmt,va_list ap); -void monitor_printf (Monitor *mon,const char *fmt, ...) +int monitor_vprintf (Monitor *mon,const char *fmt,va_list ap); +int monitor_printf (Monitor *mon,const char *fmt, ...) __attribute__ ((__format__ (__printf__,2 ,3 )));void monitor_print_filename (Monitor *mon,const char *filename);void monitor_flush (Monitor *mon);
qemu-tool.c +4 -2
@@ -43,12 +43,14 @@ void monitor_set_error(Monitor *mon, QError *qerror) { } -void monitor_vprintf (Monitor *mon,const char *fmt,va_list ap) +int monitor_vprintf (Monitor *mon,const char *fmt,va_list ap) { +return -1 ; } -void monitor_printf (Monitor *mon,const char *fmt, ...) +int monitor_printf (Monitor *mon,const char *fmt, ...) { +return -1 ; }void monitor_print_filename (Monitor *mon,const char *filename)
Signature · 1 line
1.6.0.2
PATCH v3 16/17 QMP: Fix python helper /wrt long return strings
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Remove the arbitrary limitation of 1024 characters per return string and read complete lines instead. Required for device_show.
--- QMP/qmp.py | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
QMP/qmp.py +5 -1
@@ -63,10 +63,14 @@ class QEMUMonitorProtocol: def __json_read(self): try: - return json.loads(self.sock.recv(1024)) + while True: + line = json.loads(self.sockfile.readline()) + if not 'event' in line: + return line except ValueError: return def __init__(self, filename): self.filename = filename self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + self.sockfile = self.sock.makefile()
Signature · 1 line
1.6.0.2
PATCH v3 14/17 monitor: Add basic device state visualization
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This introduces device_show, a monitor command that saves the vmstate of a qdev device and visualizes it. Buffers are cut after 16 byte by default, but the full content can be requested via '-f'. To pretty-print sub-arrays, vmstate is extended to store the start index name. A new qerror is introduced to signal a missing vmstate. QMP is not supported as we cannot provide a stable interface, at least at this point.
--- hw/hw.h | 2 + hw/qdev.c | 243 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 2 + qemu-monitor.hx | 19 +++++ qerror.c | 4 + qerror.h | 3 + 6 files changed, 273 insertions(+), 0 deletions(-)
hw/hw.h +2 -0
@@ -299,6 +299,7 @@ enum VMStateFlags { typedef struct { const char *name; + const char *start_index; size_t offset; size_t size; size_t start;
@@ -413,6 +414,7 @@ extern const VMStateInfo vmstate_info_unused_buffer; .size = sizeof(_type), \ .flags = VMS_ARRAY, \ .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \ + .start_index = (stringify(_start)), \ }#define VMSTATE_VARRAY_INT32 (_field, _state, _field_num, _version, _info, _type) {\
hw/qdev.c +243 -0
252 lines not on this page · raw message
hw/qdev.h +2 -0
@@ -183,6 +183,8 @@ void do_info_qtree(Monitor *mon);void do_info_qdm (Monitor *mon);int do_device_add (Monitor *mon,const QDict *qdict,QObject **ret_data);int do_device_del (Monitor *mon,const QDict *qdict,QObject **ret_data); +void device_user_print (Monitor *mon,const QObject *data); +int do_device_show (Monitor *mon,const QDict *qdict,QObject **ret_data);/*** qdev-properties.c ***/
qemu-monitor.hx +19 -0
@@ -734,6 +734,25 @@ Example: EQMP { + .name = "device_show", + .args_type = "path:Q,full:-f", + .params = "device [-f]", + .help = "show device state (specify -f for full buffer dumping)", + .user_print = device_user_print, + .mhandler.cmd_new = do_device_show, + .user_only = true, + }, + +STEXI +@item device_show @var{path} [@code{-f}] + +Show state of device @var{path} in a human-readable form. @var{path} can be +an unique id specified during device creation or a full path in the device +tree (see @code{info qtree}). Buffers are cut after 16 bytes unless a full +dump is requested via @code{-f}. +ETEXI + + { .name = "cpu", .args_type = "index:i", .params = "index",
qerror.c +4 -0
@@ -101,6 +101,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Device '%(device)' has no child bus", }, { + .error_fmt = QERR_DEVICE_NO_STATE, + .desc = "No state available for device '%(device)'", + }, + { .error_fmt = QERR_DUPLICATE_ID, .desc = "Duplicate ID '%(id)' for %(object)", },
qerror.h +3 -0
@@ -91,6 +91,9 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_DEVICE_NO_BUS \ "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }" +#define QERR_DEVICE_NO_STATE \ + "{ 'class': 'DeviceNoState', 'data': { 'device': %s } }" +#define QERR_DUPLICATE_ID \ "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
Signature · 1 line
1.6.0.2
PATCH v3 17/17 QMP: Add support for buffer class to qmp python helper
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This demonstrates the conversion of QMP buffer objects and does some minimalistic pretty-printing.
--- QMP/qmp.py | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-)
QMP/qmp.py +23 -2
@@ -8,7 +8,7 @@ # This work is licensed under the terms of the GNU GPL, version 2. See # the COPYING file in the top-level directory. -import socket, json +import socket, json, binascii class QMPError(Exception): pass
@@ -16,6 +16,18 @@ class QMPError(Exception): class QMPConnectError(QMPError): pass +class QMPBuffer: + def __init__(self, data): + self.data = binascii.a2b_base64(data) + + def __repr__(self): + str = '' + for i in range(0, len(self.data)): + if i > 0: + str += ' ' + str += binascii.b2a_hex(self.data[i]) + return str + class QEMUMonitorProtocol: def connect(self): self.sock.connect(self.filename)
@@ -61,10 +73,19 @@ class QEMUMonitorProtocol: # the Server won't read our input self.sock.send(json.dumps(cmd) + ' ') + def __json_obj_hook(self, dct): + if '__class__' in dct: + if dct['__class__'] == 'buffer': + return QMPBuffer(dct['data']) + else: + return + return dct + def __json_read(self): try: while True: - line = json.loads(self.sockfile.readline()) + line = json.loads(self.sockfile.readline(), + object_hook=self.__json_obj_hook) if not 'event' in line: return line except ValueError:
Signature · 1 line
1.6.0.2
[Qemu-devel] Re: [PATCH v3 06/17] qdev: Allow device specification by qtree path for device_del
In reply to Jan KiszkaQuoted 6 lines · On Sun, 23 May 2010 12:59:19 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Allow to specify the device to be removed via
device_delnot only by ID but also by its full or abbreviated qtree path. For this purpose,qdev_findis introduced which combines walking the qtree with searching for device IDs if required.
[...]
Quoted 9 lines
Arguments:
-- "id": the device's ID (json-string)
+- "path": the device's qtree path or unique ID (json-string)Example:
--> { "execute": "
device_del", "arguments": { "id": "net1" } } +-> { "execute": "device_del", "arguments": { "path": "net1" } }
Doesn't seem like a good change to me, besides being incompatible[1] we
shouldn't overload arguments this way in QMP as overloading leads to interface degradation (harder to use, understand, maintain).
Maybe we could have both arguments as optional, but one must be passed.
[1] It's 'legal' to break the protocol before 0.13, but this has to be coordinated with libvirt so we should have a good reason to do this
Quoted 3 lines
<- { "return": {} }
EQMP
[Qemu-devel] Re: [PATCH v3 10/17] QMP: Reserve namespace for complex object classes
In reply to Jan KiszkaQuoted 15 lines · On Sun, 23 May 2010 12:59:23 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
This reserves JSON objects that contain the key '
__class__' for QMP-specific complex objects. First user will be the buffer class.Signed-off-by Jan Kiszka <[email protected]>--- QMP/qmp-spec.txt | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)QMP/qmp-spec.txt +0
-0
QMP/qmp-spec.txt The format is: · line 152
Quoted 7 lines
QMP/qmp-spec.txt +4
-0@@ -146,6 +146,15 @@ The format is: For a listing of supported asynchronous events, please, refer to the qmp-events.txt file. +2.6 Complex object classes +-------------------------- + +JSON objects that contain the key-value pair '"__class__": json-string' are
I'm not strong about this, but it's better to call it just a 'pair', as 'value'
is a bit problematic because of json-value.
QMP/qmp-spec.txt The format is: · line 153
Quoted 1 line
QMP/qmp-spec.txt +1
-0+reserved for QMP-specific complex object classes that. QMP specifies which
Early full stop?
Quoted 8 lines
QMP/qmp-spec.txt +4
-0+further keys each of these objects include and how they are encoded. + +So far, no complex object class is specified. + 3. QMP Examples ===============
QMP/qmp-spec.txt avoid modifying QMP. Both upstream and downstream need to take care to · line 244
Quoted 10 lines
QMP/qmp-spec.txt +4
-3@@ -229,9 +238,10 @@ avoid modifying QMP. Both upstream and downstream need to take care to preserve long-term compatibility and interoperability. To help with that, QMP reserves JSON object member names beginning with -'__' (double underscore) for downstream use ("downstream names"). This -means upstream will never use any downstream names for its commands, -arguments, errors, asynchronous events, and so forth. +'__' (double underscore) for downstream use ("downstream names"). Downstream +names MUST NOT end with '__' as this pattern is reserved for QMP-defined JSON +object classes. Upstream will never use any downstream names for its +commands, arguments, errors, asynchronous events, and so forth.
Suggest mentioning subsection 2.6.
Quoted 3 lines
QMP/qmp-spec.txt +0
-0Any new names downstream wishes to add must begin with '__'. To ensure compatibility with other downstreams, it is strongly
[Qemu-devel] Re: [PATCH v3 13/17] monitor: Allow to exclude commands from QMP
In reply to Jan KiszkaQuoted 6 lines · On Sun, 23 May 2010 12:59:26 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Ported commands that are marked '
user_only' will not be considered for QMP monitor sessions. This allows to implement new commands that do not (yet) provide a sufficiently stable interface for QMP use (e.g.device_show).
This is fine for me, but two things I've been wondering:
1. Isn't a 'flags' struct member better? So that we can do (in the qemu-monitor.hx entry):
.flags = MONITOR_USER_ONLY | MONITOR_HANDLER_ASYNC,
I'm not suggesting this is an async handler, just exemplifying multiple flags.
2. Getting QMP handlers right in the first time might be difficult, so we could have a way to mark them unstable. Maybe a different namespace which is only enabled at configure time with:
--enable-qmp-unstable-commands
If this were possible, we could have device_show and any command we aren't sure is QMP-ready working in QMP this way.
Quoted 56 lines
Signed-off-by Jan Kiszka <[email protected]>--- monitor.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)monitor.c +10
-3@@ -114,6 +114,7 @@ typedef struct mon_cmd_t { MonitorCompletion *cb, void *opaque); } mhandler;int async; +bool user_only; } mon_cmd_t;/* file descriptors passed via SCM_RIGHTS */ @@ -635,6 +636,11 @@ static int do_info(Monitor *mon, const QDict *qdict, QObject **ret_data) goto help; } +if (monitor_ctrl_mode (mon) && cmd->user_only) { +qerror_report (QERR_COMMAND_NOT_FOUND , item); +return -1 ; + } +if (monitor_handler_is_async (cmd)) {if (monitor_ctrl_mode (mon)) {qmp_async_info_handler (mon, cmd);@@ -732,13 +738,14 @@ static void do_info_commands(Monitor *mon, QObject **ret_data) cmd_list =qlist_new ();for (cmd = mon_cmds; cmd->name !=NULL ; cmd++) { -if (monitor_handler_ported (cmd) && !compare_cmd (cmd->name,"info" )) { +if (monitor_handler_ported (cmd) && !cmd->user_only && + !compare_cmd (cmd->name,"info" )) {qlist_append_obj (cmd_list,get_cmd_dict (cmd->name)); } }for (cmd = info_cmds; cmd->name !=NULL ; cmd++) { -if (monitor_handler_ported (cmd)) { +if (monitor_handler_ported (cmd) && !cmd->user_only) {char buf[128 ];snprintf (buf,sizeof (buf),"query-%s" , cmd->name);qlist_append_obj (cmd_list,get_cmd_dict (buf));@@ -4416,7 +4423,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) qobject_from_jsonf("{ 'item': %s }", info_item)); }else { cmd =monitor_find_command (cmd_name); -if (!cmd || !monitor_handler_ported (cmd)) { +if (!cmd || !monitor_handler_ported (cmd) || cmd->user_only) {qerror_report (QERR_COMMAND_NOT_FOUND , cmd_name); goto err_input; }
[Qemu-devel] Re: [PATCH v3 16/17] QMP: Fix python helper /wrt long return strings
In reply to Jan KiszkaQuoted 4 lines · On Sun, 23 May 2010 12:59:29 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Remove the arbitrary limitation of 1024 characters per return string and read complete lines instead. Required for
device_show.
Thanks for both fixes, I have started working on a better version of this
script that mimics better the user monitor but it's only half done.
Quoted 26 lines
Signed-off-by Jan Kiszka <[email protected]>--- QMP/qmp.py | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)QMP/qmp.py +5
-1@@ -63,10 +63,14 @@ class QEMUMonitorProtocol: def __json_read(self): try: - return json.loads(self.sock.recv(1024)) + while True: + line = json.loads(self.sockfile.readline()) + if not 'event' in line: + return line except ValueError: return def __init__(self, filename): self.filename = filename self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + self.sockfile = self.sock.makefile()
[Qemu-devel] Re: [PATCH v3 13/17] monitor: Allow to exclude commands from QMP
In reply to Luiz CapitulinoQuoted 12 lines · Luiz Capitulino
Quoted 6 lines · On Sun, 23 May 2010 12:59:26 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Ported commands that are marked '
user_only' will not be considered for QMP monitor sessions. This allows to implement new commands that do not (yet) provide a sufficiently stable interface for QMP use (e.g.device_show).This is fine for me, but two things I've been wondering:
Quoted 7 lines
1. Isn't a 'flags' struct member better? So that we can do (in the qemu-monitor.hx entry):
.flags =
MONITOR_USER_ONLY|MONITOR_HANDLER_ASYNC,I'm not suggesting this is an async handler, just exemplifying multiple flags.
Yes, can refactor this.
Quoted 9 lines
2. Getting QMP handlers right in the first time might be difficult, so we could have a way to mark them unstable. Maybe a different namespace which is only enabled at configure time with:
--enable-qmp-unstable-commands
If this were possible, we could have
device_showand any command we aren't sure is QMP-ready working in QMP this way.
Do you suggest this as an alternative to this patch? Or an extension later on? I have no opinion on this yet, I would just like to know how to proceed for this series.
Jan
[Qemu-devel] Re: [PATCH v3 06/17] qdev: Allow device specification by qtree path for device_del
In reply to Luiz CapitulinoQuoted 17 lines · Luiz Capitulino
Quoted 6 lines · On Sun, 23 May 2010 12:59:19 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Allow to specify the device to be removed via
device_delnot only by ID but also by its full or abbreviated qtree path. For this purpose,qdev_findis introduced which combines walking the qtree with searching for device IDs if required.[...]
Quoted 5 lines
Arguments:
-- "id": the device's ID (json-string)
+- "path": the device's qtree path or unique ID (json-string)
Quoted 8 lines
Quoted 4 lines
Example:
--> { "execute": "
device_del", "arguments": { "id": "net1" } } +-> { "execute": "device_del", "arguments": { "path": "net1" } }Doesn't seem like a good change to me, besides being incompatible[1] we
shouldn't overload arguments this way in QMP as overloading leads to interface degradation (harder to use, understand, maintain).
It's not overloaded, think of an ID as a (weak) symbolic link in the qtree filesystem. The advantage of basing everything on top of full or abbreviated qtree paths is that IDs are not always assigned, paths are.
Quoted 2 lines
Maybe we could have both arguments as optional, but one must be passed.
This would at least require some way to keep the proposed unified path specification for the human monitor (having separate arguments there is really unhandy).
Quoted 8 lines
[1] It's 'legal' to break the protocol before 0.13, but this has to be coordinated with libvirt so we should have a good reason to do this
Quoted 3 lines
<- { "return": {} }
EQMP
Jan
[Qemu-devel] Re: [PATCH v3 10/17] QMP: Reserve namespace for complex object classes
In reply to Luiz CapitulinoQuoted 21 lines · Luiz Capitulino
Quoted 18 lines · On Sun, 23 May 2010 12:59:23 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
This reserves JSON objects that contain the key '
__class__' for QMP-specific complex objects. First user will be the buffer class.Signed-off-by Jan Kiszka <[email protected]>--- QMP/qmp-spec.txt | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)QMP/qmp-spec.txt +0
-0@@ -146,6 +146,15 @@ The format is: For a listing of supported asynchronous events, please, refer to the qmp-events.txt file.
Quoted 7 lines
QMP/qmp-spec.txt The format is: · line 152
Quoted 4 lines
QMP/qmp-spec.txt +4
-0+2.6 Complex object classes +-------------------------- + +JSON objects that contain the key-value pair '"__class__": json-string' areI'm not strong about this, but it's better to call it just a 'pair', as 'value'
is a bit problematic because of json-value.
Hmm, the official term is "name/value pairs". Will use that instead.
Quoted 4 lines
QMP/qmp-spec.txt The format is: · line 153
Quoted 2 lines
QMP/qmp-spec.txt +1
-0+reserved for QMP-specific complex object classes that. QMP specifies whichEarly full stop?
Obviously. I just don't remember what I wanted to add.
Quoted 11 lines
Quoted 11 lines
QMP/qmp-spec.txt +4
-0+further keys each of these objects include and how they are encoded. + +So far, no complex object class is specified. + 3. QMP Examples ===============@@ -229,9 +238,10 @@ avoid modifying QMP. Both upstream and downstream need to take care to preserve long-term compatibility and interoperability.
Quoted 10 lines
QMP/qmp-spec.txt avoid modifying QMP. Both upstream and downstream need to take care to · line 244
Quoted 8 lines
QMP/qmp-spec.txt +4
-3To help with that, QMP reserves JSON object member names beginning with -'__' (double underscore) for downstream use ("downstream names"). This -means upstream will never use any downstream names for its commands, -arguments, errors, asynchronous events, and so forth. +'__' (double underscore) for downstream use ("downstream names"). Downstream +names MUST NOT end with '__' as this pattern is reserved for QMP-defined JSON +object classes. Upstream will never use any downstream names for its +commands, arguments, errors, asynchronous events, and so forth.Suggest mentioning subsection 2.6.
OK.
Thanks,
Jan
[Qemu-devel] Re: [PATCH v3 06/17] qdev: Allow device specification by qtree path for device_del
In reply to Jan KiszkaQuoted 23 lines · On Fri, 28 May 2010 00:19:48 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 22 lines · Luiz Capitulino
Quoted 6 lines · On Sun, 23 May 2010 12:59:19 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Allow to specify the device to be removed via
device_delnot only by ID but also by its full or abbreviated qtree path. For this purpose,qdev_findis introduced which combines walking the qtree with searching for device IDs if required.[...]
Quoted 9 lines
Arguments:
-- "id": the device's ID (json-string)
+- "path": the device's qtree path or unique ID (json-string)Example:
--> { "execute": "
device_del", "arguments": { "id": "net1" } } +-> { "execute": "device_del", "arguments": { "path": "net1" } }
Quoted 7 lines
Quoted 3 lines
Doesn't seem like a good change to me, besides being incompatible[1] we
shouldn't overload arguments this way in QMP as overloading leads to interface degradation (harder to use, understand, maintain).It's not overloaded, think of an ID as a (weak) symbolic link in the qtree filesystem. The advantage of basing everything on top of full or abbreviated qtree paths is that IDs are not always assigned, paths are.
You mean there're cases where an ID is not assigned? I didn't know that,
I thought they were always assigned, at least via QMP.
In any case, my main question here is that if this change really makes
sense for QMP or if it's something for HMP where we can have features like tab completion.
Quoted 5 lines
Quoted 1 line
Maybe we could have both arguments as optional, but one must be passed.
This would at least require some way to keep the proposed unified path specification for the human monitor (having separate arguments there is really unhandy).
Agreed, perhaps we have to decouple QMP and HMP in the way proposed by
Anthony: the HMP should work by making QMP calls (IIUC).
This way HMP can accept whatever arguments make sense for it, but then
it should transform them in a QMP call.
This is a long term project though.
[Qemu-devel] Re: [PATCH v3 13/17] monitor: Allow to exclude commands from QMP
In reply to Jan KiszkaQuoted 28 lines · On Fri, 28 May 2010 00:20:08 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 12 lines · Luiz Capitulino
Quoted 6 lines · On Sun, 23 May 2010 12:59:26 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Ported commands that are marked '
user_only' will not be considered for QMP monitor sessions. This allows to implement new commands that do not (yet) provide a sufficiently stable interface for QMP use (e.g.device_show).This is fine for me, but two things I've been wondering:
Quoted 7 lines
1. Isn't a 'flags' struct member better? So that we can do (in the qemu-monitor.hx entry):
.flags =
MONITOR_USER_ONLY|MONITOR_HANDLER_ASYNC,I'm not suggesting this is an async handler, just exemplifying multiple flags.
Yes, can refactor this.
Quoted 5 lines
2. Getting QMP handlers right in the first time might be difficult, so we could have a way to mark them unstable. Maybe a different namespace which is only enabled at configure time with:
Quoted 8 lines
Quoted 4 lines
--enable-qmp-unstable-commands
If this were possible, we could have
device_showand any command we aren't sure is QMP-ready working in QMP this way.Do you suggest this as an alternative to this patch? Or an extension later on? I have no opinion on this yet, I would just like to know how to proceed for this series.
Both can be done worked later, as this is internal there's no problem in
living with a simpler solution for a while.
[Qemu-devel] Re: [PATCH v3 06/17] qdev: Allow device specification by qtree path for device_del
In reply to Luiz CapitulinoQuoted 27 lines · Luiz Capitulino
Quoted 24 lines · On Fri, 28 May 2010 00:19:48 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 23 lines · Luiz Capitulino
Quoted 6 lines · On Sun, 23 May 2010 12:59:19 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Allow to specify the device to be removed via
device_delnot only by ID but also by its full or abbreviated qtree path. For this purpose,qdev_findis introduced which combines walking the qtree with searching for device IDs if required.[...]
Quoted 9 lines
Arguments:
-- "id": the device's ID (json-string)
+- "path": the device's qtree path or unique ID (json-string)Example:
--> { "execute": "
device_del", "arguments": { "id": "net1" } } +-> { "execute": "device_del", "arguments": { "path": "net1" } }Doesn't seem like a good change to me, besides being incompatible[1] we
shouldn't overload arguments this way in QMP as overloading leads to interface degradation (harder to use, understand, maintain).
Quoted 6 lines
Quoted 3 lines
It's not overloaded, think of an ID as a (weak) symbolic link in the qtree filesystem. The advantage of basing everything on top of full or abbreviated qtree paths is that IDs are not always assigned, paths are.
You mean there're cases where an ID is not assigned? I didn't know that,
I thought they were always assigned, at least via QMP.
Yes, platform devices or anything else that is auto-instantiated does not have an ID. Granted, you normally don't want or even can remove such devices, but you can perfectly display them. And someone asked for unifying the paths accepted by device_show and device_del.
Quoted 4 lines
In any case, my main question here is that if this change really makes
sense for QMP or if it's something for HMP where we can have features like tab completion.
I don't think QMP would suffer from having separate arguments for ID and qtree paths. We just need a way to map them on the same for HMP, ie. we need argument types that only show up in one of both domains.
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Maybe we could have both arguments as optional, but one must be passed.
This would at least require some way to keep the proposed unified path specification for the human monitor (having separate arguments there is really unhandy).
Quoted 7 lines
Agreed, perhaps we have to decouple QMP and HMP in the way proposed by
Anthony: the HMP should work by making QMP calls (IIUC).This way HMP can accept whatever arguments make sense for it, but then
it should transform them in a QMP call.This is a long term project though.
But the changes I propose already take effect today. We need at least an interim solution.
We could postpone the device_del HMP format change e.g., but that would take away some usability and leave criticized inconsistency behind.
Hmm, or we could simply introduce optional .hmp_args_type and .hmp_params. HMP would favor them when provided by a command, otherwise fall back to the standard params. Doesn't sound awfully complex and invasive.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] Re: [PATCH v3 06/17] qdev: Allow device specification by qtree path for device_del
In reply to Jan KiszkaQuoted 23 lines · Jan Kiszka
Quoted 22 lines · Luiz Capitulino
Quoted 6 lines · On Sun, 23 May 2010 12:59:19 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Allow to specify the device to be removed via
device_delnot only by ID but also by its full or abbreviated qtree path. For this purpose,qdev_findis introduced which combines walking the qtree with searching for device IDs if required.[...]
Quoted 9 lines
Arguments:
-- "id": the device's ID (json-string)
+- "path": the device's qtree path or unique ID (json-string)Example:
--> { "execute": "
device_del", "arguments": { "id": "net1" } } +-> { "execute": "device_del", "arguments": { "path": "net1" } }
Quoted 7 lines
Quoted 3 lines
Doesn't seem like a good change to me, besides being incompatible[1] we
shouldn't overload arguments this way in QMP as overloading leads to interface degradation (harder to use, understand, maintain).It's not overloaded, think of an ID as a (weak) symbolic link in the qtree filesystem. The advantage of basing everything on top of full or abbreviated qtree paths is that IDs are not always assigned, paths are.
As long as your patch doesn't change the interpretation of IDs, we can keep the old name.
The recent review of QMP documentation may lead to a "clean up bad names" flag day. One more wouldn't make it worse, I guess.
Quoted 5 lines
Quoted 1 line
Maybe we could have both arguments as optional, but one must be passed.
This would at least require some way to keep the proposed unified path specification for the human monitor (having separate arguments there is really unhandy).
Correct.
It would be nice to have device_del support paths in addition to IDs. I'd expect management tools to slap IDs on everything, so they won't care, but human users do.
As far as I know, we have two places where we let the user name a node in the qtree: device_add bus=X and device_del X. The former names a bus, the latter a device. But both are nodes in the same tree, so consistency is in order.
Only devices have user-specified IDs. Buses have names assigned by the system. Unique names, hopefully.
If the user doesn't specify a device ID, the driver name is used instead. If you put multiple instances of the same device on the same bus, they have the *same* path. For instance, here's a snippet of info qtree after adding two usb-mouse:
dev: piix3-usb-uhci, id ""
bus-prop: addr = 01.2
bus-prop: romfile = <null>
bus-prop: rombar = 1
class USB controller, addr 00:01.2, pci id 8086:7020 (sub 1af4:1100) bar 4: i/o at 0xffffffffffffffff [0x1e]
bus: usb.0
type USB
dev: usb-hub, id ""
addr 0.0, speed 12, name QEMU USB Hub, attached
dev: usb-mouse, id "no2"
addr 0.0, speed 12, name QEMU USB Mouse, attached
dev: usb-mouse, id ""
addr 0.0, speed 12, name QEMU USB Mouse, attached
Both devices have the same full path /i440FX-pcihost/pci.0/piix3-usb-uhci/usb.0/usb-mouse Which one does your code pick? Shouldn't it refuse to pick?
By the way, you *can* put '/' in IDs. I call that a bug.
Quoted 9 lines
Quoted 7 lines
[1] It's 'legal' to break the protocol before 0.13, but this has to be coordinated with libvirt so we should have a good reason to do this
Quoted 3 lines
<- { "return": {} }
EQMP
Jan
Re: [Qemu-devel] Re: [PATCH v3 06/17] qdev: Allow device specification by qtree path for device_del
Quoted 47 lines · Markus Armbruster
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Luiz Capitulino
Quoted 6 lines · On Sun, 23 May 2010 12:59:19 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Allow to specify the device to be removed via
device_delnot only by ID but also by its full or abbreviated qtree path. For this purpose,qdev_findis introduced which combines walking the qtree with searching for device IDs if required.[...]
Quoted 7 lines
Arguments:
-- "id": the device's ID (json-string)
+- "path": the device's qtree path or unique ID (json-string)Example:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
--> { "execute": "
device_del", "arguments": { "id": "net1" } } +-> { "execute": "device_del", "arguments": { "path": "net1" } }Doesn't seem like a good change to me, besides being incompatible[1] we
shouldn't overload arguments this way in QMP as overloading leads to interface degradation (harder to use, understand, maintain).It's not overloaded, think of an ID as a (weak) symbolic link in the qtree filesystem. The advantage of basing everything on top of full or abbreviated qtree paths is that IDs are not always assigned, paths are.
As long as your patch doesn't change the interpretation of IDs, we can keep the old name.
The recent review of QMP documentation may lead to a "clean up bad names" flag day. One more wouldn't make it worse, I guess.
Quoted 4 lines
Quoted 1 line
Maybe we could have both arguments as optional, but one must be passed.
This would at least require some way to keep the proposed unified path specification for the human monitor (having separate arguments there is really unhandy).
Correct.
It would be nice to have
device_delsupport paths in addition to IDs. I'd expect management tools to slap IDs on everything, so they won't care, but human users do.
Quoted 7 lines
As far as I know, we have two places where we let the user name a node in the qtree:
device_addbus=X anddevice_delX. The former names a bus, the latter a device. But both are nodes in the same tree, so consistency is in order.Only devices have user-specified IDs. Buses have names assigned by the system. Unique names, hopefully.
...but not necessarily. The bus name device_add accepts can also be a full, thus unambiguous path.
Quoted 21 lines
If the user doesn't specify a device ID, the driver name is used instead. If you put multiple instances of the same device on the same bus, they have the *same* path. For instance, here's a snippet of info qtree after adding two usb-mouse:
dev: piix3-usb-uhci, id ""
bus-prop: addr = 01.2
bus-prop: romfile = <null>
bus-prop: rombar = 1
class USB controller, addr 00:01.2, pci id 8086:7020 (sub 1af4:1100) bar 4: i/o at0xffffffffffffffff[0x1e]
bus: usb.0
type USB
dev: usb-hub, id ""
addr 0.0, speed 12, name QEMU USB Hub, attached
dev: usb-mouse, id "no2"
addr 0.0, speed 12, name QEMU USB Mouse, attached
dev: usb-mouse, id ""
addr 0.0, speed 12, name QEMU USB Mouse, attached
Quoted 3 lines
Both devices have the same full path /i440FX-pcihost/pci.0/piix3-usb-uhci/usb.0/usb-mouse Which one does your code pick? Shouldn't it refuse to pick?
Patch 3 of this series resolves this as follows:
usb-mouse[.0] -> first listed instance
usb-mouse.1 -> second instance
...
We should probably include this numbering in the qtree dump, I guess.
Quoted 2 lines
By the way, you *can* put '/' in IDs. I call that a bug.
Even if we prevent this, IDs can still collide with abbreviated device or bus paths. Therefore I give paths precedence over IDs in patch 4.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] Re: [PATCH v3 13/17] monitor: Allow to exclude commands from QMP
In reply to Markus ArmbrusterQuoted 16 lines · Markus Armbruster
Quoted 14 lines · Luiz Capitulino
Quoted 6 lines · On Sun, 23 May 2010 12:59:26 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Ported commands that are marked '
user_only' will not be considered for QMP monitor sessions. This allows to implement new commands that do not (yet) provide a sufficiently stable interface for QMP use (e.g.device_show).This is fine for me, but two things I've been wondering:
1. Isn't a 'flags' struct member better? So that we can do (in the qemu-monitor.hx entry):
Quoted 8 lines
Quoted 4 lines
.flags =
MONITOR_USER_ONLY|MONITOR_HANDLER_ASYNC,I'm not suggesting this is an async handler, just exemplifying multiple flags.
We also have at least one command that makes only sense in QMP:
qmp_capabilities. Maybe we could use separate flags controlling command availability in human monitor and QMP.
Sounds reasonable. Then I think I will lay the ground for this by introducing flags already in this patch. A v4 run is required anyway.
Jan
Re: [Qemu-devel] Re: [PATCH v3 13/17] monitor: Allow to exclude commands from QMP
In reply to Luiz CapitulinoQuoted 12 lines · Luiz Capitulino
Quoted 6 lines · On Sun, 23 May 2010 12:59:26 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Ported commands that are marked '
user_only' will not be considered for QMP monitor sessions. This allows to implement new commands that do not (yet) provide a sufficiently stable interface for QMP use (e.g.device_show).This is fine for me, but two things I've been wondering:
Quoted 7 lines
1. Isn't a 'flags' struct member better? So that we can do (in the qemu-monitor.hx entry):
.flags =
MONITOR_USER_ONLY|MONITOR_HANDLER_ASYNC,I'm not suggesting this is an async handler, just exemplifying multiple flags.
We also have at least one command that makes only sense in QMP:qmp_capabilities. Maybe we could use separate flags controlling command availability in human monitor and QMP.
[...]
Re: [Qemu-devel] Re: [PATCH v3 06/17] qdev: Allow device specification by qtree path for device_del
In reply to Markus ArmbrusterQuoted 89 lines · Markus Armbruster
Quoted 87 lines · Jan Kiszka
Quoted 45 lines · Markus Armbruster
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Luiz Capitulino
Quoted 6 lines · On Sun, 23 May 2010 12:59:19 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Allow to specify the device to be removed via
device_delnot only by ID but also by its full or abbreviated qtree path. For this purpose,qdev_findis introduced which combines walking the qtree with searching for device IDs if required.[...]
Quoted 7 lines
Arguments:
-- "id": the device's ID (json-string)
+- "path": the device's qtree path or unique ID (json-string)Example:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
--> { "execute": "
device_del", "arguments": { "id": "net1" } } +-> { "execute": "device_del", "arguments": { "path": "net1" } }Doesn't seem like a good change to me, besides being incompatible[1] we
shouldn't overload arguments this way in QMP as overloading leads to interface degradation (harder to use, understand, maintain).It's not overloaded, think of an ID as a (weak) symbolic link in the qtree filesystem. The advantage of basing everything on top of full or abbreviated qtree paths is that IDs are not always assigned, paths are.
As long as your patch doesn't change the interpretation of IDs, we can keep the old name.
The recent review of QMP documentation may lead to a "clean up bad names" flag day. One more wouldn't make it worse, I guess.
Quoted 4 lines
Quoted 1 line
Maybe we could have both arguments as optional, but one must be passed.
This would at least require some way to keep the proposed unified path specification for the human monitor (having separate arguments there is really unhandy).
Correct.
It would be nice to have
device_delsupport paths in addition to IDs. I'd expect management tools to slap IDs on everything, so they won't care, but human users do.Quoted 7 lines
As far as I know, we have two places where we let the user name a node in the qtree:
device_addbus=X anddevice_delX. The former names a bus, the latter a device. But both are nodes in the same tree, so consistency is in order.Only devices have user-specified IDs. Buses have names assigned by the system. Unique names, hopefully.
...but not necessarily. The bus name
device_addaccepts can also be a full, thus unambiguous path.Quoted 20 lines
If the user doesn't specify a device ID, the driver name is used instead. If you put multiple instances of the same device on the same bus, they have the *same* path. For instance, here's a snippet of info qtree after adding two usb-mouse:
dev: piix3-usb-uhci, id ""
bus-prop: addr = 01.2
bus-prop: romfile = <null>
bus-prop: rombar = 1
class USB controller, addr 00:01.2, pci id 8086:7020 (sub 1af4:1100) bar 4: i/o at0xffffffffffffffff[0x1e]
bus: usb.0
type USB
dev: usb-hub, id ""
addr 0.0, speed 12, name QEMU USB Hub, attached
dev: usb-mouse, id "no2"
addr 0.0, speed 12, name QEMU USB Mouse, attached
dev: usb-mouse, id ""
addr 0.0, speed 12, name QEMU USB Mouse, attachedQuoted 3 lines
Both devices have the same full path /i440FX-pcihost/pci.0/piix3-usb-uhci/usb.0/usb-mouse Which one does your code pick? Shouldn't it refuse to pick?
Patch 3 of this series resolves this as follows:
usb-mouse[.0] -> first listed instance
usb-mouse.1 -> second instance
...We should probably include this numbering in the qtree dump, I guess.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
By the way, you *can* put '/' in IDs. I call that a bug.
Even if we prevent this, IDs can still collide with abbreviated device or bus paths. Therefore I give paths precedence over IDs in patch 4.
You're fixing problems in the overly complex and subtle path name lookup by making it more complex and subtle. Let's make it simple and straightforward instead.
I have no problem with ripping out all of those abbreviations, requiring the user to either specify a '/'-less unique ID or a full qtree path that must start with a '/'. If paths get long, we now have interactive completions.
Jan
Re: [Qemu-devel] [PATCH v3 12/17] monitor: return length of printed string via monitor_[v]printf
In reply to Jan KiszkaQuoted 7 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
This simply forwards the result of the internal vsnprintf to the callers of
monitor_printfandmonitor_vprintf. When invoked over a QMP session or in absence of an active monitor, -1 is returned.Signed-off-by Jan Kiszka <[email protected]>
Appreciated! Opens the door to addressing the TODOs in qemu-error.c.
Re: [Qemu-devel] Re: [PATCH v3 06/17] qdev: Allow device specification by qtree path for device_del
In reply to Jan KiszkaQuoted 90 lines · Jan Kiszka
Quoted 47 lines · Markus Armbruster
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Luiz Capitulino
Quoted 6 lines · On Sun, 23 May 2010 12:59:19 +0200 Jan Kiszka <[email protected]> wrote:
From: Jan Kiszka <[email protected]>
Allow to specify the device to be removed via
device_delnot only by ID but also by its full or abbreviated qtree path. For this purpose,qdev_findis introduced which combines walking the qtree with searching for device IDs if required.[...]
Quoted 7 lines
Arguments:
-- "id": the device's ID (json-string)
+- "path": the device's qtree path or unique ID (json-string)Example:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
--> { "execute": "
device_del", "arguments": { "id": "net1" } } +-> { "execute": "device_del", "arguments": { "path": "net1" } }Doesn't seem like a good change to me, besides being incompatible[1] we
shouldn't overload arguments this way in QMP as overloading leads to interface degradation (harder to use, understand, maintain).It's not overloaded, think of an ID as a (weak) symbolic link in the qtree filesystem. The advantage of basing everything on top of full or abbreviated qtree paths is that IDs are not always assigned, paths are.
As long as your patch doesn't change the interpretation of IDs, we can keep the old name.
The recent review of QMP documentation may lead to a "clean up bad names" flag day. One more wouldn't make it worse, I guess.
Quoted 4 lines
Quoted 1 line
Maybe we could have both arguments as optional, but one must be passed.
This would at least require some way to keep the proposed unified path specification for the human monitor (having separate arguments there is really unhandy).
Correct.
It would be nice to have
device_delsupport paths in addition to IDs. I'd expect management tools to slap IDs on everything, so they won't care, but human users do.Quoted 7 lines
As far as I know, we have two places where we let the user name a node in the qtree:
device_addbus=X anddevice_delX. The former names a bus, the latter a device. But both are nodes in the same tree, so consistency is in order.Only devices have user-specified IDs. Buses have names assigned by the system. Unique names, hopefully.
...but not necessarily. The bus name
device_addaccepts can also be a full, thus unambiguous path.Quoted 21 lines
If the user doesn't specify a device ID, the driver name is used instead. If you put multiple instances of the same device on the same bus, they have the *same* path. For instance, here's a snippet of info qtree after adding two usb-mouse:
dev: piix3-usb-uhci, id ""
bus-prop: addr = 01.2
bus-prop: romfile = <null>
bus-prop: rombar = 1
class USB controller, addr 00:01.2, pci id 8086:7020 (sub 1af4:1100) bar 4: i/o at0xffffffffffffffff[0x1e]
bus: usb.0
type USB
dev: usb-hub, id ""
addr 0.0, speed 12, name QEMU USB Hub, attached
dev: usb-mouse, id "no2"
addr 0.0, speed 12, name QEMU USB Mouse, attached
dev: usb-mouse, id ""
addr 0.0, speed 12, name QEMU USB Mouse, attachedQuoted 3 lines
Both devices have the same full path /i440FX-pcihost/pci.0/piix3-usb-uhci/usb.0/usb-mouse Which one does your code pick? Shouldn't it refuse to pick?
Patch 3 of this series resolves this as follows:
usb-mouse[.0] -> first listed instance
usb-mouse.1 -> second instance
...
Quoted 7 lines
We should probably include this numbering in the qtree dump, I guess.
Quoted 2 lines
By the way, you *can* put '/' in IDs. I call that a bug.
Even if we prevent this, IDs can still collide with abbreviated device or bus paths. Therefore I give paths precedence over IDs in patch 4.
You're fixing problems in the overly complex and subtle path name lookup by making it more complex and subtle. Let's make it simple and straightforward instead.
Re: [Qemu-devel] [PATCH v3 04/17] qdev: Give qtree names precedence over user-assigned IDs
In reply to Jan KiszkaQuoted 6 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
As the user may specify ambiguous device IDs, let's search for their official names first before considering the user-supplied identifiers.
Signed-off-by Jan Kiszka <[email protected]>
The problem is letting the user specify ambiguous device IDs in the first place! That way is madness...
Re: [Qemu-devel] [PATCH v3 04/17] qdev: Give qtree names precedence over user-assigned IDs
Quoted 5 lines · Markus Armbruster
Quoted 2 lines · Jan Kiszka
From: Jan Kiszka<[email protected]>
Quoted 8 lines
Quoted 5 lines
As the user may specify ambiguous device IDs, let's search for their official names first before considering the user-supplied identifiers.
Signed-off-by Jan Kiszka<[email protected]>The problem is letting the user specify ambiguous device IDs in the first place! That way is madness...
Agreed, we're sowing the seeds for future problems.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH v3 04/17] qdev: Give qtree names precedence over user-assigned IDs
[cc: kraxel]
Quoted 9 lines · Avi Kivity
Quoted 8 lines · Markus Armbruster
Quoted 5 lines · Jan Kiszka
From: Jan Kiszka<[email protected]>
As the user may specify ambiguous device IDs, let's search for their official names first before considering the user-supplied identifiers.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Jan Kiszka<[email protected]>The problem is letting the user specify ambiguous device IDs in the first place! That way is madness...
Agreed, we're sowing the seeds for future problems.
On closer look, we have some protection against duplicate IDs, but it got holes.
We don't assign IDs to default devices.
-device and device_add use the ID of a qemu_device_opts. Which rejects duplicate IDs.
pci_add nic -net use either the ID or option "name" of qemu_net_opts. And there's our hole. Reproducible with "-net user -net nic,id=foo -device lsi,id=foo".
We better check for duplicates right where we create qdevs. Gerd, what do you think about the appended patch?
hw/qdev.c +5 -0
@@ -40,6 +40,7 @@ DeviceInfo *device_info_list;static BusState *qbus_find_recursive (BusState *bus,const char *name,const BusInfo *info);static BusState *qbus_find (const char *path); +static DeviceState *qdev_find_recursive (BusState *bus,const char *id);/* Register a new device type. */ void qdev_register (DeviceInfo *info)
@@ -242,6 +243,10 @@ DeviceState *qdev_device_add(QemuOpts *opts) qdev =qdev_create_from_info (bus, info); id =qemu_opts_id (opts);if (id) { +if (qdev_find_recursive (main_system_bus, id)) { +qerror_report (QERR_DUPLICATE_ID , id,"device" ); +return NULL ; + } qdev->id = id; }if (qemu_opt_foreach (opts, set_property, qdev,1 ) !=0 ) {
Gerd Hoffmann
Acked-byRe: [Qemu-devel] [PATCH v3 04/17] qdev: Give qtree names precedence over user-assigned IDs
Quoted 3 lines
pci_addnic -net use either the ID or option "name" ofqemu_net_opts. And there's our hole. Reproducible with "-net user -net nic,id=foo -device lsi,id=foo".
Oh. Well. Yes, better plug that.
hw/qdev.c DeviceState *qdev_device_add(QemuOpts *opts) · line 252
Quoted 11 lines
hw/qdev.c +4
-0@@ -242,6 +243,10 @@ DeviceState *qdev_device_add(QemuOpts *opts) qdev =qdev_create_from_info (bus, info); id =qemu_opts_id (opts);if (id) { +if (qdev_find_recursive (main_system_bus, id)) { +qerror_report (QERR_DUPLICATE_ID , id,"device" ); +return NULL ; + } qdev->id = id; }if (qemu_opt_foreach (opts, set_property, qdev,1 ) !=0 ) {
Looks good..
cheers,
Gerd
Re: [Qemu-devel] [PATCH v3 04/17] qdev: Give qtree names precedence over user-assigned IDs
Quoted 20 lines · Gerd Hoffmann
Quoted 3 lines
pci_addnic -net use either the ID or option "name" ofqemu_net_opts. And there's our hole. Reproducible with "-net user -net nic,id=foo -device lsi,id=foo".Oh. Well. Yes, better plug that.
hw/qdev.c DeviceState *qdev_device_add(QemuOpts *opts) · line 252
Quoted 11 lines
hw/qdev.c +4
-0@@ -242,6 +243,10 @@ DeviceState *qdev_device_add(QemuOpts *opts) qdev =qdev_create_from_info (bus, info); id =qemu_opts_id (opts);if (id) { +if (qdev_find_recursive (main_system_bus, id)) { +qerror_report (QERR_DUPLICATE_ID , id,"device" ); +return NULL ; + } qdev->id = id; }if (qemu_opt_foreach (opts, set_property, qdev,1 ) !=0 ) {Looks good..
Quoted 1 line
Acked-by Gerd Hoffmann <[email protected]>
I'll repost it as a well-formed patch. While there, I'll outlaw "/".
What about requiring IDs to start with a letter? Just in case we ever want to add alias names that must not clash with user-specified IDs.
PATCH 1/1 qdev: Reject duplicate and anti-social device IDs
In reply to Gerd HoffmannWe need Device IDs to be unique and not contain '/' so device tree nodes can always be unambigously referenced by tree path.
We already have some protection against duplicate IDs, but it got holes:
* We don't assign IDs to default devices.
* -device and device_add use the ID of a qemu_device_opts. Which rejects duplicate IDs.
* pci_add nic -net use either the ID or option "name" of qemu_net_opts. And there's our hole. Reproducible with "-net user -net nic,id=foo -device lsi,id=foo".
Also require IDs to start with a letter to provide for possible future extensions.
---
Note: If requiring IDs to start with a letter should turn out to be controversial, I'm happy to respin without that part.
hw/qdev.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
hw/qdev.c +11 -0
@@ -40,6 +40,7 @@ DeviceInfo *device_info_list;static BusState *qbus_find_recursive (BusState *bus,const char *name,const BusInfo *info);static BusState *qbus_find (const char *path); +static DeviceState *qdev_find_recursive (BusState *bus,const char *id);/* Register a new device type. */ void qdev_register (DeviceInfo *info)
@@ -242,6 +243,16 @@ DeviceState *qdev_device_add(QemuOpts *opts) qdev =qdev_create_from_info (bus, info); id =qemu_opts_id (opts);if (id) { +if (!qemu_isalpha (id[0 ]) ||strchr (id,'/' )) { +qerror_report (QERR_INVALID_PARAMETER_VALUE ,"id" , +"an identifier starting with a letter, " +"and not containing '/'" ); +return NULL ; + } +if (qdev_find_recursive (main_system_bus, id)) { +qerror_report (QERR_DUPLICATE_ID , id,"device" ); +return NULL ; + } qdev->id = id; }if (qemu_opt_foreach (opts, set_property, qdev,1 ) !=0 ) {
Signature · 1 line
1.6.6.1
[Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
Quoted 11 lines · Markus Armbruster
We need Device IDs to be unique and not contain '/' so device tree nodes can always be unambigously referenced by tree path.
We already have some protection against duplicate IDs, but it got holes:
* We don't assign IDs to default devices.
* -device and
device_adduse the ID of aqemu_device_opts. Which rejects duplicate IDs.
Quoted 7 lines
*
pci_addnic -net use either the ID or option "name" ofqemu_net_opts. And there's our hole. Reproducible with "-net user -net nic,id=foo -device lsi,id=foo".Also require IDs to start with a letter to provide for possible future extensions.
cheers,
Gerd
[Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
In reply to Markus ArmbrusterQuoted 6 lines · On Mon, 31 May 2010 16:13:12 +0200 Markus Armbruster <[email protected]> wrote:
We need Device IDs to be unique and not contain '/' so device tree nodes can always be unambigously referenced by tree path.
We already have some protection against duplicate IDs, but it got holes:
Quoted 8 lines
* We don't assign IDs to default devices.
* -device and
device_adduse the ID of aqemu_device_opts. Which rejects duplicate IDs.*
pci_addnic -net use either the ID or option "name" ofqemu_net_opts. And there's our hole. Reproducible with "-net user -net nic,id=foo -device lsi,id=foo".
Two bugs that might not be related to this thread:
* "id" member is not mandatory for the device_add command:
{ "execute": "device_add", "arguments": { "driver": "e1000" } }
{"return": {}} * "id" member remains in use when the netdev_add command fails:
{ "execute": "netdev_add", "arguments": { "id": "foobar" } }
{"error": {"class": "MissingParameter", "desc": "Parameter 'type' is missing", "data": {"name": "type"}}}
{ "execute": "netdev_add", "arguments": { "type": "user", "id": "foobar" } }
{"error": {"class": "DuplicateId", "desc": "Duplicate ID 'foobar' for netdev", "data": {"object": "netdev", "id": "foobar"}}}[Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
Quoted 6 lines · Luiz Capitulino
Two bugs that might not be related to this thread:
* "id" member is not mandatory for the
device_addcommand:{ "execute": "device_add", "arguments": { "driver": "e1000" } } {"return": {}}
Once we enable qtree paths for device_del, this is no longer an issue, devices will remain addressable.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
[Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
Quoted 10 lines · On Tue, 01 Jun 2010 15:09:34 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 6 lines · Luiz Capitulino
Two bugs that might not be related to this thread:
* "id" member is not mandatory for the
device_addcommand:{ "execute": "device_add", "arguments": { "driver": "e1000" } } {"return": {}}Once we enable qtree paths for
device_del, this is no longer an issue, devices will remain addressable.
Main point is whether "id" is required or not, I think it should be.
[Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
In reply to Jan KiszkaQuoted 6 lines · Jan Kiszka
Quoted 3 lines
Main point is whether "id" is required or not, I think it should be.
And I think it might be recommended but should become mandatory (specifically not for HMP).
I agree. Making id a mandatory argument will just result in clients being forced to manufacture unnecessary IDs, which is annoying.
Signature · 1 line
error compiling committee.c: too many arguments to function
[Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
In reply to Jan KiszkaQuoted 11 lines · On Tue, 01 Jun 2010 15:19:59 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 10 lines · Luiz Capitulino
Quoted 7 lines · On Tue, 01 Jun 2010 15:09:34 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 6 lines · Luiz Capitulino
Two bugs that might not be related to this thread:
* "id" member is not mandatory for the
device_addcommand:{ "execute": "device_add", "arguments": { "driver": "e1000" } } {"return": {}}
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Once we enable qtree paths for
device_del, this is no longer an issue, devices will remain addressable.Main point is whether "id" is required or not, I think it should be.
And I think it might be recommended but should become mandatory (specifically not for HMP).
Maybe you meant 'should not'?
Anyway, if we keep it optional for device_add we should also change
the others _add commands to have the same behavior.
[Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
In reply to Luiz CapitulinoQuoted 6 lines · Luiz Capitulino
Quoted 3 lines · On Tue, 01 Jun 2010 15:09:34 +0200 Jan Kiszka <[email protected]> wrote:
Quoted 2 lines · Luiz Capitulino
Two bugs that might not be related to this thread:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
* "id" member is not mandatory for the
device_addcommand:{ "execute": "device_add", "arguments": { "driver": "e1000" } } {"return": {}}Once we enable qtree paths for
device_del, this is no longer an issue, devices will remain addressable.Main point is whether "id" is required or not, I think it should be.
And I think it might be recommended but should become mandatory (specifically not for HMP).
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
In reply to Luiz CapitulinoQuoted 18 lines · Luiz Capitulino
Quoted 6 lines · On Mon, 31 May 2010 16:13:12 +0200 Markus Armbruster <[email protected]> wrote:
We need Device IDs to be unique and not contain '/' so device tree nodes can always be unambigously referenced by tree path.
We already have some protection against duplicate IDs, but it got holes:
Quoted 8 lines
* We don't assign IDs to default devices.
* -device and
device_adduse the ID of aqemu_device_opts. Which rejects duplicate IDs.*
pci_addnic -net use either the ID or option "name" ofqemu_net_opts. And there's our hole. Reproducible with "-net user -net nic,id=foo -device lsi,id=foo".
Quoted 6 lines
Two bugs that might not be related to this thread:
* "id" member is not mandatory for the
device_addcommand:{ "execute": "device_add", "arguments": { "driver": "e1000" } } {"return": {}}
Works as designed.
Quoted 7 lines
* "id" member remains in use when the
netdev_addcommand fails:{ "execute": "netdev_add", "arguments": { "id": "foobar" } } {"error": {"class": "MissingParameter", "desc": "Parameter 'type' is missing", "data": {"name": "type"}}} { "execute": "netdev_add", "arguments": { "type": "user", "id": "foobar" } } {"error": {"class": "DuplicateId", "desc": "Duplicate ID 'foobar' for netdev", "data": {"object": "netdev", "id": "foobar"}}}
Sounds like a bug.
Re: [Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
Quoted 20 lines · On Tue, 01 Jun 2010 16:44:24 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 18 lines · Luiz Capitulino
Quoted 14 lines · On Mon, 31 May 2010 16:13:12 +0200 Markus Armbruster <[email protected]> wrote:
We need Device IDs to be unique and not contain '/' so device tree nodes can always be unambigously referenced by tree path.
We already have some protection against duplicate IDs, but it got holes:
* We don't assign IDs to default devices.
* -device and
device_adduse the ID of aqemu_device_opts. Which rejects duplicate IDs.*
pci_addnic -net use either the ID or option "name" ofqemu_net_opts. And there's our hole. Reproducible with "-net user -net nic,id=foo -device lsi,id=foo".
Quoted 8 lines
Quoted 6 lines
Two bugs that might not be related to this thread:
* "id" member is not mandatory for the
device_addcommand:{ "execute": "device_add", "arguments": { "driver": "e1000" } } {"return": {}}Works as designed.
What about netdev_add?
{ "execute": "netdev_add", "arguments": { "type": "user" } }
{"error": {"class": "MissingParameter", "desc": "Parameter 'id' is missing", "data": {"name": "id"}}}
Re: [Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
Quoted 30 lines · Luiz Capitulino
Quoted 27 lines · On Tue, 01 Jun 2010 16:44:24 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 24 lines · Luiz Capitulino
Quoted 6 lines · On Mon, 31 May 2010 16:13:12 +0200 Markus Armbruster <[email protected]> wrote:
We need Device IDs to be unique and not contain '/' so device tree nodes can always be unambigously referenced by tree path.
We already have some protection against duplicate IDs, but it got holes:
Quoted 8 lines
* We don't assign IDs to default devices.
* -device and
device_adduse the ID of aqemu_device_opts. Which rejects duplicate IDs.*
pci_addnic -net use either the ID or option "name" ofqemu_net_opts. And there's our hole. Reproducible with "-net user -net nic,id=foo -device lsi,id=foo".Two bugs that might not be related to this thread:
* "id" member is not mandatory for the
device_addcommand:{ "execute": "device_add", "arguments": { "driver": "e1000" } } {"return": {}}
Quoted 6 lines
Quoted 1 line
Works as designed.
What about
netdev_add?{ "execute": "
netdev_add", "arguments": { "type": "user" } }
{"error": {"class": "MissingParameter", "desc": "Parameter 'id' is missing", "data": {"name": "id"}}}
The only way to put a netdev to use is connecting it to a NIC with -device DRIVER,netdev=ID,... And that requires an ID.
Re: [Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
Quoted 38 lines · Markus Armbruster
Quoted 35 lines · Luiz Capitulino
Quoted 31 lines · On Tue, 01 Jun 2010 16:44:24 +0200 Markus Armbruster<[email protected]> wrote:
Quoted 19 lines · Luiz Capitulino
Quoted 6 lines · On Mon, 31 May 2010 16:13:12 +0200 Markus Armbruster<[email protected]> wrote:
We need Device IDs to be unique and not contain '/' so device tree nodes can always be unambigously referenced by tree path.
We already have some protection against duplicate IDs, but it got holes:
Quoted 9 lines
* We don't assign IDs to default devices.
* -device and
device_adduse the ID of aqemu_device_opts. Which rejects duplicate IDs.*
pci_addnic -net use either the ID or option "name" ofqemu_net_opts. And there's our hole. Reproducible with "-net user -net nic,id=foo -device lsi,id=foo".Quoted 7 lines
Two bugs that might not be related to this thread:
* "id" member is not mandatory for the device_add command: { "execute": "device_add", "arguments": { "driver": "e1000" } } {"return": {}}Works as designed.
Quoted 8 lines
Quoted 5 lines
What about
netdev_add?{ "execute": "
netdev_add", "arguments": { "type": "user" } }
{"error": {"class": "MissingParameter", "desc": "Parameter 'id' is missing", "data": {"name": "id"}}}The only way to put a netdev to use is connecting it to a NIC with -device DRIVER,netdev=ID,... And that requires an ID.
To be honest, I think we should universally require an id parameter or we should auto-assign one and return it during creation.
Implicit/Null ids with QemuOpts are really difficult to work with and it certainly makes device addressing a lot easier.
Regards,
Anthony Liguori
Re: [Qemu-devel] [PATCH v3 02/17] qdev: Fix scanning across single-bus devices
In reply to Jan KiszkaQuoted 5 lines
From: Jan Kiszka <[email protected]>
As long as we allow /dev.1 as shortcut for /dev1/bus1, we also have to make sure that /dev1/dev2 works for /dev1/bus1/dev2/bus2 - as long as there is only one child bus per device.
How about we make this explicit in the syntax by having a different separator for bus names. e.g. /dev1:bus1/dev2:bus1. Omitting the :bus is then unambiguous.
Paul
Re: [Qemu-devel] [PATCH v3 02/17] qdev: Fix scanning across single-bus devices
Quoted 9 lines · Paul Brook
Quoted 5 lines
From: Jan Kiszka <[email protected]>
As long as we allow /dev.1 as shortcut for /dev1/bus1, we also have to make sure that /dev1/dev2 works for /dev1/bus1/dev2/bus2 - as long as there is only one child bus per device.
How about we make this explicit in the syntax by having a different separator for bus names. e.g. /dev1:bus1/dev2:bus1. Omitting the :bus is then unambiguous.
...as long as there will always be only one bus at dev1 and/or only one dev2 on dev1's buses.
I think we should stick with the consensus of dropping these abbreviations.
Jan
Re: [Qemu-devel] Re: [PATCH] qdev: Reject duplicate and anti-social device IDs
In reply to Anthony LiguoriQuoted 50 lines · Anthony Liguori
Quoted 39 lines · Markus Armbruster
Quoted 36 lines · Luiz Capitulino
Quoted 32 lines · On Tue, 01 Jun 2010 16:44:24 +0200 Markus Armbruster<[email protected]> wrote:
Quoted 20 lines · Luiz Capitulino
Quoted 8 lines · On Mon, 31 May 2010 16:13:12 +0200 Markus Armbruster<[email protected]> wrote:
We need Device IDs to be unique and not contain '/' so device tree nodes can always be unambigously referenced by tree path.
We already have some protection against duplicate IDs, but it got holes:
* We don't assign IDs to default devices.
Quoted 8 lines
* -device and
device_adduse the ID of aqemu_device_opts. Which rejects duplicate IDs.*
pci_addnic -net use either the ID or option "name" ofqemu_net_opts. And there's our hole. Reproducible with "-net
user
-net nic,id=foo -device lsi,id=foo".Quoted 7 lines
Two bugs that might not be related to this thread:
* "id" member is not mandatory for the device_add command: { "execute": "device_add", "arguments": { "driver": "e1000" } } {"return": {}}Works as designed.
Quoted 9 lines
Quoted 6 lines
What about
netdev_add?{ "execute": "
netdev_add", "arguments": { "type": "user" } } {"error": {"class": "MissingParameter", "desc": "Parameter 'id' is
missing", "data": {"name": "id"}}}The only way to put a netdev to use is connecting it to a NIC with -device DRIVER,netdev=ID,... And that requires an ID.
Quoted 5 lines
To be honest, I think we should universally require an id parameter or we should auto-assign one and return it during creation.
Implicit/Null ids with QemuOpts are really difficult to work with and it certainly makes device addressing a lot easier.
I really see no need for this additional burden. We always have unique qtree paths for devices.
Jan
Re: [Qemu-devel] [PATCH] qdev: Reject duplicate and anti-social device IDs
In reply to Markus ArmbrusterQuoted 2 lines
Also require IDs to start with a letter to provide for possible future extensions.
I'd go further than that, and require that user specified IDs match [A-Za-z][A-Za-z0-9_-]*
Paul
Re: [Qemu-devel] [PATCH] qdev: Reject duplicate and anti-social device IDs
Quoted 5 lines · Paul Brook
Quoted 2 lines
Also require IDs to start with a letter to provide for possible future extensions.
I'd go further than that, and require that user specified IDs match [A-Za-z][A-Za-z0-9_-]*
I talked with Dan (cc'ed) to make sure we don't trample on existing libvirt usage without need. What about
[A-Za-z][A-Za-z0-9_-:.]*
i.e. your regexp plus ':' and '.' in the second bracket?
Re: [Qemu-devel] [PATCH] qdev: Reject duplicate and anti-social device IDs
Quoted 7 lines
Quoted 5 lines · Paul Brook
Quoted 2 lines
Also require IDs to start with a letter to provide for possible future extensions.
I'd go further than that, and require that user specified IDs match [A-Za-z][A-Za-z0-9_-]*
Quoted 6 lines
I talked with Dan (cc'ed) to make sure we don't trample on existing libvirt usage without need. What about
[A-Za-z][A-Za-z0-9_-:.]*
i.e. your regexp plus ':' and '.' in the second bracket?
I was deliberately avoiding those as they're often used as separators - we already use ':' in other contexts so there's potential ambiguity and parsing/quoting issues. I'm not aware of any current issues with '.'.
Paul
P.S. Your regexp doesn't do what you think it does, but I know what you mean.
Re: [Qemu-devel] [PATCH] qdev: Reject duplicate and anti-social device IDs
Quoted 10 lines · Paul Brook
Quoted 10 lines
Quoted 5 lines · Paul Brook
Quoted 2 lines
Also require IDs to start with a letter to provide for possible future extensions.
I'd go further than that, and require that user specified IDs match [A-Za-z][A-Za-z0-9_-]*
I talked with Dan (cc'ed) to make sure we don't trample on existing libvirt usage without need. What about
Quoted 7 lines
Quoted 3 lines
[A-Za-z][A-Za-z0-9_-:.]*
i.e. your regexp plus ':' and '.' in the second bracket?
I was deliberately avoiding those as they're often used as separators - we already use ':' in other contexts so there's potential ambiguity and parsing/quoting issues. I'm not aware of any current issues with '.'.
I checked with Dan, and we can outlaw ':'. I just posted a new patch that covers all qemu-option IDs, not just qdev.
[...]