From: Markus Armbruster <armbru@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
eblake@redhat.com, dave@treblig.org, eduardo@habkost.net,
berrange@redhat.com, pbonzini@redhat.com, hreitz@redhat.com,
kwolf@redhat.com, raphael.norwitz@nutanix.com, mst@redhat.com,
yc-core@yandex-team.ru, den-plotnikov@yandex-team.ru,
daniil.tatianin@yandex.ru
Subject: Re: [PATCH 2/4] qapi: introduce device-sync-config
Date: Wed, 18 Oct 2023 08:08:49 +0200 [thread overview]
Message-ID: <87ttqozclq.fsf@pond.sub.org> (raw)
In-Reply-To: <9d62a50e-627e-4441-b760-56c096f99c53@yandex-team.ru> (Vladimir Sementsov-Ogievskiy's message of "Tue, 17 Oct 2023 18:32:00 +0300")
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
> On 17.10.23 17:57, Markus Armbruster wrote:
>> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
>>
>>> Add command to sync config from vhost-user backend to the device. It
>>> may be helpful when VHOST_USER_SLAVE_CONFIG_CHANGE_MSG failed or not
>>> triggered interrupt to the guest or just not available (not supported
>>> by vhost-user server).
>>>
>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>> [...]
>>
>>> diff --git a/qapi/qdev.json b/qapi/qdev.json
>>> index fa80694735..2468f8bddf 100644
>>> --- a/qapi/qdev.json
>>> +++ b/qapi/qdev.json
>>> @@ -315,3 +315,17 @@
>>> # Since: 8.2
>>> ##
>>> { 'event': 'X_DEVICE_ON', 'data': 'DeviceAndPath' }
>>> +
>>> +##
>>> +# @x-device-sync-config:
>>> +#
>>> +# Sync config from backend to the guest.
>>
>> "Sync" is not a word; "synchronize" is :)
>
> Seems, I learn English from code :)
It's working, so no worries ;)
>>> +#
>>> +# @id: the device's ID or QOM path
>>> +#
>>> +# Returns: Nothing on success
>>> +# If @id is not a valid device, DeviceNotFound
>>
>> Why not GenericError?
>
> I just designed the command looking at device_del. device_del reports DeviceNotFound in this case. GenericError is OK for me, if you think it's better even in this case. I remember now that everything except GenericError is not recommended.
I figure you picked up DeviceNotFound by reusing find_device_state().
Same happened when commit 9680caee0fa added blk_by_qdev_id(). At least
some of its users don't document the error code. I'm not sure the
unwanted use of DeviceNotFound is worth fixing after all this time. But
I certainly don't want it documented.
For your patch, not reusing find_device_state() would let you avoid
DeviceNotFound at the price of a few more lines of code.
>>> +#
>>> +# Since: 8.2
>>> +##
>>> +{ 'command': 'x-device-sync-config', 'data': {'id': 'str'} }
>>
>> The commit message above and the error message below talk about command
>> device-sync-config, 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".
>>
>> We tend to eschew abbreviations in QAPI schema names.
>> device-synchronize-config is quite a mouthful, though. What do you
>> think?
>
> OK for me.
>
> Hmm, could I ask here, is "config" a word?)) device-synchronize-configuration would become a precedent, I'm afraid)
In the words of Captain Barbossa, it's "more what you'd call
'guidelines' than actual rules."
I didn't come up with the "avoid abbreviations" stylistic guideline. I
inherited it.
I do like consistent style. I don't like excessively long names.
Sometimes these likes conflict, and we need to pick.
Checking... alright, there precedence both for 'config' and for 'sync'
in the QAPI schema. You pick what you like best.
>>> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
>>> index 19c31446d8..b6da24389f 100644
>>> --- a/softmmu/qdev-monitor.c
>>> +++ b/softmmu/qdev-monitor.c
>>> @@ -987,6 +987,29 @@ HotplugInfo *qmp_x_query_hotplug(const char *id, Error **errp)
>>> return hotplug_handler_get_state(hotplug_ctrl, dev, errp);
>>> }
>>> +int qdev_sync_config(DeviceState *dev, Error **errp)
>>> +{
>>> + DeviceClass *dc = DEVICE_GET_CLASS(dev);
>>> +
>>> + if (!dc->sync_config) {
>>> + error_setg(errp, "device-sync-config is not supported for '%s'",
>>> + object_get_typename(OBJECT(dev)));
>>> + return -ENOTSUP;
>>> + }
>>> +
>>> + return dc->sync_config(dev, errp);
>>> +}
>>> +
>>> +void qmp_x_device_sync_config(const char *id, Error **errp)
>>> +{
>>> + DeviceState *dev = find_device_state(id, errp);
>>
>> Not your patch's fault, but here goes anyway: when @id refers to a
>> non-device, find_device_state() fails with "is not a hotpluggable
>> device". "hotpluggable" is misleading.
>
> Hmm. Thanks, OK, I'll rework it somehow in v2.
I think "hotpluggable" is misleading for all the existing uses of
find_device_state(). Suggest a preliminary patch deleting the word.
>>> + if (!dev) {
>>> + return;
>>> + }
>>> +
>>> + qdev_sync_config(dev, errp);
>>> +}
>>> +
>>> void hmp_device_add(Monitor *mon, const QDict *qdict)
>>> {
>>> Error *err = NULL;
>>
next prev parent reply other threads:[~2023-10-18 6:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-06 20:20 [PATCH 0/4] vhost-user-blk: live resize additional APIs Vladimir Sementsov-Ogievskiy
2023-10-06 20:20 ` [PATCH 1/4] vhost-user-blk: simplify and fix vhost_user_blk_handle_config_change Vladimir Sementsov-Ogievskiy
2023-10-23 9:31 ` Raphael Norwitz
2023-10-06 20:20 ` [PATCH 2/4] qapi: introduce device-sync-config Vladimir Sementsov-Ogievskiy
2023-10-17 14:57 ` Markus Armbruster
2023-10-17 15:32 ` Vladimir Sementsov-Ogievskiy
2023-10-18 6:08 ` Markus Armbruster [this message]
2023-10-06 20:20 ` [PATCH 3/4] qapi: device-sync-config: check runstate Vladimir Sementsov-Ogievskiy
2023-10-06 20:20 ` [PATCH 4/4] qapi: introduce CONFIG_READ event Vladimir Sementsov-Ogievskiy
2023-10-17 15:00 ` Markus Armbruster
2023-10-17 15:44 ` Vladimir Sementsov-Ogievskiy
2023-10-18 6:47 ` Markus Armbruster
2023-10-18 8:51 ` Vladimir Sementsov-Ogievskiy
2023-10-18 10:36 ` Markus Armbruster
2023-10-18 10:51 ` Michael S. Tsirkin
2023-10-18 10:59 ` Daniel P. Berrangé
2023-10-18 12:02 ` Markus Armbruster
2023-10-18 12:07 ` Daniel P. Berrangé
2023-10-18 14:33 ` Dr. David Alan Gilbert
2023-10-19 7:05 ` Markus Armbruster
2023-10-19 7:10 ` Markus Armbruster
2023-10-18 12:39 ` Vladimir Sementsov-Ogievskiy
2023-10-19 7:01 ` Markus Armbruster
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=87ttqozclq.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=daniil.tatianin@yandex.ru \
--cc=dave@treblig.org \
--cc=den-plotnikov@yandex-team.ru \
--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.norwitz@nutanix.com \
--cc=vsementsov@yandex-team.ru \
--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.