[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/4] qapi: introduce CONFIG_READ event
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 4/4] qapi: introduce CONFIG_READ event |
Date: |
Tue, 17 Oct 2023 17:00:45 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
> Send a new event when guest reads virtio-pci config after
> virtio_notify_config() call.
>
> That's useful to check that guest fetched modified config, for example
> after resizing disk backend.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
> hw/virtio/virtio-pci.c | 9 +++++++++
> include/monitor/qdev.h | 1 +
> monitor/monitor.c | 1 +
> qapi/qdev.json | 22 ++++++++++++++++++++++
> softmmu/qdev-monitor.c | 5 +++++
> 5 files changed, 38 insertions(+)
>
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index dd4620462b..f24f8ff03d 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -23,6 +23,7 @@
> #include "hw/boards.h"
> #include "hw/virtio/virtio.h"
> #include "migration/qemu-file-types.h"
> +#include "monitor/qdev.h"
> #include "hw/pci/pci.h"
> #include "hw/pci/pci_bus.h"
> #include "hw/qdev-properties.h"
> @@ -541,6 +542,10 @@ static uint64_t virtio_pci_config_read(void *opaque,
> hwaddr addr,
> }
> addr -= config;
>
> + if (vdev->generation > 0) {
> + qdev_config_read_event(DEVICE(proxy));
> + }
> +
> switch (size) {
> case 1:
> val = virtio_config_readb(vdev, addr);
> @@ -1728,6 +1733,10 @@ static uint64_t virtio_pci_device_read(void *opaque,
> hwaddr addr,
> return UINT64_MAX;
> }
>
> + if (vdev->generation > 0) {
> + qdev_config_read_event(DEVICE(proxy));
> + }
> +
> switch (size) {
> case 1:
> val = virtio_config_modern_readb(vdev, addr);
> diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h
> index 949a3672cb..f0b0eab07e 100644
> --- a/include/monitor/qdev.h
> +++ b/include/monitor/qdev.h
> @@ -39,6 +39,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
> const char *qdev_set_id(DeviceState *dev, char *id, Error **errp);
>
> void qdev_hotplug_device_on_event(DeviceState *dev);
> +void qdev_config_read_event(DeviceState *dev);
>
> DeviceAndPath *qdev_new_device_and_path(DeviceState *dev);
>
> diff --git a/monitor/monitor.c b/monitor/monitor.c
> index 941f87815a..f8aa91b190 100644
> --- a/monitor/monitor.c
> +++ b/monitor/monitor.c
> @@ -315,6 +315,7 @@ static MonitorQAPIEventConf
> monitor_qapi_event_conf[QAPI_EVENT__MAX] = {
> [QAPI_EVENT_QUORUM_FAILURE] = { 1000 * SCALE_MS },
> [QAPI_EVENT_VSERPORT_CHANGE] = { 1000 * SCALE_MS },
> [QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE] = { 1000 * SCALE_MS },
> + [QAPI_EVENT_X_CONFIG_READ] = { 300 * SCALE_MS },
> };
>
> /*
> diff --git a/qapi/qdev.json b/qapi/qdev.json
> index 2468f8bddf..37a8785b81 100644
> --- a/qapi/qdev.json
> +++ b/qapi/qdev.json
> @@ -329,3 +329,25 @@
> # Since: 8.2
> ##
> { 'command': 'x-device-sync-config', 'data': {'id': 'str'} }
> +
> +##
> +# @X_CONFIG_READ:
> +#
> +# Emitted whenever guest reads virtio device config after config change.
> +#
> +# @device: device name
> +#
> +# @path: device path
> +#
> +# Since: 5.0.1-24
> +#
> +# Example:
> +#
> +# <- { "event": "X_CONFIG_READ",
> +# "data": { "device": "virtio-net-pci-0",
> +# "path": "/machine/peripheral/virtio-net-pci-0" },
> +# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
> +#
> +##
> +{ 'event': 'X_CONFIG_READ',
> + 'data': { '*device': 'str', 'path': 'str' } }
The commit message talks about event CONFIG_READ, but you actually name
it x-device-sync-config.
I figure you use x- to signify "unstable". Please use feature flag
'unstable' for that. See docs/devel/qapi-code-gen.rst section
"Features", in particular "Special features", and also the note on x- in
section "Naming rules and reserved names".
The name CONFIG_READ feels overly generic for something that makes sense
only with virtio devices.
> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> index b485375049..d0f022e925 100644
> --- a/softmmu/qdev-monitor.c
> +++ b/softmmu/qdev-monitor.c
> @@ -1252,3 +1252,8 @@ void qdev_hotplug_device_on_event(DeviceState *dev)
> dev->device_on_event_sent = true;
> qapi_event_send_x_device_on(dev->id, dev->canonical_path);
> }
> +
> +void qdev_config_read_event(DeviceState *dev)
> +{
> + qapi_event_send_x_config_read(dev->id, dev->canonical_path);
> +}
- [PATCH 0/4] vhost-user-blk: live resize additional APIs, Vladimir Sementsov-Ogievskiy, 2023/10/06
- [PATCH 3/4] qapi: device-sync-config: check runstate, Vladimir Sementsov-Ogievskiy, 2023/10/06
- [PATCH 1/4] vhost-user-blk: simplify and fix vhost_user_blk_handle_config_change, Vladimir Sementsov-Ogievskiy, 2023/10/06
- [PATCH 4/4] qapi: introduce CONFIG_READ event, Vladimir Sementsov-Ogievskiy, 2023/10/06
- Re: [PATCH 4/4] qapi: introduce CONFIG_READ event,
Markus Armbruster <=
- Re: [PATCH 4/4] qapi: introduce CONFIG_READ event, Vladimir Sementsov-Ogievskiy, 2023/10/17
- Re: [PATCH 4/4] qapi: introduce CONFIG_READ event, Markus Armbruster, 2023/10/18
- Re: [PATCH 4/4] qapi: introduce CONFIG_READ event, Vladimir Sementsov-Ogievskiy, 2023/10/18
- Re: [PATCH 4/4] qapi: introduce CONFIG_READ event, Markus Armbruster, 2023/10/18
- Re: [PATCH 4/4] qapi: introduce CONFIG_READ event, Michael S. Tsirkin, 2023/10/18
- Re: [PATCH 4/4] qapi: introduce CONFIG_READ event, Daniel P . Berrangé, 2023/10/18
- Re: [PATCH 4/4] qapi: introduce CONFIG_READ event, Markus Armbruster, 2023/10/18
- Re: [PATCH 4/4] qapi: introduce CONFIG_READ event, Daniel P . Berrangé, 2023/10/18
- Re: [PATCH 4/4] qapi: introduce CONFIG_READ event, Dr. David Alan Gilbert, 2023/10/18
- Re: [PATCH 4/4] qapi: introduce CONFIG_READ event, Markus Armbruster, 2023/10/19