Skip to content

qdev: Add JSON -device and fix QMP device_add

Kevin Wolf qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 37 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11qom: Reduce use of error_propagate()qom/object.c qom/object_interfaces.c+9 -153 replies
2/11iotests/245: Fix type for iothread propertytests/qemu-iotests/245+2 -21 reply
3/11iotests/051: Fix typotests/qemu-iotests/051 tests/qemu-iotests/051.pc.out+3 -31 reply
4/11qdev: Avoid using string visitor for propertiessoftmmu/qdev-monitor.c+17 -31 reply
5/11qdev: Make DeviceState.id independent of QemuOptshw/arm/virt.c hw/core/qdev.c hw/pci-bridge/pci_expander_bridge.c +4 more+9 -73 replies
6/11qdev: Add Error parameter to qdev_set_id()hw/xen/xen-legacy-backend.c include/monitor/qdev.h softmmu/qdev-monitor.c+13 -83 replies
7/11qemu-option: Allow deleting opts during qemu_opts_foreach()util/qemu-option.c+2 -21 reply
8/11qdev: Base object creation on QDict rather than QemuOptshw/core/qdev.c hw/net/virtio-net.c hw/vfio/pci.c +2 more+41 -471 reply
9/11qdev: Avoid QemuOpts in QMP device_addsoftmmu/qdev-monitor.c+11 -713 replies
10/11vl: Enable JSON syntax for -deviceqapi/qdev.json softmmu/vl.c+62 -111 reply
11/11Deprecate stable non-JSON -device and -objectdocs/about/deprecated.rst+11 -09 replies

Reviews trailers per patch

10 of 11 patches have a Reviewed-by or Acked-by.

PatchVladimir Sementsov-OgievskiyMarkus ArmbrusterEric Blake
1/11R-b R-b
2/11R-b
3/11R-b
4/11R-b
5/11R-b
6/11
7/11R-b
8/11R-b
9/11R-b
10/11R-b
11/11R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 00/11] qdev: Add JSON -device and fix QMP device_add

It's still a long way until we'll have QAPIfied devices, but there are some improvements that we can already make now to make the future switch easier.

One important part of this is having code paths without QemuOpts, which we want to get rid of and replace with the keyval parser in the long run. This series adds support for JSON syntax to -device, which bypasses QemuOpts.

While we're not using QAPI yet, devices are based on QOM, so we already do have type checks and an implied schema. JSON syntax supported now can be supported by QAPI later and regarding command line compatibility, actually switching to it becomes an implementation detail this way (of course, it will still add valuable user-visible features like introspection and documentation).

Apart from making things more future proof, this also immediately adds a way to do non-scalar properties on the command line. nvme could have used list support recently, and the lack of it in -device led to some rather unnatural solution in the first version (doing the relationship between a device and objects backwards) and loss of features in the following. With this series, using a list as a device property should be possible without any weird tricks.

Unfortunately, even QMP device_add goes through QemuOpts before this series, which destroys any type safety QOM provides and also can't support non-scalar properties. This is a bug that is fixed during this series, but that is technically an incompatible change. A similar change was made for netdev_add in commit db2a380c84.

libvirt needs to make sure that it actually always passes the right type, because passing a wrong type will start to fail after this series. I hope that libvirt already does things correctly, so this won't cause any trouble, but if it does, there is the option of using the QemuOpts-less code path only for JSON -device and going through a deprecation period for QMP device_add.

Kevin Wolf (11):
qom: Reduce use of error_propagate()
iotests/245: Fix type for iothread property iotests/051: Fix typo
qdev: Avoid using string visitor for properties
qdev: Make DeviceState.id independent of QemuOpts
qdev: Add Error parameter to qdev_set_id()
qemu-option: Allow deleting opts during qemu_opts_foreach()
qdev: Base object creation on QDict rather than QemuOpts
qdev: Avoid QemuOpts in QMP device_add
vl: Enable JSON syntax for -device
Deprecate stable non-JSON -device and -object

 qapi/qdev.json                      | 15 +++--
 docs/about/deprecated.rst           | 11 ++++
 include/hw/qdev-core.h              | 10 ++--
 include/monitor/qdev.h              |  2 +-
 hw/arm/virt.c                       |  2 +-
 hw/core/qdev.c                      |  6 +-
 hw/net/virtio-net.c                 |  4 +-
 hw/pci-bridge/pci_expander_bridge.c |  2 +-
 hw/ppc/e500.c                       |  2 +-
 hw/vfio/pci.c                       |  4 +-
 hw/xen/xen-legacy-backend.c         |  3 +-
 qom/object.c                        |  7 +--
 qom/object_interfaces.c             | 17 ++----
 softmmu/qdev-monitor.c              | 90 +++++++++++++++++------------
 softmmu/vl.c                        | 58 ++++++++++++++++---
 util/qemu-option.c                  |  4 +-
 tests/qemu-iotests/051              |  2 +-
 tests/qemu-iotests/051.pc.out       |  4 +-
 tests/qemu-iotests/245              |  4 +-
 19 files changed, 161 insertions(+), 86 deletions(-)
Signature · 1 line
2.31.1