qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] e287bf: net: Introduce NetClientInfo.check_pe


From: Richard Henderson
Subject: [Qemu-commits] [qemu/qemu] e287bf: net: Introduce NetClientInfo.check_peer_type()
Date: Fri, 15 Oct 2021 13:26:09 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: e287bf7bb15ffd3728c000d9c5b52460ea17d713
      
https://github.com/qemu/qemu/commit/e287bf7bb15ffd3728c000d9c5b52460ea17d713
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M hw/core/qdev-properties-system.c
    M include/net/net.h

  Log Message:
  -----------
  net: Introduce NetClientInfo.check_peer_type()

Some network backends (vhost-user and vhost-vdpa) work only with
specific devices. At startup, they second guess what the command line
option handling will do and error out if they think a non-virtio device
will attach to them.

This second guessing is not only ugly, it can lead to wrong error
messages ('-device floppy,netdev=foo' should complain about an unknown
property, not about the wrong kind of network device being attached) and
completely ignores hotplugging.

Add a callback where backends can check compatibility with a device when
it actually tries to attach, even on hotplug.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20211008133442.141332-2-kwolf@redhat.com>
Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 5c485d51c4e2e8b3c78110a1a3f31f789c900d9d
      
https://github.com/qemu/qemu/commit/5c485d51c4e2e8b3c78110a1a3f31f789c900d9d
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M net/vhost-user.c

  Log Message:
  -----------
  net/vhost-user: Fix device compatibility check

vhost-user works only with specific devices. At startup, it second
guesses what the command line option handling will do and error out if
it thinks a non-virtio device will attach to them.

This second guessing is not only ugly, it can lead to wrong error
messages ('-device floppy,netdev=foo' should complain about an unknown
property, not about the wrong kind of network device being attached) and
completely ignores hotplugging.

Drop the old checks and implement .check_peer_type() instead to fix
this. As a nice side effect, it also removes one more dependency on the
legacy QemuOpts infrastructure and even reduces the code size.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20211008133442.141332-3-kwolf@redhat.com>
Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: ee8a1c63d337a893fa915dd263dfdaa272e1a76a
      
https://github.com/qemu/qemu/commit/ee8a1c63d337a893fa915dd263dfdaa272e1a76a
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M net/vhost-vdpa.c

  Log Message:
  -----------
  net/vhost-vdpa: Fix device compatibility check

vhost-vdpa works only with specific devices. At startup, it second
guesses what the command line option handling will do and error out if
it thinks a non-virtio device will attach to them.

This second guessing is not only ugly, it can lead to wrong error
messages ('-device floppy,netdev=foo' should complain about an unknown
property, not about the wrong kind of network device being attached) and
completely ignores hotplugging.

Drop the old checks and implement .check_peer_type() instead to fix
this. As a nice side effect, it also removes one more dependency on the
legacy QemuOpts infrastructure and even reduces the code size.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20211008133442.141332-4-kwolf@redhat.com>
Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: dbc8221f8cf3a3004fb6b4d0675f5852758b0388
      
https://github.com/qemu/qemu/commit/dbc8221f8cf3a3004fb6b4d0675f5852758b0388
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M qom/object.c
    M qom/object_interfaces.c

  Log Message:
  -----------
  qom: Reduce use of error_propagate()

ERRP_GUARD() makes debugging easier by making sure that &error_abort
still fails at the real origin of the error instead of
error_propagate().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20211008133442.141332-5-kwolf@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: e2c8eb1454b6aee79077d6d9710ec92d66554e56
      
https://github.com/qemu/qemu/commit/e2c8eb1454b6aee79077d6d9710ec92d66554e56
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M tests/qemu-iotests/245

  Log Message:
  -----------
  iotests/245: Fix type for iothread property

iothread is a string property, so None (= JSON null) is not a valid
value for it. Pass the empty string instead to get the default iothread.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20211008133442.141332-6-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: af6400afb89f5eb3f66f841c8ee8c2f6754c8394
      
https://github.com/qemu/qemu/commit/af6400afb89f5eb3f66f841c8ee8c2f6754c8394
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M tests/qemu-iotests/051
    M tests/qemu-iotests/051.pc.out

  Log Message:
  -----------
  iotests/051: Fix typo

The iothread isn't called 'iothread0', but 'thread0'. Depending on the
order that properties are parsed, the error message may change from the
expected one to another one saying that the iothread doesn't exist.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20211008133442.141332-7-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: c34efecedd0552ee8b830402241e19daebb22aec
      
https://github.com/qemu/qemu/commit/c34efecedd0552ee8b830402241e19daebb22aec
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M softmmu/qdev-monitor.c

  Log Message:
  -----------
  qdev: Avoid using string visitor for properties

The only thing the string visitor adds compared to a keyval visitor is
list support. git grep for 'visit_start_list' and 'visit.*List' shows
that devices don't make use of this.

In a world with a QAPIfied command line interface, the keyval visitor is
used to parse the command line. In order to make sure that no devices
start using this feature that would make backwards compatibility harder,
just switch away from object_property_parse(), which internally uses the
string visitor, to a keyval visitor and object_property_set().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20211008133442.141332-8-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 163f384752dd9125ce7eb1b2edf00b23f0a54557
      
https://github.com/qemu/qemu/commit/163f384752dd9125ce7eb1b2edf00b23f0a54557
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M hw/arm/virt.c
    M hw/core/qdev.c
    M hw/pci-bridge/pci_expander_bridge.c
    M hw/ppc/e500.c
    M include/hw/qdev-core.h
    M include/monitor/qdev.h
    M softmmu/qdev-monitor.c

  Log Message:
  -----------
  qdev: Make DeviceState.id independent of QemuOpts

DeviceState.id is a pointer to a string that is stored in the QemuOpts
object DeviceState.opts and freed together with it. We want to create
devices without going through QemuOpts in the future, so make this a
separately allocated string.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20211008133442.141332-9-kwolf@redhat.com>
Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 4a1d937796de0fecd8b22d7dbebf87f38e8282fd
      
https://github.com/qemu/qemu/commit/4a1d937796de0fecd8b22d7dbebf87f38e8282fd
  Author: Damien Hedde <damien.hedde@greensocs.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M hw/xen/xen-legacy-backend.c
    M include/monitor/qdev.h
    M softmmu/qdev-monitor.c

  Log Message:
  -----------
  softmmu/qdev-monitor: add error handling in qdev_set_id

qdev_set_id() is mostly used when the user adds a device (using
-device cli option or device_add qmp command). This commit adds
an error parameter to handle the case where the given id is
already taken.

Also document the function and add a return value in order to
be able to capture success/failure: the function now returns the
id in case of success, or NULL in case of failure.

The commit modifies the 2 calling places (qdev-monitor and
xen-legacy-backend) to add the error object parameter.

Note that the id is, right now, guaranteed to be unique because
all ids came from the "device" QemuOptsList where the id is used
as key. This addition is a preparation for a future commit which
will relax the uniqueness.

Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20211008133442.141332-10-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 30648dd5d609d111e635112d7e6014ca63f7ba13
      
https://github.com/qemu/qemu/commit/30648dd5d609d111e635112d7e6014ca63f7ba13
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M util/qemu-option.c

  Log Message:
  -----------
  qemu-option: Allow deleting opts during qemu_opts_foreach()

Use QTAILQ_FOREACH_SAFE() so that the current QemuOpts can be deleted
while iterating through the whole list.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20211008133442.141332-11-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 7d61808206cc651ae42024ab6def827afa2f807b
      
https://github.com/qemu/qemu/commit/7d61808206cc651ae42024ab6def827afa2f807b
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M hw/core/qdev.c
    M hw/net/virtio-net.c
    M include/hw/qdev-core.h
    M softmmu/qdev-monitor.c

  Log Message:
  -----------
  qdev: Add Error parameter to hide_device() callbacks

hide_device() is used for virtio-net failover, where the standby virtio
device delays creation of the primary device. It only makes sense to
have a single primary device for each standby device. Adding a second
one should result in an error instead of hiding it and never using it
afterwards.

Prepare for this by adding an Error parameter to the hide_device()
callback where virtio-net is informed about adding a primary device.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20211008133442.141332-12-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 259a10dbcb4f36a3489fb52f9f7a654761589448
      
https://github.com/qemu/qemu/commit/259a10dbcb4f36a3489fb52f9f7a654761589448
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M hw/net/virtio-net.c
    M include/hw/virtio/virtio-net.h

  Log Message:
  -----------
  virtio-net: Store failover primary opts pointer locally

Instead of accessing the global QemuOptsList, which really belong to the
command line parser and shouldn't be accessed from devices, store a
pointer to the QemuOpts in a new VirtIONet field.

This is not the final state, but just an intermediate step to get rid of
QemuOpts in devices. It will later be replaced with an options QDict.

Before this patch, two "primary" devices could be hidden for the same
standby device, but only one of them would actually be enabled and the
other one would be kept hidden forever, so this doesn't make sense.
After this patch, configuring a second primary device is an error.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20211008133442.141332-13-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 12b2fad7dcc8d08b6a59d1b14caa392ea614c6d9
      
https://github.com/qemu/qemu/commit/12b2fad7dcc8d08b6a59d1b14caa392ea614c6d9
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M hw/net/virtio-net.c

  Log Message:
  -----------
  virtio-net: Avoid QemuOpts in failover_find_primary_device()

Don't go through the global QemuOptsList, it is state of the legacy
command line parser and we will create devices that are not contained
in it. It is also just the command line configuration and not
necessarily the current runtime state.

Instead, look at the qdev device tree which has the current state of all
existing devices.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20211008133442.141332-14-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: f3558b1b763683bb877f7dd5b282469cdadc65c3
      
https://github.com/qemu/qemu/commit/f3558b1b763683bb877f7dd5b282469cdadc65c3
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M hw/core/qdev.c
    M hw/net/virtio-net.c
    M hw/vfio/pci.c
    M include/hw/qdev-core.h
    M include/hw/virtio/virtio-net.h
    M include/monitor/qdev.h
    M softmmu/qdev-monitor.c

  Log Message:
  -----------
  qdev: Base object creation on QDict rather than QemuOpts

QDicts are both what QMP natively uses and what the keyval parser
produces. Going through QemuOpts isn't useful for either one, so switch
the main device creation function to QDicts. By sharing more code with
the -object/object-add code path, we can even reduce the code size a
bit.

This commit doesn't remove the detour through QemuOpts from any code
path yet, but it allows the following commits to do so.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20211008133442.141332-15-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 5dacda5167560b3af8eadbce5814f60ba44b467e
      
https://github.com/qemu/qemu/commit/5dacda5167560b3af8eadbce5814f60ba44b467e
  Author: Kevin Wolf <kwolf@redhat.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M qapi/qdev.json
    M softmmu/vl.c

  Log Message:
  -----------
  vl: Enable JSON syntax for -device

Like we already do for -object, introduce support for JSON syntax in
-device, which can be kept stable in the long term and guarantees that a
single code path with identical behaviour is used for both QMP and the
command line. Compared to the QemuOpts based code, the parser contains
less surprises and has support for non-scalar options (lists and
structs). Switching management tools to JSON means that we can more
easily change the "human" CLI syntax from QemuOpts to the keyval parser
later.

In the QAPI schema, a feature flag is added to the device-add command to
allow management tools to detect support for this.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20211008133442.141332-16-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>


  Commit: 253e399bab7c83b3411f8eac01840283a9304cb3
      
https://github.com/qemu/qemu/commit/253e399bab7c83b3411f8eac01840283a9304cb3
  Author: Richard Henderson <richard.henderson@linaro.org>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M hw/arm/virt.c
    M hw/core/qdev-properties-system.c
    M hw/core/qdev.c
    M hw/net/virtio-net.c
    M hw/pci-bridge/pci_expander_bridge.c
    M hw/ppc/e500.c
    M hw/vfio/pci.c
    M hw/xen/xen-legacy-backend.c
    M include/hw/qdev-core.h
    M include/hw/virtio/virtio-net.h
    M include/monitor/qdev.h
    M include/net/net.h
    M net/vhost-user.c
    M net/vhost-vdpa.c
    M qapi/qdev.json
    M qom/object.c
    M qom/object_interfaces.c
    M softmmu/qdev-monitor.c
    M softmmu/vl.c
    M tests/qemu-iotests/051
    M tests/qemu-iotests/051.pc.out
    M tests/qemu-iotests/245
    M util/qemu-option.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/kwolf/tags/for-upstream' into staging

qdev: Add JSON -device

- Add a JSON mode to the -device command line option
- net/vhost-{user,vdpa}: Fix device compatibility check
- Minor iotests fixes

# gpg: Signature made Fri 15 Oct 2021 07:41:22 AM PDT
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "kwolf@redhat.com"
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]

* remotes/kwolf/tags/for-upstream:
  vl: Enable JSON syntax for -device
  qdev: Base object creation on QDict rather than QemuOpts
  virtio-net: Avoid QemuOpts in failover_find_primary_device()
  virtio-net: Store failover primary opts pointer locally
  qdev: Add Error parameter to hide_device() callbacks
  qemu-option: Allow deleting opts during qemu_opts_foreach()
  softmmu/qdev-monitor: add error handling in qdev_set_id
  qdev: Make DeviceState.id independent of QemuOpts
  qdev: Avoid using string visitor for properties
  iotests/051: Fix typo
  iotests/245: Fix type for iothread property
  qom: Reduce use of error_propagate()
  net/vhost-vdpa: Fix device compatibility check
  net/vhost-user: Fix device compatibility check
  net: Introduce NetClientInfo.check_peer_type()

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


Compare: https://github.com/qemu/qemu/compare/82d88f834c8f...253e399bab7c



reply via email to

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