All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-block@nongnu.org, raphael@enfabrica.net, mst@redhat.com,
	kwolf@redhat.com, hreitz@redhat.com, pbonzini@redhat.com,
	berrange@redhat.com, eduardo@habkost.net, dave@treblig.org,
	eblake@redhat.com, qemu-devel@nongnu.org, yc-core@yandex-team.ru
Subject: Re: [PATCH v3 5/5] qapi: introduce CONFIG_READ event
Date: Mon, 29 Apr 2024 12:02:51 +0300	[thread overview]
Message-ID: <539ee069-39ab-432e-b6ee-29221d372c0f@yandex-team.ru> (raw)
In-Reply-To: <87a5ljvu3b.fsf@pond.sub.org>

On 24.04.24 15:11, Markus Armbruster wrote:
> 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 |  2 ++
>>   monitor/monitor.c      |  1 +
>>   qapi/qdev.json         | 33 +++++++++++++++++++++++++++++++++
>>   stubs/qdev.c           |  6 ++++++
>>   system/qdev-monitor.c  |  6 ++++++
>>   6 files changed, 57 insertions(+)
>>
>> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
>> index 92afbae71c..c0c158dae2 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"
>> @@ -530,6 +531,10 @@ static uint64_t virtio_pci_config_read(void *opaque, hwaddr addr,
>>       }
>>       addr -= config;
>>   
>> +    if (vdev->generation > 0) {
>> +        qdev_virtio_config_read_event(DEVICE(proxy));
>> +    }
>> +
>>       switch (size) {
>>       case 1:
>>           val = virtio_config_readb(vdev, addr);
>> @@ -1884,6 +1889,10 @@ static uint64_t virtio_pci_device_read(void *opaque, hwaddr addr,
>>           return UINT64_MAX;
>>       }
>>   
>> +    if (vdev->generation > 0) {
>> +        qdev_virtio_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 1d57bf6577..fc9a834dca 100644
>> --- a/include/monitor/qdev.h
>> +++ b/include/monitor/qdev.h
>> @@ -36,4 +36,6 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
>>    */
>>   const char *qdev_set_id(DeviceState *dev, char *id, Error **errp);
>>   
>> +void qdev_virtio_config_read_event(DeviceState *dev);
>> +
>>   #endif
>> diff --git a/monitor/monitor.c b/monitor/monitor.c
>> index 01ede1babd..5b06146503 100644
>> --- a/monitor/monitor.c
>> +++ b/monitor/monitor.c
>> @@ -316,6 +316,7 @@ static MonitorQAPIEventConf monitor_qapi_event_conf[QAPI_EVENT__MAX] = {
>>       [QAPI_EVENT_VSERPORT_CHANGE]   = { 1000 * SCALE_MS },
>>       [QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE] = { 1000 * SCALE_MS },
>>       [QAPI_EVENT_HV_BALLOON_STATUS_REPORT] = { 1000 * SCALE_MS },
>> +    [QAPI_EVENT_VIRTIO_CONFIG_READ] = { 300 * SCALE_MS },
> 
> All the other rate-limited events use 1s.  Why 0.3s for this one?

No actual reason, just seemed to me that 1s is too much. Should be better to keep all limits to be the same, until no concrete reason to break it.

> 
>>   };
>>   
>>   /*
>> diff --git a/qapi/qdev.json b/qapi/qdev.json
>> index e8be79c3d5..29a4f47360 100644
>> --- a/qapi/qdev.json
>> +++ b/qapi/qdev.json
>> @@ -182,3 +182,36 @@
>>   { 'command': 'device-sync-config',
>>     'features': [ 'unstable' ],
>>     'data': {'id': 'str'} }
>> +
>> +##
>> +# @VIRTIO_CONFIG_READ:
>> +#
>> +# Emitted whenever guest reads virtio device configuration after
>> +# configuration change.
> 
> Is it emitted whenever the guest reads, or only when it reads after a
> configuration change?

Hmm, it's emitted only when vdev->generation > 0, which generally mean that there was at least one call to virtio_notify_config()... That's not the logic, which could be simply described here.


Actually, now I think that event was a premature improvement. In our final downstream solution only the command device-sync-config is used, not the event. I see that the concept of the event is objectionable, I think, I'll better just drop it in v4.

> 
>> +#
>> +# The event may be used in pair with device-sync-config. It shows
>> +# that guest has re-read updated configuration. It doesn't
>> +# guarantee that guest successfully handled it and updated the
>> +# view of the device for the user, but still it's a kind of
>> +# success indicator.
> 
> The event is virtio-only.  device-sync-config isn't.  Why?
> 
>> +#
>> +# @device: device name
>> +#
>> +# @path: device path
>> +#
>> +# Features:
>> +#
>> +# @unstable: The event is experimental.
>> +#
> 
> Missing:
> 
>     # Note: This event is rate-limited.
>     #
> 
>> +# Since: 9.1
>> +#
>> +# Example:
>> +#
>> +#     <- { "event": "VIRTIO_CONFIG_READ",
>> +#          "data": { "device": "virtio-net-pci-0",
>> +#                    "path": "/machine/peripheral/virtio-net-pci-0" },
>> +#          "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
>> +##
>> +{ 'event': 'VIRTIO_CONFIG_READ',
>> +  'features': [ 'unstable' ],
>> +  'data': { '*device': 'str', 'path': 'str' } }
>> diff --git a/stubs/qdev.c b/stubs/qdev.c
>> index 6869f6f90a..ab6c4afe0b 100644
>> --- a/stubs/qdev.c
>> +++ b/stubs/qdev.c
>> @@ -26,3 +26,9 @@ void qapi_event_send_device_unplug_guest_error(const char *device,
>>   {
>>       /* Nothing to do. */
>>   }
>> +
>> +void qapi_event_send_virtio_config_read(const char *device,
>> +                                        const char *path)
>> +{
>> +    /* Nothing to do. */
>> +}
>> diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
>> index cb35ea0b86..8a2ca77fde 100644
>> --- a/system/qdev-monitor.c
>> +++ b/system/qdev-monitor.c
>> @@ -26,6 +26,7 @@
>>   #include "sysemu/runstate.h"
>>   #include "qapi/error.h"
>>   #include "qapi/qapi-commands-qdev.h"
>> +#include "qapi/qapi-events-qdev.h"
>>   #include "qapi/qmp/dispatch.h"
>>   #include "qapi/qmp/qdict.h"
>>   #include "qapi/qmp/qerror.h"
>> @@ -1206,3 +1207,8 @@ bool qmp_command_available(const QmpCommand *cmd, Error **errp)
>>       }
>>       return true;
>>   }
>> +
>> +void qdev_virtio_config_read_event(DeviceState *dev)
>> +{
>> +    qapi_event_send_virtio_config_read(dev->id, dev->canonical_path);
>> +}
> 
> Which configuration needs the stub?
> 

-- 
Best regards,
Vladimir



      reply	other threads:[~2024-04-29  9:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-29 18:37 [PATCH v3 0/5] vhost-user-blk: live resize additional APIs Vladimir Sementsov-Ogievskiy
2024-03-29 18:37 ` [PATCH v3 1/5] vhost-user-blk: simplify and fix vhost_user_blk_handle_config_change Vladimir Sementsov-Ogievskiy
2024-03-29 18:37 ` [PATCH v3 2/5] qdev-monitor: fix error message in find_device_state() Vladimir Sementsov-Ogievskiy
2024-03-29 18:37 ` [PATCH v3 3/5] qdev-monitor: add option to report GenericError from find_device_state Vladimir Sementsov-Ogievskiy
2024-03-29 18:37 ` [PATCH v3 4/5] qapi: introduce device-sync-config Vladimir Sementsov-Ogievskiy
2024-04-24 11:48   ` Markus Armbruster
2024-04-29  8:18     ` Vladimir Sementsov-Ogievskiy
2024-04-29 10:51       ` Markus Armbruster
2024-04-29 12:22         ` Vladimir Sementsov-Ogievskiy
2024-04-29 13:04           ` Markus Armbruster
2024-04-29 14:49             ` Vladimir Sementsov-Ogievskiy
2024-04-24 12:05   ` Markus Armbruster
2024-03-29 18:37 ` [PATCH v3 5/5] qapi: introduce CONFIG_READ event Vladimir Sementsov-Ogievskiy
2024-04-24 12:11   ` Markus Armbruster
2024-04-29  9:02     ` Vladimir Sementsov-Ogievskiy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=539ee069-39ab-432e-b6ee-29221d372c0f@yandex-team.ru \
    --to=vsementsov@yandex-team.ru \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dave@treblig.org \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael@enfabrica.net \
    --cc=yc-core@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.