From: Markus Armbruster <armbru@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: mst@redhat.com, jasowang@redhat.com, pbonzini@redhat.com,
berrange@redhat.com, eduardo@habkost.net, peterx@redhat.com,
farosas@suse.de, eblake@redhat.com, thuth@redhat.com,
philmd@linaro.org, zhao1.liu@intel.com, qemu-devel@nongnu.org,
leiyang@redhat.com, davydov-max@yandex-team.ru,
yc-core@yandex-team.ru, raphael.s.norwitz@gmail.com
Subject: Re: [PATCH v9 2/8] qapi: introduce query-backend-transfer-support
Date: Thu, 06 Nov 2025 16:30:25 +0100 [thread overview]
Message-ID: <87jz03fab2.fsf@pond.sub.org> (raw)
In-Reply-To: <20251030203116.870742-3-vsementsov@yandex-team.ru> (Vladimir Sementsov-Ogievskiy's message of "Thu, 30 Oct 2025 23:31:09 +0300")
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
> We are going to implement backend-transfer feature: some devices
> will be able to transfer their backend through migration stream
> for local migration through UNIX domain socket. For example,
> virtio-net will migrate its attached TAP netdev, with all its
> connected file descriptors.
>
> Let's add a command to list supporting devices (no one for now),
> together with necessary infrastructure in qdev code.
Use case?
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
> include/hw/qdev-core.h | 7 +++++++
> qapi/qdev.json | 26 +++++++++++++++++++++++++
> system/qdev-monitor.c | 43 ++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 76 insertions(+)
>
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 2caa0cbd26..0551fbaa6c 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -96,6 +96,7 @@ typedef void (*DeviceReset)(DeviceState *dev);
> typedef void (*BusRealize)(BusState *bus, Error **errp);
> typedef void (*BusUnrealize)(BusState *bus);
> typedef int (*DeviceSyncConfig)(DeviceState *dev, Error **errp);
> +typedef bool (*DeviceSupportBackendTransfer)(DeviceState *dev, Error **errp);
>
> /**
> * struct DeviceClass - The base class for all devices.
> @@ -174,6 +175,12 @@ struct DeviceClass {
> DeviceUnrealize unrealize;
> DeviceSyncConfig sync_config;
>
> + /**
> + * @backend_transfer_support: reports support for backend-transfer
> + * migration of the device.
> + */
> + DeviceSupportBackendTransfer backend_transfer_support;
> +
> /**
> * @vmsd: device state serialisation description for
> * migration/save/restore
> diff --git a/qapi/qdev.json b/qapi/qdev.json
> index e14a0c9259..d7e878d58d 100644
> --- a/qapi/qdev.json
> +++ b/qapi/qdev.json
> @@ -188,3 +188,29 @@
> { 'command': 'device-sync-config',
> 'features': [ 'unstable' ],
> 'data': {'id': 'str'} }
> +
> +##
> +# @DevPath:
> +#
> +# @path: the device's QOM path
> +#
> +# Since: 10.2
> +##
> +{ 'struct': 'DevPath',
> + 'data': { 'path': 'str' } }
> +
> +##
> +# @query-backend-transfer-support:
> +#
> +# Returns list of devices, supporting backend-transfer
> +# migration.
Suggest
# Return the devices that support backend-transfer migration.
> +#
> +# Features:
> +#
> +# @unstable: The command is experimental.
The conventional text ist "This command is experimental."
> +#
> +# Since: 10.2
> +##
> +{ 'command': 'query-backend-transfer-support',
> + 'features': [ 'unstable' ],
> + 'returns': [ 'DevPath' ] }
> diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
> index ec4a2394ce..9d3d961c15 100644
> --- a/system/qdev-monitor.c
> +++ b/system/qdev-monitor.c
> @@ -939,6 +939,49 @@ void qmp_device_del(const char *id, Error **errp)
> }
> }
>
> +static bool qdev_backend_transfer_support(DeviceState *dev, Error **errp)
> +{
> + DeviceClass *dc = DEVICE_GET_CLASS(dev);
> +
> + if (!dc->backend_transfer_support) {
> + error_setg(errp, "backend-transfer is not supported for '%s'",
> + object_get_typename(OBJECT(dev)));
> + return false;
> + }
> +
> + return dc->backend_transfer_support(dev, errp);
> +}
@errp is useless in this patch: the only caller passes NULL. Took me a
minute to check it doesn't remain useless. The next patch puts it to
use.
> +
> +static int qdev_add_if_backend_transfer_supported(Object *obj, void *opaque)
> +{
> + DevPathList **list = opaque;
> + DeviceState *dev = (DeviceState *)object_dynamic_cast(obj, TYPE_DEVICE);
> +
> + if (dev != NULL && qdev_backend_transfer_support(dev, NULL)) {
> + DevPath *el = g_new(DevPath, 1);
> + *el = (DevPath) {
> + .path = g_strdup(dev->canonical_path),
> + };
> + QAPI_LIST_PREPEND(*list, el);
> + }
> +
> + /* Recursively check all children */
> + object_child_foreach(obj, qdev_add_if_backend_transfer_supported, opaque);
> +
> + return 0;
> +}
> +
> +DevPathList *qmp_query_backend_transfer_support(Error **errp)
> +{
> + DevPathList *result = NULL;
> + Object *peripheral = machine_get_container("peripheral");
> +
> + object_child_foreach(peripheral, qdev_add_if_backend_transfer_supported,
> + &result);
> +
> + return result;
> +}
> +
> int qdev_sync_config(DeviceState *dev, Error **errp)
> {
> DeviceClass *dc = DEVICE_GET_CLASS(dev);
next prev parent reply other threads:[~2025-11-06 15:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 20:31 [PATCH v9 0/8] virtio-net: live-TAP local migration Vladimir Sementsov-Ogievskiy
2025-10-30 20:31 ` [PATCH v9 1/8] migration: introduce .pre_incoming() vmsd handler Vladimir Sementsov-Ogievskiy
2025-10-30 20:31 ` [PATCH v9 2/8] qapi: introduce query-backend-transfer-support Vladimir Sementsov-Ogievskiy
2025-11-06 15:30 ` Markus Armbruster [this message]
2025-11-06 19:27 ` Vladimir Sementsov-Ogievskiy
2025-11-07 5:28 ` Markus Armbruster
2025-11-07 6:09 ` Vladimir Sementsov-Ogievskiy
2025-10-30 20:31 ` [PATCH v9 3/8] qapi: add backend-transfer migration parameter Vladimir Sementsov-Ogievskiy
2025-11-06 15:44 ` Markus Armbruster
2025-10-30 20:31 ` [PATCH v9 4/8] net: introduce vmstate_net_peer_backend Vladimir Sementsov-Ogievskiy
2025-10-30 20:31 ` [PATCH v9 5/8] virtio-net: support backend-transfer migration Vladimir Sementsov-Ogievskiy
2025-10-30 20:31 ` [PATCH v9 6/8] net/tap: " Vladimir Sementsov-Ogievskiy
2025-10-30 20:31 ` [PATCH v9 7/8] tests/functional: add skipWithoutSudo() decorator Vladimir Sementsov-Ogievskiy
2025-10-30 20:31 ` [PATCH v9 8/8] tests/functional: add test_tap_migration Vladimir Sementsov-Ogievskiy
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=87jz03fab2.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=davydov-max@yandex-team.ru \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=farosas@suse.de \
--cc=jasowang@redhat.com \
--cc=leiyang@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=raphael.s.norwitz@gmail.com \
--cc=thuth@redhat.com \
--cc=vsementsov@yandex-team.ru \
--cc=yc-core@yandex-team.ru \
--cc=zhao1.liu@intel.com \
/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.