Skip to contentSkip to conversation

Basic device state visualization

PATCH Superseded Jan Kiszka 9 participants 53 messages May 22, 2010 – May 31, 2010 Kbuild

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
author
#1 lore raw

PATCH v2 1/15 Add dependency of JSON unit tests on config-host.h

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

---
 Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Makefile +2 -0
index 110698e..aa81d9b 100644
@@ -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
author
#2 lore raw

PATCH v2 2/15 qdev: Fix scanning across single-bus devices

In reply to Jan Kiszka

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
index f252c8e..9ac1fa1 100644
@@ -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
index aa2ce01..2e50531 100644
@@ -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
author
#6 lore raw

PATCH v2 3/15 qdev: Allow device addressing via 'driver.instance'

In reply to Jan Kiszka

From: 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 |   12 +++++++++++-
 hw/qdev.c                |   23 ++++++++++++++++++-----
 2 files changed, 29 insertions(+), 6 deletions(-)
docs/qdev-device-use.txt +11 -1
index 9ac1fa1..5939481 100644
@@ -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,16 @@ 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]
+
+Example: /i440FX-pcihost/pci.0/e1000.2 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
index 2e50531..6b4a629 100644
@@ -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
author
#10 lore raw

PATCH v2 4/15 qdev: Convert device and bus lists to QTAILQ

In reply to Jan Kiszka

From: 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
index 0fce958..3cb3d11 100644
@@ -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
index bee8e88..61ab6fa 100644
@@ -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
index cc45c50..a226d3c 100644
@@ -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
index a44060e..53f5565 100644
@@ -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
index cfe7c07..2c18436 100644
@@ -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
author
#12 lore raw

PATCH v2 6/15 qdev: Push QMP mode checks into qbus_list_bus/dev

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

Simplifies the usage.

---
 hw/qdev.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
hw/qdev.c +10 -12
index fa611a1..db005ce 100644
@@ -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;
         }
     }
@@ -697,9 +697,7 @@ static DeviceState *qdev_find(const char *path)
     dev = qbus_find_dev(bus, dev_name);
     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
author
#11 lore raw

PATCH v2 5/15 qdev: Allow device specification by qtree path for device_del

In reply to Jan Kiszka

From: 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 searching for device IDs with walking the qtree when required.

---
 hw/qdev.c       |   46 ++++++++++++++++++++++++++++++++++++++++++----
 qemu-monitor.hx |   10 +++++-----
 2 files changed, 47 insertions(+), 9 deletions(-)
hw/qdev.c +42 -4
index 6d55e50..fa611a1 100644
@@ -666,6 +666,44 @@ 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 = qdev_find_recursive(bus, path);
+        if (dev) {
+            return dev;
+        }
+        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) {
+        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 +862,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
index c8f1789..754d71e 100644
@@ -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
author
#13 lore raw

PATCH v2 7/15 monitor: Add completion for qdev paths

In reply to Jan Kiszka

From: 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
index db005ce..7db839f 100644
@@ -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;
@@ -686,7 +701,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) {
@@ -695,13 +710,18 @@ static DeviceState *qdev_find(const char *path)
         }
     }
     dev = qbus_find_dev(bus, dev_name);
-    if (!dev) {
+    if (!dev && report_errors) {
         qerror_report(QERR_DEVICE_NOT_FOUND, dev_name);
         qbus_list_dev(bus);
     }
     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)
 {
@@ -863,7 +883,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
index 53f5565..b27d33b 100644
@@ -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
index 754d71e..eb257a6 100644
@@ -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
author
#14 lore raw

PATCH v2 8/15 Add base64 encoder/decoder

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

Will be used by QBuffer.

---
 Makefile.objs |    2 +-
 base64.c      |  202 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 base64.h      |   18 +++++
 3 files changed, 221 insertions(+), 1 deletions(-)
 create mode 100644 base64.c
 create mode 100644 base64.h
Makefile.objs +1 -1
index acbaf22..2c603b2 100644
@@ -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 +18 -0
new file mode 100644
index 0000000..9a0e03a
@@ -0,0 +1,18 @@
+/*
+ * 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 <unistd.h>
+
+void base64_encode(const void *src, size_t srclen, char *dest);
+int base64_decode(const char *src, size_t srclen, void *dest);
Signature · 1 line
1.6.0.2

Jan Kiszka

author
#0 lore raw

v2 cover Basic device state visualization

Here is version 2 of the device_show patch series. It currently has some dependencies on recently posted doc changes / enhancements, namely:
- http://thread.gmane.org/gmane.comp.emulators.qemu/70673
([PATCH v3 0/3]: QMP: Commands doc)
- http://thread.gmane.org/gmane.comp.emulators.qemu/70756
([PATCH 1/7] QMP: Add "Downstream extension of QMP" to spec)

Major changes in v2 are:
- command line completion for device tree paths
- introduced complex object classes ("__class__") and applied that on buffers
- documentation
- applied new qdev path specification also on device_del
- proper qdev device/bus sorting via QTAILQ (instead of QLIST_INSERT_TAIL)
- added QERR_DEVICE_NO_STATE
- fixed various bugs
- <things I forgot>

For reference, the series is also available at

git://git.kiszka.org/qemu.git queues/device-show

Thanks for all comments so far!

Jan Kiszka (15):
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: 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: 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                 |   18 ++
 check-qbuffer.c          |  172 +++++++++++++++++++
 configure                |    2 +-
 docs/qdev-device-use.txt |   16 ++-
 hw/acpi_piix4.c          |    2 +-
 hw/hw.h                  |    2 +
 hw/i2c.c                 |    2 +-
 hw/pci-hotplug.c         |    2 +-
 hw/qdev.c                |  408 +++++++++++++++++++++++++++++++++++++++++-----
 hw/qdev.h                |   12 +-
 hw/ssi.c                 |    6 +-
 monitor.c                |  108 +++++++++++-
 monitor.h                |    4 +-
 qbuffer.c                |  116 +++++++++++++
 qbuffer.h                |   33 ++++
 qemu-monitor.hx          |   74 ++++++++-
 qemu-tool.c              |    6 +-
 qerror.c                 |    4 +
 qerror.h                 |    3 +
 qjson.c                  |   15 ++
 qobject.h                |    1 +
 28 files changed, 1193 insertions(+), 79 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
author
#21 lore raw

PATCH v2 11/15 monitor: return length of printed string via monitor_[v]printf

From: 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
index 64de10a..6766e49 100644
@@ -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
index ea15469..32c0170 100644
@@ -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
index b39af86..f6ce6cd 100644
@@ -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
author
#19 lore raw

PATCH v2 9/15 QMP: Reserve namespace for complex object classes

In reply to Jan Kiszka

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.

---
 QMP/qmp-spec.txt |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
QMP/qmp-spec.txt +13 -3
index 9d30a8c..fa1dd62 100644
@@ -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
author
#20 lore raw

PATCH v2 10/15 Add QBuffer

In reply to Jan Kiszka

From: 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
index aa81d9b..9c226ae 100644
@@ -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
index 2c603b2..d556806 100644
@@ -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
index fa1dd62..820e39d 100644
@@ -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
index 653c8d2..1c5c0f9 100755
@@ -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
new file mode 100644
index 0000000..2e01078
@@ -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
index 483c667..419b4e7 100644
@@ -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
index 07de211..45c4fa0 100644
@@ -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
author
#22 lore raw

PATCH v2 12/15 monitor: Add basic device state visualization

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

This introduces device_show, a monitor command that saves the vmstate of a qdev device and visualizes it. QMP is also supported. 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. And it comes with documentation.

---
 hw/hw.h         |    2 +
 hw/qdev.c       |  244 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/qdev.h       |    2 +
 qemu-monitor.hx |   64 +++++++++++++++
 qerror.c        |    4 +
 qerror.h        |    3 +
 6 files changed, 319 insertions(+), 0 deletions(-)
hw/hw.h +2 -0
index fc2d184..cc4bd5f 100644
@@ -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 +244 -0

253 lines not on this page · raw message

hw/qdev.h +2 -0
index b27d33b..447d13c 100644
@@ -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 +64 -0

70 lines not on this page · raw message

qerror.c +4 -0
index 034c7de..c50ff91 100644
@@ -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
index c98c61a..e5de6dd 100644
@@ -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
author
#50 lore raw

PATCH v2 15/15 QMP: Add support for buffer class to qmp python helper

In reply to Jan Kiszka

From: 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
index 4062f84..67ca8b9 100644
@@ -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) - 1):
+            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
author
#49 lore raw

PATCH v2 14/15 QMP: Fix python helper /wrt long return strings

In reply to Jan Kiszka

From: 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
index d9da603..4062f84 100644
@@ -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
author
#48 lore raw

PATCH v2 13/15 QMP: Teach basic capability negotiation to python example

In reply to Jan Kiszka

From: 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
index f89b9af..a5b72d1 100755
@@ -42,6 +42,7 @@ def main():
 
     qemu = qmp.QEMUMonitorProtocol(argv[1])
     qemu.connect()
+    qemu.send("qmp_capabilities")
 
     print 'Connected!'
 
QMP/vm-info +1 -0
index b150d82..d29e7f5 100755
@@ -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
#15 lore raw

Re: [Qemu-devel] [PATCH v2 08/15] Add base64 encoder/decoder

In reply to Jan Kiszka
Quoted 37 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Will be used by QBuffer.

---
 Makefile.objs |    2 +-
 base64.c      |  202 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ base64.h      |   18 +++++

 3 files changed, 221 insertions(+), 1 deletions(-)

 create mode 100644 base64.c
 create mode 100644 base64.h

Makefile.objs +0 -0
index acbaf22..2c603b2 100644
@@ -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

Makefile.objs +1 -1
-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 +5 -0
new file mode 100644
index 0000000..543e8c6
@@ -0,0 +1,202 @@
+/*
+ * Base64 encoder/decoder conforming to RFC 4648
+ * (based on Mozilla's nsprpub/lib/libc/src/base64.c)
+ *
+ * Copyright (C) 2010 Siemens AG

base64.c line 15

Quoted 10 lines
base64.c new file +10 -0
+ *
+ * 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"

Why not <inttypes.h>?

Quoted 153 lines
base64.c new file +153 -0
+#include "base64.h"
+
+static const char base[] =
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+static void encode3to4(const char *src, char *dest)
+{
+    uint32_t b32 = 0;
+    int i, j = 18;
+
+    for (i = 0; i < 3; i++) {
+        b32 <<= 8;
+        b32 |= src[i];
+    }
+    for (i = 0; i < 4; i++) {
+        dest[i] = base[(b32 >> j) & 0x3F];
+        j -= 6;
+    }
+}
+
+static void encode2to4(const char *src, char *dest)
+{
+    dest[0] = base[(src[0] >> 2) & 0x3F];
+    dest[1] = base[((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0F)];
+    dest[2] = base[(src[1] & 0x0F) << 2];
+    dest[3] = '=';
+}
+
+static void encode1to4(const char *src, char *dest)
+{
+    dest[0] = base[(src[0] >> 2) & 0x3F];
+    dest[1] = base[(src[0] & 0x03) << 4];
+    dest[2] = '=';
+    dest[3] = '=';
+}
+
+/*
+ * Encode data in 'src' of length 'srclen' to a base64 string, saving the
+ * null-terminated result in 'dest'. The size of the destition buffer must be
+ * at least ((srclen + 2) / 3) * 4 + 1.
+ */
+void base64_encode(const void *src, size_t srclen, char *dest)
+{
+    while (srclen >= 3) {
+        encode3to4(src, dest);
+        src += 3;
+        dest += 4;
+        srclen -= 3;
+    }
+    switch (srclen) {
+    case 2:
+        encode2to4(src, dest);
+        dest += 4;
+        break;
+    case 1:
+        encode1to4(src, dest);
+        dest += 4;
+        break;
+    case 0:
+        break;
+    }
+    dest[0] = 0;
+}
+
+static int32_t codetovalue(char c)
+{
+    if (c >= 'A' && c <= 'Z') {
+        return c - 'A';
+    } else if (c >= 'a' && c <= 'z') {
+        return c - 'a' + 26;
+    } else if (c >= '0' && c <= '9') {
+        return c - '0' + 52;
+    } else if (c == '+') {
+        return 62;
+    } else if ( c == '/') {
+        return 63;
+    } else {
+        return -1;
+    }
+}
+
+static int decode4to3 (const char *src, char *dest)
+{
+    uint32_t b32 = 0;
+    int32_t bits;
+    int i;
+
+    for (i = 0; i < 4; i++) {
+        bits = codetovalue(src[i]);
+        if (bits < 0) {
+            return bits;
+        }
+        b32 <<= 6;
+        b32 |= bits;
+    }
+    dest[0] = (b32 >> 16) & 0xFF;
+    dest[1] = (b32 >> 8) & 0xFF;
+    dest[2] = b32 & 0xFF;
+
+    return 0;
+}
+
+static int decode3to2(const char *src, char *dest)
+{
+    uint32_t b32 = 0;
+    int32_t bits;
+
+    bits = codetovalue(src[0]);
+    if (bits < 0) {
+        return bits;
+    }
+    b32 = (uint32_t)bits;
+    b32 <<= 6;
+
+    bits = codetovalue(src[1]);
+    if (bits < 0) {
+        return bits;
+    }
+    b32 |= (uint32_t)bits;
+    b32 <<= 4;
+
+    bits = codetovalue(src[2]);
+    if (bits < 0) {
+        return bits;
+    }
+    b32 |= ((uint32_t)bits) >> 2;
+
+    dest[0] = (b32 >> 8) & 0xFF;
+    dest[1] = b32 & 0xFF;
+
+    return 0;
+}
+
+static int decode2to1(const char *src, char *dest)
+{
+    uint32_t b32;
+    int32_t bits;
+
+    bits = codetovalue(src[0]);
+    if (bits < 0) {
+        return bits;
+    }
+    b32 = (uint32_t)bits << 2;
+
+    bits = codetovalue(src[1]);
+    if (bits < 0) {
+        return bits;
+    }
+    b32 |= ((uint32_t)bits) >> 4;
+
+    dest[0] = b32;
+
+    return 0;

base64.c line 178

Quoted 10 lines
base64.c new file +10 -0
+}
+
+/*
+ * Convert string 'src' of length 'srclen' from base64 to binary form,
+ * saving the result in 'dest'. The size of the destination buffer must be at
+ * least srclen * 3 / 4.
+ *
+ * Returns 0 on success, -1 on conversion error.
+ */
+int base64_decode(const char *src, size_t srclen, void *dest)

I think dest should be char *, like all the functions where dest is passed to.

Quoted 35 lines
base64.c new file +24 -0
+{
+    int ret;
+
+    while (srclen >= 4) {
+        ret = decode4to3(src, dest);
+        if (ret < 0) {
+            return ret;
+        }
+        src += 4;
+        dest += 3;
+        srclen -= 4;
+    }
+
+    switch (srclen) {
+    case 3:
+        return decode3to2(src, dest);
+    case 2:
+        return decode2to1(src, dest);
+    case 1:
+        return -1;
+    default: /* 0 */
+        return 0;
+    }
+}
base64.h new file +5 -0
new file mode 100644
index 0000000..9a0e03a
@@ -0,0 +1,18 @@
+/*
+ * Base64 encoder/decoder conforming to RFC 4648
+ * (based on Mozilla's nsprpub/lib/libc/src/base64.c)
+ *
+ * Copyright (C) 2010 Siemens AG

base64.h line 15

Quoted 10 lines
base64.h new file +10 -0
+ *
+ * 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 <unistd.h>

Maybe <stddef.h> instead, it's only for size_t?

Quoted 8 lines
base64.h new file +3 -1
+
+void base64_encode(const void *src, size_t srclen, char *dest);
+int base64_decode(const char *src, size_t srclen, void *dest);
--

1.6.0.2

#51 lore raw
In reply to Jan Kiszka
Quoted 6 lines · Jan Kiszka

Here is version 2 of the device_show patch series. It currently has some dependencies on recently posted doc changes / enhancements, namely:
 - http://thread.gmane.org/gmane.comp.emulators.qemu/70673
  ([PATCH v3 0/3]: QMP: Commands doc)
 - http://thread.gmane.org/gmane.comp.emulators.qemu/70756
  ([PATCH 1/7] QMP: Add "Downstream extension of QMP" to spec)

I had minor comments to 8/15, otherwise looks good.

Quoted 72 lines

Major changes in v2 are:
 - command line completion for device tree paths
 - introduced complex object classes ("__class__") and applied that on buffers
 - documentation
 - applied new qdev path specification also on device_del
 - proper qdev device/bus sorting via QTAILQ (instead of QLIST_INSERT_TAIL)
 - added QERR_DEVICE_NO_STATE
 - fixed various bugs
 - <things I forgot>

For reference, the series is also available at

       git://git.kiszka.org/qemu.git queues/device-show

Thanks for all comments so far!

Jan Kiszka (15):
 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: 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: 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                 |   18 ++ check-qbuffer.c          |  172 +++++++++++++++++++ configure                |    2 +- docs/qdev-device-use.txt |   16 ++- hw/acpi_piix4.c          |    2 +-
 hw/hw.h                  |    2 +
 hw/i2c.c                 |    2 +- hw/pci-hotplug.c         |    2 +-

 hw/qdev.c                |  408 +++++++++++++++++++++++++++++++++++++++++-----
 hw/qdev.h                |   12 +-
 hw/ssi.c                 |    6 +-
 monitor.c                |  108 +++++++++++-
 monitor.h                |    4 +-
 qbuffer.c                |  116 +++++++++++++
 qbuffer.h                |   33 ++++

 qemu-monitor.hx          |   74 ++++++++-
 qemu-tool.c              |    6 +-
 qerror.c                 |    4 +
 qerror.h                 |    3 +
 qjson.c                  |   15 ++
 qobject.h                |    1 +

 28 files changed, 1193 insertions(+), 79 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

#23 lore raw

[Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Jan Kiszka
Quoted 10 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

This introduces device_show, a monitor command that saves the vmstate of a qdev device and visualizes it. QMP is also supported. 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. And it comes with documentation.

qemu-monitor.hx Example: · line 762

Quoted 7 lines
qemu-monitor.hx +7 -0
+
+Dump a snapshot of the device state. Buffers are cut after 16 bytes unless
+a full dump is requested.
+
+Arguments:
+
+- "path": the device's qtree path or unique ID (json-string)

This may be ambiguous.

Quoted 2 lines

+- "full": report full state (json-bool, optional)

Is this needed for QMP? The client can always truncate it to any length.

qemu-monitor.hx Example: · line 775

Quoted 13 lines
qemu-monitor.hx +12 -0
+
+Schema of returned object:
+
+{ "device": json-string, "id": json-string, "fields" : [ field-objects ] }
+
+The field object array may be empty, otherwise it consists of
+
+{ "name": json-string, "size": json-int, "elems": [ element-objects ] }
+
+"size" describes the real number of bytes required for a binary representation
+of a single field element in the array. The actually transfered amount may be
+smaller unless a full dump was requested.

This converts the entire qdev tree into an undocumented stable protocol (the qdev paths were already in this state I believe). This really worries me.

Quoted 14 lines
qemu-monitor.hx +13 -0
+
+The element object array may be empty, otherwise it can contain
+
+- json-int objects
+- QMP buffer objects
+- field objects
+- arrays of json-ints, QMP buffers, or field objects
+
+Example:
+
+->  { "execute": "device_show", "arguments": { "path": "isa.0/i8042" } }
+<- { "return": { "device": "i8042", "id": "", "fields":
+                 [ { "name": "kbd", "size": 4, "elems":

qemu-monitor.hx Example: · line 798

Quoted 10 lines
qemu-monitor.hx +10 -0
+                     [ { "name": "write_cmd", "size": 1, "elems": [0] },
+                       { "name": "status", "size": 1, "elems": [25] },
+                       { "name": "mode", "size": 1, "elems": [3] },
+                       { "name": "pending", "size": 1, "elems": [1] }
+                     ] }
+                 ]
+               }
+   }
+
+EQMP

Looks good. I am only worried about long term stability and documentation.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
author
#16 lore raw

Re: [Qemu-devel] [PATCH v2 08/15] Add base64 encoder/decoder

In reply to Blue Swirl
Quoted 42 lines · Blue Swirl
Quoted 41 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Will be used by QBuffer.

---
 Makefile.objs |    2 +-
 base64.c      |  202 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 base64.h      |   18 +++++
 3 files changed, 221 insertions(+), 1 deletions(-)
 create mode 100644 base64.c
 create mode 100644 base64.h
Makefile.objs +1 -1
index acbaf22..2c603b2 100644
@@ -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 +9 -0
new file mode 100644
index 0000000..543e8c6
@@ -0,0 +1,202 @@
+/*
+ * 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]>
+ *
Quoted 8 lines

base64.c line 15

Quoted 6 lines
base64.c new file +6 -0
+ * 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"

Why not <inttypes.h>?

Oops, no intention.

Quoted 158 lines
Quoted 158 lines
base64.c new file +157 -0
+#include "base64.h"
+
+static const char base[] =
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+static void encode3to4(const char *src, char *dest)
+{
+    uint32_t b32 = 0;
+    int i, j = 18;
+
+    for (i = 0; i < 3; i++) {
+        b32 <<= 8;
+        b32 |= src[i];
+    }
+    for (i = 0; i < 4; i++) {
+        dest[i] = base[(b32 >> j) & 0x3F];
+        j -= 6;
+    }
+}
+
+static void encode2to4(const char *src, char *dest)
+{
+    dest[0] = base[(src[0] >> 2) & 0x3F];
+    dest[1] = base[((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0F)];
+    dest[2] = base[(src[1] & 0x0F) << 2];
+    dest[3] = '=';
+}
+
+static void encode1to4(const char *src, char *dest)
+{
+    dest[0] = base[(src[0] >> 2) & 0x3F];
+    dest[1] = base[(src[0] & 0x03) << 4];
+    dest[2] = '=';
+    dest[3] = '=';
+}
+
+/*
+ * Encode data in 'src' of length 'srclen' to a base64 string, saving the
+ * null-terminated result in 'dest'. The size of the destition buffer must be
+ * at least ((srclen + 2) / 3) * 4 + 1.
+ */
+void base64_encode(const void *src, size_t srclen, char *dest)
+{
+    while (srclen >= 3) {
+        encode3to4(src, dest);
+        src += 3;
+        dest += 4;
+        srclen -= 3;
+    }
+    switch (srclen) {
+    case 2:
+        encode2to4(src, dest);
+        dest += 4;
+        break;
+    case 1:
+        encode1to4(src, dest);
+        dest += 4;
+        break;
+    case 0:
+        break;
+    }
+    dest[0] = 0;
+}
+
+static int32_t codetovalue(char c)
+{
+    if (c >= 'A' && c <= 'Z') {
+        return c - 'A';
+    } else if (c >= 'a' && c <= 'z') {
+        return c - 'a' + 26;
+    } else if (c >= '0' && c <= '9') {
+        return c - '0' + 52;
+    } else if (c == '+') {
+        return 62;
+    } else if ( c == '/') {
+        return 63;
+    } else {
+        return -1;
+    }
+}
+
+static int decode4to3 (const char *src, char *dest)
+{
+    uint32_t b32 = 0;
+    int32_t bits;
+    int i;
+
+    for (i = 0; i < 4; i++) {
+        bits = codetovalue(src[i]);
+        if (bits < 0) {
+            return bits;
+        }
+        b32 <<= 6;
+        b32 |= bits;
+    }
+    dest[0] = (b32 >> 16) & 0xFF;
+    dest[1] = (b32 >> 8) & 0xFF;
+    dest[2] = b32 & 0xFF;
+
+    return 0;
+}
+
+static int decode3to2(const char *src, char *dest)
+{
+    uint32_t b32 = 0;
+    int32_t bits;
+
+    bits = codetovalue(src[0]);
+    if (bits < 0) {
+        return bits;
+    }
+    b32 = (uint32_t)bits;
+    b32 <<= 6;
+
+    bits = codetovalue(src[1]);
+    if (bits < 0) {
+        return bits;
+    }
+    b32 |= (uint32_t)bits;
+    b32 <<= 4;
+
+    bits = codetovalue(src[2]);
+    if (bits < 0) {
+        return bits;
+    }
+    b32 |= ((uint32_t)bits) >> 2;
+
+    dest[0] = (b32 >> 8) & 0xFF;
+    dest[1] = b32 & 0xFF;
+
+    return 0;
+}
+
+static int decode2to1(const char *src, char *dest)
+{
+    uint32_t b32;
+    int32_t bits;
+
+    bits = codetovalue(src[0]);
+    if (bits < 0) {
+        return bits;
+    }
+    b32 = (uint32_t)bits << 2;
+
+    bits = codetovalue(src[1]);
+    if (bits < 0) {
+        return bits;
+    }
+    b32 |= ((uint32_t)bits) >> 4;
+
+    dest[0] = b32;
+
+    return 0;
+}
+
+/*
+ * Convert string 'src' of length 'srclen' from base64 to binary form,
Quoted 8 lines

base64.c line 178

Quoted 6 lines
base64.c new file +6 -0
+ * saving the result in 'dest'. The size of the destination buffer must be at
+ * least srclen * 3 / 4.
+ *
+ * Returns 0 on success, -1 on conversion error.
+ */
+int base64_decode(const char *src, size_t srclen, void *dest)

I think dest should be char *, like all the functions where dest is passed to.

The output may but need not be a string, it's binary data. And to avoid needless warnings about signedness mismatches if unsigned char or uint8_t buffers are passed, I chose void *.

Quoted 40 lines
Quoted 40 lines
base64.c new file +24 -0
+{
+    int ret;
+
+    while (srclen >= 4) {
+        ret = decode4to3(src, dest);
+        if (ret < 0) {
+            return ret;
+        }
+        src += 4;
+        dest += 3;
+        srclen -= 4;
+    }
+
+    switch (srclen) {
+    case 3:
+        return decode3to2(src, dest);
+    case 2:
+        return decode2to1(src, dest);
+    case 1:
+        return -1;
+    default: /* 0 */
+        return 0;
+    }
+}
base64.h new file +9 -0
new file mode 100644
index 0000000..9a0e03a
@@ -0,0 +1,18 @@
+/*
+ * 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]>
+ *
Quoted 8 lines

base64.h line 15

Quoted 6 lines
base64.h new file +6 -0
+ * 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 <unistd.h>

Maybe <stddef.h> instead, it's only for size_t?

Makes sense.

Quoted 9 lines
Quoted 9 lines
base64.h new file +3 -1
+
+void base64_encode(const void *src, size_t srclen, char *dest);
+int base64_decode(const char *src, size_t srclen, void *dest);
--

1.6.0.2

Thanks,
Jan

author
#52 lore raw
In reply to Blue Swirl
Quoted 9 lines · Blue Swirl
Quoted 6 lines · Jan Kiszka

Here is version 2 of the device_show patch series. It currently has some dependencies on recently posted doc changes / enhancements, namely:
- http://thread.gmane.org/gmane.comp.emulators.qemu/70673
([PATCH v3 0/3]: QMP: Commands doc)
- http://thread.gmane.org/gmane.comp.emulators.qemu/70756
([PATCH 1/7] QMP: Add "Downstream extension of QMP" to spec)

I had minor comments to 8/15, otherwise looks good.

Great. I will follow up on that patch or incorporate those bits in a potential third run.

Thanks again - and sorry for forgetting to CC you, Jan

author
#24 lore raw

[Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Avi Kivity
Quoted 10 lines · Avi Kivity
Quoted 9 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

This introduces device_show, a monitor command that saves the vmstate of a qdev device and visualizes it. QMP is also supported. 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. And it comes with documentation.

Quoted 11 lines

qemu-monitor.hx Example: · line 762

Quoted 9 lines
(quoted diff) +2 -0
+
+Dump a snapshot of the device state. Buffers are cut after 16 bytes

unless

qemu-monitor.hx +5 -0
+a full dump is requested.
+
+Arguments:
+
+- "path": the device's qtree path or unique ID (json-string)

This may be ambiguous.

Can your elaborate what precisely is ambiguous?

Quoted 5 lines
Quoted 3 lines

+- "full": report full state (json-bool, optional)

Is this needed for QMP? The client can always truncate it to any length.

The effect may not be needed for QMP, but I do need this channel from the command line to the monitor pretty-printer. I could just stick "full": json-bool back into the return dict, but that would look somehow strange IMO.

Quoted 13 lines
Quoted 13 lines
qemu-monitor.hx +4 -0
+
+Schema of returned object:
+
+{ "device": json-string, "id": json-string, "fields" : [

field-objects ] }

qemu-monitor.hx +6 -0
+
+The field object array may be empty, otherwise it consists of
+
+{ "name": json-string, "size": json-int, "elems": [ element-objects ] }
+
+"size" describes the real number of bytes required for a binary

representation

Quoted 8 lines
Quoted 4 lines

+of a single field element in the array. The actually transfered amount may be
+smaller unless a full dump was requested.

This converts the entire qdev tree into an undocumented stable protocol (the qdev paths were already in this state I believe). This really worries me.

Being primarily a debugging tool, device_show exports the entire (qdev'ified) vmstates via QMP. Unlike the migration protocol, it does not provide something like backward compatibility. This would be overkill for the intended purpose (though someone may find a different use case one day).

I think we have the following options:
- disable device_show via QMP, limit it to the monitor console
- declare its output inherently unstable, maybe at least adding the vmstate version to each device so that potential QMP consumers notice that they may have to update their tools or switch to a different processing function

Given that vmstate annotations will most probably require some work on the output structure (and I don't have a QMP use case ATM anyway), I would be fine with the first option for now. Still, I don't think we will ever get beyond the second option because this service is tight to some internals of QEMU we don't want to freeze.

Quoted 19 lines
Quoted 19 lines
qemu-monitor.hx +18 -0
+
+The element object array may be empty, otherwise it can contain
+
+- json-int objects
+- QMP buffer objects
+- field objects
+- arrays of json-ints, QMP buffers, or field objects
+
+Example:
+
+->  { "execute": "device_show", "arguments": { "path": "isa.0/i8042" } }
+<- { "return": { "device": "i8042", "id": "", "fields":
+                 [ { "name": "kbd", "size": 4, "elems":
+                     [ { "name": "write_cmd", "size": 1, "elems": [0] },
+                       { "name": "status", "size": 1, "elems": [25] },
+                       { "name": "mode", "size": 1, "elems": [3] },
+                       { "name": "pending", "size": 1, "elems": [1] }
+                     ] }
Quoted 9 lines

qemu-monitor.hx Example: · line 798

Quoted 6 lines
qemu-monitor.hx +5 -0
+                 ]
+               }
+   }
+
+EQMP

Looks good. I am only worried about long term stability and documentation.

Thanks,
Jan

#25 lore raw

[Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 25 lines · Jan Kiszka
Quoted 11 lines · Avi Kivity
Quoted 9 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

This introduces device_show, a monitor command that saves the vmstate of a qdev device and visualizes it. QMP is also supported. 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. And it comes with documentation.

Quoted 12 lines

qemu-monitor.hx Example: · line 762

Quoted 10 lines
(quoted diff) +2 -0
+
+Dump a snapshot of the device state. Buffers are cut after 16 bytes

unless

qemu-monitor.hx +5 -0
+a full dump is requested.
+
+Arguments:
+
+- "path": the device's qtree path or unique ID (json-string)

This may be ambiguous.

Quoted 2 lines

Can your elaborate what precisely is ambiguous?

Can't the user choose the unique ID so that it aliases an unrelated qtree path?

I prefer having mutually exclusive 'path' and 'ref' arguments.

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

+- "full": report full state (json-bool, optional)

Is this needed for QMP? The client can always truncate it to any length.

The effect may not be needed for QMP, but I do need this channel from the command line to the monitor pretty-printer. I could just stick "full": json-bool back into the return dict, but that would look somehow strange IMO.

So we could disallow it as a QMP input, but allow it as an HMP input.

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
qemu-monitor.hx +4 -0
+
+Schema of returned object:
+
+{ "device": json-string, "id": json-string, "fields" : [

field-objects ] }

qemu-monitor.hx +6 -0
+
+The field object array may be empty, otherwise it consists of
+
+{ "name": json-string, "size": json-int, "elems": [ element-objects ] }
+
+"size" describes the real number of bytes required for a binary

representation

Quoted 9 lines
Quoted 5 lines

+of a single field element in the array. The actually transfered amount may be
+smaller unless a full dump was requested.

This converts the entire qdev tree into an undocumented stable protocol (the qdev paths were already in this state I believe). This really worries me.

Quoted 3 lines

Being primarily a debugging tool, device_show exports the entire (qdev'ified) vmstates via QMP. Unlike the migration protocol, it does not provide something like backward compatibility.

Should be explicitly documented. All QMP commands should be backwards and forwards compatible unless noted.

Quoted 4 lines

This would be
overkill for the intended purpose (though someone may find a different use case one day).

Even for simply showing things, a GUI may depend on the presence of certain fields. If we document that the fields may change, a correctly written GUI can fall back to a simpler display.

Quoted 7 lines

I think we have the following options:
- disable device_show via QMP, limit it to the monitor console
- declare its output inherently unstable, maybe at least adding the vmstate version to each device so that potential QMP consumers notice that they may have to update their tools or switch to a different processing function

Quoted 6 lines

Given that vmstate annotations will most probably require some work on the output structure (and I don't have a QMP use case ATM anyway), I would be fine with the first option for now. Still, I don't think we will ever get beyond the second option because this service is tight to some internals of QEMU we don't want to freeze.

I agree. This feature is very useful as a debugging aid, and as I don't think we'll have debugging GUIs any time soon, it's better to defer the problem until we really need to solve it.

Signature · 1 line
error compiling committee.c: too many arguments to function
#17 lore raw

Re: [Qemu-devel] [PATCH v2 08/15] Add base64 encoder/decoder

In reply to Jan Kiszka
Quoted 11 lines · Jan Kiszka
Quoted 11 lines

base64.c line 178

Quoted 9 lines
base64.c new file +8 -0
+/*
+ * Convert string 'src' of length 'srclen' from base64 to binary form,
+ * saving the result in 'dest'. The size of the destination buffer must be at
+ * least srclen * 3 / 4.
+ *
+ * Returns 0 on success, -1 on conversion error.
+ */
+int base64_decode(const char *src, size_t srclen, void *dest)

I think dest should be char *, like all the functions where dest is passed to.

Quoted 4 lines

The output may but need not be a string, it's binary data. And to avoid needless warnings about signedness mismatches if unsigned char or uint8_t buffers are passed, I chose void *.

I think qemu is pretty consistent in using uint8_t for binary, and void * is a little dangerous as it allows passing any kind of data (anything above a byte is subject to endianness issues for example).

But I don't feel strongly about this.

Signature · 1 line
error compiling committee.c: too many arguments to function
author
#26 lore raw

[Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Avi Kivity
Quoted 28 lines · Avi Kivity
Quoted 27 lines · Jan Kiszka
Quoted 25 lines · Avi Kivity
Quoted 16 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

This introduces device_show, a monitor command that saves the vmstate of
a qdev device and visualizes it. QMP is also supported. 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. And it comes with documentation.

(quoted diff) +2 -0
+
+Dump a snapshot of the device state. Buffers are cut after 16 bytes

unless

qemu-monitor.hx Example: · line 762

Quoted 5 lines
qemu-monitor.hx +5 -0
+a full dump is requested.
+
+Arguments:
+
+- "path": the device's qtree path or unique ID (json-string)

This may be ambiguous.

Quoted 5 lines
Quoted 2 lines

Can your elaborate what precisely is ambiguous?

Can't the user choose the unique ID so that it aliases an unrelated qtree path?

True. I'll swap the search order and document this. Qtree paths should always rule.

Quoted 2 lines

I prefer having mutually exclusive 'path' and 'ref' arguments.

That would be unhandy.

Quoted 67 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+- "full": report full state (json-bool, optional)

Quoted 8 lines
Quoted 3 lines

Is this needed for QMP? The client can always truncate it to any length.

The effect may not be needed for QMP, but I do need this channel from the command line to the monitor pretty-printer. I could just stick "full": json-bool back into the return dict, but that would look somehow strange IMO.

So we could disallow it as a QMP input, but allow it as an HMP input.

Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
qemu-monitor.hx +4 -0
+
+Schema of returned object:
+
+{ "device": json-string, "id": json-string, "fields" : [

field-objects ] }

qemu-monitor.hx +4 -0
+
+The field object array may be empty, otherwise it consists of
+
+{ "name": json-string, "size": json-int, "elems": [ element-objects

] }
+
+"size" describes the real number of bytes required for a binary representation

Quoted 9 lines
Quoted 5 lines

+of a single field element in the array. The actually transfered amount may be
+smaller unless a full dump was requested.

This converts the entire qdev tree into an undocumented stable protocol (the qdev paths were already in this state I believe). This really worries me.

Quoted 3 lines

Being primarily a debugging tool, device_show exports the entire (qdev'ified) vmstates via QMP. Unlike the migration protocol, it does not provide something like backward compatibility.

Should be explicitly documented. All QMP commands should be backwards and forwards compatible unless noted.

Quoted 4 lines

This would be
overkill for the intended purpose (though someone may find a different use case one day).

Even for simply showing things, a GUI may depend on the presence of certain fields. If we document that the fields may change, a correctly written GUI can fall back to a simpler display.

Quoted 7 lines

I think we have the following options:
- disable device_show via QMP, limit it to the monitor console
- declare its output inherently unstable, maybe at least adding the vmstate version to each device so that potential QMP consumers notice that they may have to update their tools or switch to a different processing function

Quoted 6 lines

Given that vmstate annotations will most probably require some work on the output structure (and I don't have a QMP use case ATM anyway), I would be fine with the first option for now. Still, I don't think we will ever get beyond the second option because this service is tight to some internals of QEMU we don't want to freeze.

Quoted 3 lines

I agree. This feature is very useful as a debugging aid, and as I don't think we'll have debugging GUIs any time soon, it's better to defer the problem until we really need to solve it.

I introduced .user_only as a monitor command tag and applied it on device_show. But I also added the vmstate version to the device output, maybe already helpful for users. All this will come with v3.

Jan

author
#18 lore raw

Re: [Qemu-devel] [PATCH v2 08/15] Add base64 encoder/decoder

In reply to Avi Kivity
Quoted 19 lines · Avi Kivity
Quoted 13 lines · Jan Kiszka
Quoted 4 lines
Quoted 4 lines

+/*
+ * Convert string 'src' of length 'srclen' from base64 to binary form,
+ * saving the result in 'dest'. The size of the destination buffer must be at

Quoted 9 lines
Quoted 6 lines

+ * least srclen * 3 / 4.
+ *
+ * Returns 0 on success, -1 on conversion error.
+ */
+int base64_decode(const char *src, size_t srclen, void *dest)

I think dest should be char *, like all the functions where dest is passed to.

Quoted 4 lines

The output may but need not be a string, it's binary data. And to avoid needless warnings about signedness mismatches if unsigned char or uint8_t buffers are passed, I chose void *.

Quoted 6 lines

I think qemu is pretty consistent in using uint8_t for binary, and void
* is a little dangerous as it allows passing any kind of data (anything above a byte is subject to endianness issues for example).

But I don't feel strongly about this.

Let's go for consistency: I switched to uint8_t for the binary input/output.

Jan

#27 lore raw

[Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Jan Kiszka
Quoted 10 lines · Jan Kiszka
Quoted 7 lines
Quoted 4 lines

Can your elaborate what precisely is ambiguous?

Can't the user choose the unique ID so that it aliases an unrelated qtree path?

True. I'll swap the search order and document this. Qtree paths should always rule.

Well, I guess the user could avoid ambiguity by avoiding /es.

Quoted 5 lines
Quoted 3 lines

I prefer having mutually exclusive 'path' and 'ref' arguments.

That would be unhandy.

Don't really see why.

Quoted 8 lines
Quoted 4 lines

I agree. This feature is very useful as a debugging aid, and as I don't think we'll have debugging GUIs any time soon, it's better to defer the problem until we really need to solve it.

I introduced .user_only as a monitor command tag and applied it on device_show. But I also added the vmstate version to the device output, maybe already helpful for users. All this will come with v3.

Thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function
#36 lore raw

[Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Jan Kiszka
Quoted 1 line · On Sun, 23 May 2010 09:57:43 +0200 Jan Kiszka <[email protected]> wrote:

Avi Kivity wrote:

[...]

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

+- "full": report full state (json-bool, optional)

Is this needed for QMP? The client can always truncate it to any length.

The effect may not be needed for QMP, but I do need this channel from the command line to the monitor pretty-printer. I could just stick "full": json-bool back into the return dict, but that would look somehow strange IMO.

We could have a form of optional key which is only present internally,
we have that async commands.

#37 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 15 lines · Luiz Capitulino
Quoted 2 lines · On Sun, 23 May 2010 09:57:43 +0200 Jan Kiszka<[email protected]> wrote:

Avi Kivity wrote:

[...]

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

+- "full": report full state (json-bool, optional)

Is this needed for QMP? The client can always truncate it to any length.

Quoted 8 lines
Quoted 5 lines

The effect may not be needed for QMP, but I do need this channel from the command line to the monitor pretty-printer. I could just stick "full": json-bool back into the return dict, but that would look somehow strange IMO.

We could have a form of optional key which is only present internally,
we have that async commands.

I'd rather see two separate commands with an internal mechanism to make direct QMP calls. The human monitor can be implemented in terms of the QMP call but it should be in terms of the human monitor invoking the QMP command such that it can munge the output as it sees appropriate.

Regards,

Anthony Liguori

#38 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Avi Kivity
Quoted 34 lines · Avi Kivity
Quoted 12 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

This introduces device_show, a monitor command that saves the vmstate of a qdev device and visualizes it. QMP is also supported. 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. And it comes with documentation.

(quoted diff) +2 -0
+
+Dump a snapshot of the device state. Buffers are cut after 16 bytes 

unless

qemu-monitor.hx Example: · line 762

Quoted 5 lines
qemu-monitor.hx +5 -0
+a full dump is requested.
+
+Arguments:
+
+- "path": the device's qtree path or unique ID (json-string)

This may be ambiguous.

Quoted 1 line

+- "full": report full state (json-bool, optional)

Is this needed for QMP? The client can always truncate it to any length.

Quoted 9 lines
qemu-monitor.hx +4 -0
+
+Schema of returned object:
+
+{ "device": json-string, "id": json-string, "fields" : [ 

field-objects ] }

qemu-monitor.hx +4 -0
+
+The field object array may be empty, otherwise it consists of
+
+{ "name": json-string, "size": json-int, "elems": [ element-objects ] }
Quoted 8 lines
Quoted 6 lines

+
+"size" describes the real number of bytes required for a binary representation
+of a single field element in the array. The actually transfered amount may be
+smaller unless a full dump was requested.

This converts the entire qdev tree into an undocumented stable protocol (the qdev paths were already in this state I believe). This really worries me.

N.B. the association with qdev is only in identifying the device. The contents of the device's state are not part of qdev but rather part of vmstate. vmstate is something that we already guarantee to be stable since that's required for live migration compatibility.

I don't think that qdev device names and paths are something we have to worry much about changing over time since they reflect logical bus layout. They should remain static provided the devices remain static.

The qdev properties are a different matter entirely. A command like 'info qdm' would be potentially difficult to support as part of QMP but the proposed command's output is actually already part of a backward compatible interface (vmstate).

Regards,

Anthony Liguori

Quoted 28 lines
Quoted 16 lines
qemu-monitor.hx +11 -0
+
+The element object array may be empty, otherwise it can contain
+
+- json-int objects
+- QMP buffer objects
+- field objects
+- arrays of json-ints, QMP buffers, or field objects
+
+Example:
+
+->  { "execute": "device_show", "arguments": { "path": "isa.0/i8042" 

} }
+<- { "return": { "device": "i8042", "id": "", "fields":

(quoted diff) +2 -0
+                 [ { "name": "kbd", "size": 4, "elems":
+                     [ { "name": "write_cmd", "size": 1, "elems": 

[0] },

qemu-monitor.hx Example: · line 798

Quoted 9 lines
qemu-monitor.hx +9 -0
+                       { "name": "status", "size": 1, "elems": [25] },
+                       { "name": "mode", "size": 1, "elems": [3] },
+                       { "name": "pending", "size": 1, "elems": [1] }
+                     ] }
+                 ]
+               }
+   }
+
+EQMP

Looks good. I am only worried about long term stability and documentation.

author
#39 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 46 lines · Anthony Liguori
Quoted 36 lines · Avi Kivity
Quoted 12 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

This introduces device_show, a monitor command that saves the vmstate of a qdev device and visualizes it. QMP is also supported. 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. And it comes with documentation.

(quoted diff) +2 -0
+
+Dump a snapshot of the device state. Buffers are cut after 16 bytes

unless

qemu-monitor.hx Example: · line 762

Quoted 5 lines
qemu-monitor.hx +5 -0
+a full dump is requested.
+
+Arguments:
+
+- "path": the device's qtree path or unique ID (json-string)

This may be ambiguous.

Quoted 1 line

+- "full": report full state (json-bool, optional)

Is this needed for QMP? The client can always truncate it to any length.

Quoted 11 lines
qemu-monitor.hx +4 -0
+
+Schema of returned object:
+
+{ "device": json-string, "id": json-string, "fields" : [

field-objects ] }

qemu-monitor.hx +6 -0
+
+The field object array may be empty, otherwise it consists of
+
+{ "name": json-string, "size": json-int, "elems": [ element-objects ] }
+
+"size" describes the real number of bytes required for a binary
Quoted 8 lines
Quoted 4 lines

representation
+of a single field element in the array. The actually transfered amount may be
+smaller unless a full dump was requested.

This converts the entire qdev tree into an undocumented stable protocol (the qdev paths were already in this state I believe). This really worries me.

Quoted 4 lines

N.B. the association with qdev is only in identifying the device. The contents of the device's state are not part of qdev but rather part of vmstate. vmstate is something that we already guarantee to be stable since that's required for live migration compatibility.

In contrast to save/loadvm, device_show does not provide a backward-compatible output. Not only field names can change (as a result of internal refactoring), fields may even disappear, new ones may pop up. vmstate makes this transparent for reading of old states, but not for visualization.

That said, I see no use case yet that would justify the effort for making state dumps as stable as vmstates.

Jan

#40 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 3 lines · Jan Kiszka

In contrast to save/loadvm, device_show does not provide a backward-compatible output. Not only field names can change (as a result of internal refactoring),

Field names could change, but that seems unlikely and unnecessary.

Quoted 1 line

fields may even disappear,

That would break live migration. The output of device_show when specifying -M pc-0.13 should always be the same. If it's not, I believe that's a bug.

The output of device_show across multiple qemu versions without specifying a -M could certainly be different but that's to be expected since you have a different hardware model.

Quoted 7 lines

new ones may pop
up. vmstate makes this transparent for reading of old states, but not for visualization.

That said, I see no use case yet that would justify the effort for making state dumps as stable as vmstates.

They already are. It's just a matter of whether we declare it as such AFAICT.

Regards,

Anthony Liguori

Quoted 2 lines

Jan

author
#41 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 6 lines · Anthony Liguori
Quoted 3 lines · Jan Kiszka

In contrast to save/loadvm, device_show does not provide a backward-compatible output. Not only field names can change (as a result of internal refactoring),

Field names could change, but that seems unlikely and unnecessary.

Actually, this may happen to improve the output format for device_show, either via renaming the fields or annotating it (once we have the latter mechanism).

Quoted 4 lines
Quoted 2 lines

fields may even disappear,

That would break live migration.

Nope. We can (and I think we did before) perfectly read some field up to version X and convert it into the new format but skip that field for X+1 upward.

Quoted 7 lines

The output of device_show when
specifying -M pc-0.13 should always be the same. If it's not, I believe that's a bug.

The output of device_show across multiple qemu versions without specifying a -M could certainly be different but that's to be expected since you have a different hardware model.

It will be different as soon as the version_id of a dumped vmstate changes, even independent of -M.

Jan

#42 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 8 lines · Jan Kiszka
Quoted 6 lines · Anthony Liguori
Quoted 4 lines · Jan Kiszka

In contrast to save/loadvm, device_show does not provide a backward-compatible output. Not only field names can change (as a result of internal refactoring),

Quoted 5 lines
Quoted 2 lines

Field names could change, but that seems unlikely and unnecessary.

Actually, this may happen to improve the output format for device_show, either via renaming the fields or annotating it (once we have the latter mechanism).

I don't think it's a huge win vs. stability.

Quoted 11 lines
Quoted 8 lines

The output of device_show when
specifying -M pc-0.13 should always be the same. If it's not, I believe that's a bug.

The output of device_show across multiple qemu versions without specifying a -M could certainly be different but that's to be expected since you have a different hardware model.

It will be different as soon as the version_id of a dumped vmstate changes, even independent of -M.

But QMP stability is only guaranteed for releases and -M pc-0.12 should (in a perfect world) always dump out the same versions regardless of whether it's qemu-0.12, qemu-0.13, etc.

Regards,

Anthony Liguori

Quoted 3 lines

Jan

#43 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Anthony Liguori
Quoted 4 lines · Anthony Liguori
Quoted 1 line

This converts the entire qdev tree into an undocumented stable protocol (the qdev paths were already in this state I believe). This really worries me.

N.B. the association with qdev is only in identifying the device. The contents of the device's state are not part of qdev but rather part of vmstate. vmstate is something that we already guarantee to be stable since that's required for live migration compatibility.

That removes out ability to deprecate older vmstate as time passes. Not a blocker but something to consider.

Quoted 1 line

I don't think that qdev device names and paths are something we have to worry much about changing over time since they reflect logical bus layout. They should remain static provided the devices remain static.

Modulo mistakes. We already saw one (lack of pci domains). To reduce the possibility of mistakes, we need reviewable documentation.

Note sysfs had similar assumptions and problems.

Quoted 1 line

The qdev properties are a different matter entirely. A command like 'info qdm' would be potentially difficult to support as part of QMP but the proposed command's output is actually already part of a backward compatible interface (vmstate).

That's all good. But documentation is critical for this. Not only to improve quality, but also so that tool authors would have something to code against instead of trial and error (which invariably misses some corner cases).

Signature · 1 line
error compiling committee.c: too many arguments to function
#44 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 11 lines · Avi Kivity
Quoted 4 lines · Anthony Liguori
Quoted 1 line

This converts the entire qdev tree into an undocumented stable protocol (the qdev paths were already in this state I believe). This really worries me.

N.B. the association with qdev is only in identifying the device. The contents of the device's state are not part of qdev but rather part of vmstate. vmstate is something that we already guarantee to be stable since that's required for live migration compatibility.

That removes out ability to deprecate older vmstate as time passes. Not a blocker but something to consider.

Quoted 1 line

I don't think that qdev device names and paths are something we have to worry much about changing over time since they reflect logical bus layout. They should remain static provided the devices remain static.

Modulo mistakes. We already saw one (lack of pci domains). To reduce the possibility of mistakes, we need reviewable documentation.

pci domains was only a mistake as a nice-to-have. We can add pci domains in a backwards compatible way.

The arguments you're making about the importance of backwards compatibility and what's needed to strongly guarantee it are equally applicable to the live migration protocol. We really do need to formally document the live migration protocol in such a way that it's reviewable if we hope to truly make it compatible across versions.

Regards,

Anthony Liguori

Quoted 6 lines

Note sysfs had similar assumptions and problems.

Quoted 1 line

The qdev properties are a different matter entirely. A command like 'info qdm' would be potentially difficult to support as part of QMP but the proposed command's output is actually already part of a backward compatible interface (vmstate).

That's all good. But documentation is critical for this. Not only to improve quality, but also so that tool authors would have something to code against instead of trial and error (which invariably misses some corner cases).

#45 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 7 lines · Anthony Liguori
Quoted 4 lines
Quoted 2 lines

I don't think that qdev device names and paths are something we have to worry much about changing over time since they reflect logical bus layout. They should remain static provided the devices remain static.

Modulo mistakes. We already saw one (lack of pci domains). To reduce the possibility of mistakes, we need reviewable documentation.

pci domains was only a mistake as a nice-to-have. We can add pci domains in a backwards compatible way.

It adds a new level to the qdev tree. Of course we can hide the new level for older clients, and newer clients can drop the level for older qemus, but it will be oh-so-painful.

Quoted 2 lines

The arguments you're making about the importance of backwards compatibility and what's needed to strongly guarantee it are equally applicable to the live migration protocol. We really do need to formally document the live migration protocol in such a way that it's reviewable if we hope to truly make it compatible across versions.

Mostly agreed. I think live migration has a faster/easier deprecation schedule (easier not to support migration from 0.n-k to 0.n than to remove qmp support for a feature introduced in 0.n-k when releasing 0.n). But that's a minor concern, improving our externally visible interface documentation is a good thing and badly needed.

Signature · 1 line
error compiling committee.c: too many arguments to function
#47 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Anthony Liguori
Quoted 5 lines · Anthony Liguori
Quoted 4 lines · Avi Kivity
Quoted 3 lines · Anthony Liguori
Quoted 3 lines
Quoted 2 lines

I don't think that qdev device names and paths are something we have to worry much about changing over time since they reflect logical bus layout. They should remain static provided the devices remain static.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Modulo mistakes. We already saw one (lack of pci domains). To reduce the possibility of mistakes, we need reviewable documentation.

pci domains was only a mistake as a nice-to-have. We can add pci domains in a backwards compatible way.

It adds a new level to the qdev tree.

The tree is not organized like that today. IOW, the PCI hierarchy is not reflected in the qdev hierarchy. All PCI devices (regardless of whether they're a function or a full slot) simply sit below the PCI bus.

That's a bug IMO, but regardless, s/qdev tree/pci device component of the qdev path/.

Signature · 1 line
error compiling committee.c: too many arguments to function
#46 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Avi Kivity
Quoted 10 lines · Avi Kivity
Quoted 7 lines · Anthony Liguori
Quoted 4 lines
Quoted 2 lines

I don't think that qdev device names and paths are something we have to worry much about changing over time since they reflect logical bus layout. They should remain static provided the devices remain static.

Modulo mistakes. We already saw one (lack of pci domains). To reduce the possibility of mistakes, we need reviewable documentation.

pci domains was only a mistake as a nice-to-have. We can add pci domains in a backwards compatible way.

It adds a new level to the qdev tree.

The tree is not organized like that today. IOW, the PCI hierarchy is not reflected in the qdev hierarchy. All PCI devices (regardless of whether they're a function or a full slot) simply sit below the PCI bus.

Quoted 5 lines
Quoted 2 lines

The arguments you're making about the importance of backwards compatibility and what's needed to strongly guarantee it are equally applicable to the live migration protocol. We really do need to formally document the live migration protocol in such a way that it's reviewable if we hope to truly make it compatible across versions.

Mostly agreed. I think live migration has a faster/easier deprecation schedule (easier not to support migration from 0.n-k to 0.n than to remove qmp support for a feature introduced in 0.n-k when releasing 0.n). But that's a minor concern, improving our externally visible interface documentation is a good thing and badly needed.

Regards,

Anthony Liguori

author
#29 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Markus Armbruster
Quoted 30 lines · Markus Armbruster
Quoted 28 lines · Avi Kivity
Quoted 27 lines · Jan Kiszka
Quoted 11 lines · Avi Kivity
Quoted 9 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

This introduces device_show, a monitor command that saves the vmstate of a qdev device and visualizes it. QMP is also supported. 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. And it comes with documentation.

Quoted 12 lines

qemu-monitor.hx Example: · line 762

Quoted 10 lines
(quoted diff) +2 -0
+
+Dump a snapshot of the device state. Buffers are cut after 16 bytes

unless

qemu-monitor.hx +5 -0
+a full dump is requested.
+
+Arguments:
+
+- "path": the device's qtree path or unique ID (json-string)

This may be ambiguous.

Can your elaborate what precisely is ambiguous?

Quoted 8 lines
Quoted 4 lines

Can't the user choose the unique ID so that it aliases an unrelated qtree path?

I prefer having mutually exclusive 'path' and 'ref' arguments.

Don't think that's necessary. If the string starts with '/', it's an absolute path. Else, it's a relative path rooted at the node with the ID equal to the first component.

'pci.0' can be both a (badly chosen) ID as well as an abbreviated qtree path.

Quoted 4 lines

Currently breaks down when IDs contain '/', but permitting that is a bug. There may be more problems; the path lookup code is way too clever.

Indeed. Less can sometimes be more. My impression is that some of the cleverness was motivated by lacking qtree completion for the HMP.

Jan

author
#8 lore raw

Re: [Qemu-devel] [PATCH v2 03/15] qdev: Allow device addressing via 'driver.instance'

In reply to Markus Armbruster
Quoted 30 lines · Markus Armbruster
Quoted 28 lines · Jan Kiszka

From: 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 |   12 +++++++++++-
 hw/qdev.c                |   23 ++++++++++++++++++-----
 2 files changed, 29 insertions(+), 6 deletions(-)
docs/qdev-device-use.txt +1 -1
index 9ac1fa1..5939481 100644
@@ -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,16 @@ 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.
 
Quoted 13 lines

docs/qdev-device-use.txt Furthermore, if a device only hosts a single bus, the bus name can be · line 37

Quoted 11 lines
docs/qdev-device-use.txt +10 -0
+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]
+
+Example: /i440FX-pcihost/pci.0/e1000.2 addresses the second e1000
+adapter on the bus 'pci.0'.
+
 Note: the USB device address can't be controlled at this time.

"instance number" isn't defined in this document.

True, only implicitly via the example.

Quoted 10 lines

I understand the problem you're trying to solve; I've had it myself many times. But is inventing an instance number the right solution?

The two e1000 devices already have a perfectly fine unique identifier on their bus: their bus address. What about recognizing bus addresses in paths? Requires a suitable restriction on device names and IDs to avoid ambiguity, say "start with letter".

qdev currently doesn't abstract bus addresses, but that's fixable.

You would also have to specify unique addressing scheme to those buses that do not have it yet. E.g. what should be the address of a ISA bus device? The base of its first ioport range? But if it does not have any as it only injects ISA IRQs?

Jan

#28 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Avi Kivity
Quoted 26 lines · Avi Kivity
Quoted 25 lines · Jan Kiszka
Quoted 23 lines · Avi Kivity
Quoted 14 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

This introduces device_show, a monitor command that saves the vmstate of a qdev device and visualizes it. QMP is also supported. 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. And it comes with documentation.

(quoted diff) +2 -0
+
+Dump a snapshot of the device state. Buffers are cut after 16 bytes

unless

qemu-monitor.hx Example: · line 762

Quoted 5 lines
qemu-monitor.hx +5 -0
+a full dump is requested.
+
+Arguments:
+
+- "path": the device's qtree path or unique ID (json-string)

This may be ambiguous.

Quoted 7 lines
Quoted 2 lines

Can your elaborate what precisely is ambiguous?

Can't the user choose the unique ID so that it aliases an unrelated qtree path?

I prefer having mutually exclusive 'path' and 'ref' arguments.

Don't think that's necessary. If the string starts with '/', it's an absolute path. Else, it's a relative path rooted at the node with the ID equal to the first component.

Currently breaks down when IDs contain '/', but permitting that is a bug. There may be more problems; the path lookup code is way too clever.

author
#4 lore raw

Re: [Qemu-devel] [PATCH v2 02/15] qdev: Fix scanning across single-bus devices

In reply to Markus Armbruster
Quoted 15 lines · Markus Armbruster

[cc: kraxel]

Quoted 5 lines · Jan Kiszka

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.

We auto-root a path not starting with '/' via convention "first component is ID then" (I like that). We auto-complete a path ending with a device when we want a bus (a bit too clever). Auto-inserting bus names in the middle is too clever by half!

Quoted 7 lines

Such cleverness can be convenient in the human monitor, but all it adds to QMP is complexity.

I'm worried about possibly ambigous interpretation of paths. Would be bad if a path could name different node after we add something to the tree. I *think* your fine print makes that impossible, but it's not exactly obvious. Heck, I could be wrong.

For the above example, that would mean a bus called 'dev2' would have to be added to dev1. If that makes sense is one question. The other is why this should be more broken than the case that this happens to a bus specified at the end of some path?

Quoted 3 lines

Wouldn't it be better to put the convenience into the interactive completion function? That way we keep it out of QMP.

That would leave user interfaces over QMP broken behind, or at least complicate their implementations as they would have to expand the qtree path on their own to achieve consistency.

Quoted 2 lines

Subject is misleading, it's a feature, not a bug fix.

Depends on the POV. For me it is a highly confusing inconsistency in the way you can specify qtree paths. IMHO, we either have to drop this path abbreviation or apply it to the whole path. As it's intention is (according to my understanding) to ease the usage, an unintuitive construction role is fairly counterproductive.

Jan

#7 lore raw

Re: [Qemu-devel] [PATCH v2 03/15] qdev: Allow device addressing via 'driver.instance'

In reply to Jan Kiszka
Quoted 29 lines · Jan Kiszka

From: 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 |   12 +++++++++++-
 hw/qdev.c                |   23 ++++++++++++++++++-----
 2 files changed, 29 insertions(+), 6 deletions(-)
docs/qdev-device-use.txt +2 -1
index 9ac1fa1..5939481 100644
@@ -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,16 @@ 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

docs/qdev-device-use.txt Furthermore, if a device only hosts a single bus, the bus name can be · line 37

Quoted 10 lines
docs/qdev-device-use.txt +9 -0
+assigned during creation or via the device tree path:
+
+/full_bus_address/driver_name[.instance_number]
+    or
+abbreviated_bus_address/driver_name[.instance_number]
+
+Example: /i440FX-pcihost/pci.0/e1000.2 addresses the second e1000
+adapter on the bus 'pci.0'.
+
 Note: the USB device address can't be controlled at this time.

"instance number" isn't defined in this document.

I understand the problem you're trying to solve; I've had it myself many times. But is inventing an instance number the right solution?

The two e1000 devices already have a perfectly fine unique identifier on their bus: their bus address. What about recognizing bus addresses in paths? Requires a suitable restriction on device names and IDs to avoid ambiguity, say "start with letter".

qdev currently doesn't abstract bus addresses, but that's fixable.

[...]

#3 lore raw

Re: [Qemu-devel] [PATCH v2 02/15] qdev: Fix scanning across single-bus devices

In reply to Jan Kiszka

[cc: kraxel]

Quoted 5 lines · Jan Kiszka

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.

We auto-root a path not starting with '/' via convention "first component is ID then" (I like that). We auto-complete a path ending with a device when we want a bus (a bit too clever). Auto-inserting bus names in the middle is too clever by half!

Such cleverness can be convenient in the human monitor, but all it adds to QMP is complexity.

I'm worried about possibly ambigous interpretation of paths. Would be bad if a path could name different node after we add something to the tree. I *think* your fine print makes that impossible, but it's not exactly obvious. Heck, I could be wrong.

Wouldn't it be better to put the convenience into the interactive completion function? That way we keep it out of QMP.

Subject is misleading, it's a feature, not a bug fix.

#30 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Jan Kiszka
Quoted 7 lines · Jan Kiszka
Quoted 4 lines

Currently breaks down when IDs contain '/', but permitting that is a bug. There may be more problems; the path lookup code is way too clever.

Indeed. Less can sometimes be more. My impression is that some of the cleverness was motivated by lacking qtree completion for the HMP.

Can we disable abbreviations for QMP and only allow them for HMP?

We can support that by adding a hidden argument to commands specifying whether the input comes from a human or machine. Abbreviations are dangerous if they become ambiguous; a human can recover while a machine can't.

Signature · 1 line
error compiling committee.c: too many arguments to function
author
#31 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 9 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka
Quoted 4 lines

Currently breaks down when IDs contain '/', but permitting that is a bug. There may be more problems; the path lookup code is way too clever.

Indeed. Less can sometimes be more. My impression is that some of the cleverness was motivated by lacking qtree completion for the HMP.

Quoted 7 lines

Can we disable abbreviations for QMP and only allow them for HMP?

We can support that by adding a hidden argument to commands specifying whether the input comes from a human or machine. Abbreviations are dangerous if they become ambiguous; a human can recover while a machine can't.

Both QMP _and_ HMP suffer from ambitious and inconsistent addressing schemes. Therefore, I'm more and more in favor of [1]. We just need to add command line completion for option values, something that would be beneficial for 'drive_add file=...' as well.

Jan

[1] http://article.gmane.org/gmane.comp.emulators.qemu/72152

#32 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 18 lines · Jan Kiszka
Quoted 9 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka
Quoted 4 lines

Currently breaks down when IDs contain '/', but permitting that is a bug. There may be more problems; the path lookup code is way too clever.

Indeed. Less can sometimes be more. My impression is that some of the cleverness was motivated by lacking qtree completion for the HMP.

Quoted 7 lines

Can we disable abbreviations for QMP and only allow them for HMP?

We can support that by adding a hidden argument to commands specifying whether the input comes from a human or machine. Abbreviations are dangerous if they become ambiguous; a human can recover while a machine can't.

Quoted 8 lines

Both QMP _and_ HMP suffer from ambitious and inconsistent addressing schemes. Therefore, I'm more and more in favor of [1]. We just need to add command line completion for option values, something that would be beneficial for 'drive_add file=...' as well.

Jan

[1] http://article.gmane.org/gmane.comp.emulators.qemu/72152

[1] = abolish the clever abbreviations in path lookup. I agree we should do that.

#33 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 23 lines · Markus Armbruster
Quoted 21 lines · Jan Kiszka
Quoted 8 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka
Quoted 4 lines

Currently breaks down when IDs contain '/', but permitting that is a bug. There may be more problems; the path lookup code is way too clever.

Indeed. Less can sometimes be more. My impression is that some of the cleverness was motivated by lacking qtree completion for the HMP.

Quoted 7 lines

Can we disable abbreviations for QMP and only allow them for HMP?

We can support that by adding a hidden argument to commands specifying whether the input comes from a human or machine. Abbreviations are dangerous if they become ambiguous; a human can recover while a machine can't.

Both QMP _and_ HMP suffer from ambitious and inconsistent addressing schemes. Therefore, I'm more and more in favor of [1]. We just need to add command line completion for option values, something that would be beneficial for 'drive_add file=...' as well.

Quoted 6 lines
Quoted 3 lines

Jan

[1] http://article.gmane.org/gmane.comp.emulators.qemu/72152

[1] = abolish the clever abbreviations in path lookup. I agree we should do that.

Fine. No concerns regarding overlaying IDs and path specifications as well?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#9 lore raw

Re: [Qemu-devel] [PATCH v2 03/15] qdev: Allow device addressing via 'driver.instance'

In reply to Jan Kiszka
Quoted 56 lines · Jan Kiszka
Quoted 30 lines · Markus Armbruster
Quoted 28 lines · Jan Kiszka

From: 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 |   12 +++++++++++-
 hw/qdev.c                |   23 ++++++++++++++++++-----
 2 files changed, 29 insertions(+), 6 deletions(-)
docs/qdev-device-use.txt +1 -1
index 9ac1fa1..5939481 100644
@@ -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,16 @@ 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.
 
Quoted 13 lines

docs/qdev-device-use.txt Furthermore, if a device only hosts a single bus, the bus name can be · line 37

Quoted 11 lines
docs/qdev-device-use.txt +10 -0
+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]
+
+Example: /i440FX-pcihost/pci.0/e1000.2 addresses the second e1000
+adapter on the bus 'pci.0'.
+
 Note: the USB device address can't be controlled at this time.

"instance number" isn't defined in this document.

True, only implicitly via the example.

Quoted 9 lines

I understand the problem you're trying to solve; I've had it myself many times. But is inventing an instance number the right solution?

The two e1000 devices already have a perfectly fine unique identifier on their bus: their bus address. What about recognizing bus addresses in paths? Requires a suitable restriction on device names and IDs to avoid ambiguity, say "start with letter".

Quoted 6 lines
Quoted 1 line

qdev currently doesn't abstract bus addresses, but that's fixable.

You would also have to specify unique addressing scheme to those buses that do not have it yet. E.g. what should be the address of a ISA bus device? The base of its first ioport range? But if it does not have any as it only injects ISA IRQs?

Hmm, instance numbers are the lesser evil in this case.

Define them properly, and make info qtree show them, and we'll be okay, I guess.

#5 lore raw

Re: [Qemu-devel] [PATCH v2 02/15] qdev: Fix scanning across single-bus devices

In reply to Markus Armbruster
Quoted 6 lines · Markus Armbruster

[cc: kraxel]

Quoted 2 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

Quoted 7 lines
Quoted 3 lines

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.

We auto-root a path not starting with '/' via convention "first component is ID then" (I like that). We auto-complete a path ending with a device when we want a bus (a bit too clever).

... only if there is a single child bus only (i.e. it isn't ambiguous).
Which is the common case though.

Quoted 2 lines

Auto-inserting bus
names in the middle is too clever by half!

Yea. I have to agree here. It can only work reliably if you make sure all your devices have unique ids. In which case there is no need to reference dev1 at all, you can just use the "first component is ID then" mechanism for dev2.

cheers,
Gerd

#34 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

In reply to Jan Kiszka
Quoted 24 lines · Jan Kiszka
Quoted 23 lines · Markus Armbruster
Quoted 21 lines · Jan Kiszka
Quoted 8 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka
Quoted 4 lines

Currently breaks down when IDs contain '/', but permitting that is a bug. There may be more problems; the path lookup code is way too clever.

Indeed. Less can sometimes be more. My impression is that some of the cleverness was motivated by lacking qtree completion for the HMP.

Quoted 7 lines

Can we disable abbreviations for QMP and only allow them for HMP?

We can support that by adding a hidden argument to commands specifying whether the input comes from a human or machine. Abbreviations are dangerous if they become ambiguous; a human can recover while a machine can't.

Both QMP _and_ HMP suffer from ambitious and inconsistent addressing schemes. Therefore, I'm more and more in favor of [1]. We just need to add command line completion for option values, something that would be beneficial for 'drive_add file=...' as well.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Jan

[1] http://article.gmane.org/gmane.comp.emulators.qemu/72152

[1] = abolish the clever abbreviations in path lookup. I agree we should do that.

Fine. No concerns regarding overlaying IDs and path specifications as well?

I'm fine with that.

Calling the overlayed argument "id" is not so nice. We got a bunch of other not-so-nice names in QMP, maybe we'll have a flag day to clean them all up.

#35 lore raw

Re: [Qemu-devel] Re: [PATCH v2 12/15] monitor: Add basic device state visualization

Quoted 31 lines · Markus Armbruster
Quoted 29 lines · Jan Kiszka
Quoted 28 lines · Markus Armbruster
Quoted 16 lines · Jan Kiszka
Quoted 8 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka
Quoted 4 lines

Currently breaks down when IDs contain '/', but permitting that is a bug. There may be more problems; the path lookup code is way too clever.

Indeed. Less can sometimes be more. My impression is that some of the cleverness was motivated by lacking qtree completion for the HMP.

Quoted 7 lines

Can we disable abbreviations for QMP and only allow them for HMP?

We can support that by adding a hidden argument to commands specifying whether the input comes from a human or machine. Abbreviations are dangerous if they become ambiguous; a human can recover while a machine can't.

Quoted 8 lines

Both QMP _and_ HMP suffer from ambitious and inconsistent addressing schemes. Therefore, I'm more and more in favor of [1]. We just need to add command line completion for option values, something that would be beneficial for 'drive_add file=...' as well.

Jan

[1] http://article.gmane.org/gmane.comp.emulators.qemu/72152

[1] = abolish the clever abbreviations in path lookup. I agree we should do that.

Quoted 7 lines
Quoted 1 line

Fine. No concerns regarding overlaying IDs and path specifications as well?

I'm fine with that.

Calling the overlayed argument "id" is not so nice. We got a bunch of other not-so-nice names in QMP, maybe we'll have a flag day to clean them all up.

For this case (device_del and device_show), I think we should simply call it 'device'.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux