From: Stefano Garzarella <sgarzare@redhat.com>
To: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Cc: qemu-devel@nongnu.org, mst@redhat.com, farosas@suse.de,
peterx@redhat.com, dongli.zhang@oracle.com,
maciej.szmigiero@oracle.com, bchaney@akamai.com,
mark.kanda@oracle.com, den@openvz.org
Subject: Re: [PATCH v4 08/10] vhost: add vhost_dev_set_owner() / vhost_dev_reset_owner() helpers
Date: Mon, 7 Sep 2026 16:56:31 +0200 [thread overview]
Message-ID: <ap7I31Lch-pyql9J@sgarzare-redhat> (raw)
In-Reply-To: <20260820113955.509478-9-andrey.drobyshev@virtuozzo.com>
On Thu, Aug 20, 2026 at 02:39:53PM +0300, Andrey Drobyshev wrote:
>Wrap the set_owner/reset_owner backend ops in dev-level helpers, matching
>other vhost_dev_* wrappers, so device code can take or release ownership
>without reaching into vhost_ops directly. vhost_dev_init() now uses
>vhost_dev_set_owner(). Both return -ENOSYS if the backend has no such op.
>
>No functional change. These are used by the following vhost-vsock patch to
>hand a device between owners during CPR.
>
>Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
>---
> hw/virtio/vhost.c | 20 +++++++++++++++++++-
> include/hw/virtio/vhost.h | 13 +++++++++++++
> 2 files changed, 32 insertions(+), 1 deletion(-)
>
>diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
>index 2bb9a23fee4..ea17bf01080 100644
>--- a/hw/virtio/vhost.c
>+++ b/hw/virtio/vhost.c
>@@ -1690,6 +1690,24 @@ int vhost_dev_init_backend(struct vhost_dev *hdev, void *opaque,
> return 0;
> }
>
>+int vhost_dev_set_owner(struct vhost_dev *hdev)
>+{
>+ assert(hdev->vhost_ops);
>+ if (!hdev->vhost_ops->vhost_set_owner) {
>+ return -ENOSYS;
>+ }
>+ return hdev->vhost_ops->vhost_set_owner(hdev);
>+}
>+
>+int vhost_dev_reset_owner(struct vhost_dev *hdev)
>+{
>+ assert(hdev->vhost_ops);
>+ if (!hdev->vhost_ops->vhost_reset_owner) {
>+ return -ENOSYS;
>+ }
>+ return hdev->vhost_ops->vhost_reset_owner(hdev);
>+}
>+
> int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
> VhostBackendType backend_type, uint32_t busyloop_timeout,
> Error **errp)
>@@ -1707,7 +1725,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
> goto fail;
> }
>
>- r = hdev->vhost_ops->vhost_set_owner(hdev);
>+ r = vhost_dev_set_owner(hdev);
> if (r < 0) {
> error_setg_errno(errp, -r, "vhost_set_owner failed");
> goto fail;
>diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
>index 9b98d34dd04..44e65968d9b 100644
>--- a/include/hw/virtio/vhost.h
>+++ b/include/hw/virtio/vhost.h
>@@ -178,6 +178,19 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
> int vhost_dev_init_backend(struct vhost_dev *hdev, void *opaque,
> VhostBackendType backend_type, Error **errp);
>
>+/**
>+ * vhost_dev_set_owner() / vhost_dev_reset_owner() - take / release ownership
I'm not sure this is a common practice in kernel-doc format.
I think we should add 2 differnt blocks, one for each function.
Stefano
>+ * @hdev: the common vhost_dev structure
>+ *
>+ * Take (VHOST_SET_OWNER) or release (VHOST_RESET_OWNER) ownership of a
>+ * device that has already been set up. Used to hand a device over during
>+ * CPR. Returns -ENOSYS if the backend has no such op.
>+ *
>+ * Return: 0 on success, negative errno on failure.
>+ */
>+int vhost_dev_set_owner(struct vhost_dev *hdev);
>+int vhost_dev_reset_owner(struct vhost_dev *hdev);
>+
> /**
> * vhost_dev_cleanup() - tear down and cleanup vhost interface
> * @hdev: the common vhost_dev structure
>--
>2.47.1
>
next prev parent reply other threads:[~2026-09-07 14:56 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 11:39 [PATCH v4 00/10] migration/cpr: support vhost-vsock devices Andrey Drobyshev
2026-08-20 11:39 ` [PATCH v4 01/10] vhost-vsock: block CPR migration modes Andrey Drobyshev
2026-09-07 14:54 ` Stefano Garzarella
2026-08-20 11:39 ` [PATCH v4 02/10] vhost: add vhost_reset_owner op Andrey Drobyshev
2026-09-07 13:58 ` Stefano Garzarella
2026-09-09 16:59 ` Andrey Drobyshev
2026-08-20 11:39 ` [PATCH v4 03/10] vhost-vsock: don't reset connections during CPR Andrey Drobyshev
2026-09-07 14:54 ` Stefano Garzarella
2026-08-20 11:39 ` [PATCH v4 04/10] vhost-vsock: fix FD leak in realize() Andrey Drobyshev
2026-09-07 14:54 ` Stefano Garzarella
2026-09-09 16:59 ` Andrey Drobyshev
2026-08-20 11:39 ` [PATCH v4 05/10] vhost-vsock: preserve vhost FD during CPR Andrey Drobyshev
2026-09-07 14:55 ` Stefano Garzarella
2026-09-09 16:59 ` Andrey Drobyshev
2026-09-11 7:37 ` Stefano Garzarella
2026-09-11 16:35 ` Andrey Drobyshev
2026-08-20 11:39 ` [PATCH v4 06/10] vhost: factor out vhost_dev_init_backend() Andrey Drobyshev
2026-09-07 14:55 ` Stefano Garzarella
2026-08-20 11:39 ` [PATCH v4 07/10] vhost: make vhost_dev_cleanup() safe on a partially initialized device Andrey Drobyshev
2026-09-07 14:56 ` Stefano Garzarella
2026-09-09 17:06 ` Andrey Drobyshev
2026-08-20 11:39 ` [PATCH v4 08/10] vhost: add vhost_dev_set_owner() / vhost_dev_reset_owner() helpers Andrey Drobyshev
2026-09-07 14:56 ` Stefano Garzarella [this message]
2026-09-09 17:05 ` Andrey Drobyshev
2026-08-20 11:39 ` [PATCH v4 09/10] vhost: add vhost_dev_is_initialized() helper Andrey Drobyshev
2026-09-07 14:57 ` Stefano Garzarella
2026-08-20 11:39 ` [PATCH v4 10/10] vhost-vsock: hand off device ownership across CPR Andrey Drobyshev
2026-09-07 15:13 ` Stefano Garzarella
2026-09-09 17:45 ` Andrey Drobyshev
2026-09-11 7:45 ` Stefano Garzarella
2026-09-11 16:35 ` Andrey Drobyshev
2026-08-31 11:16 ` [PATCH v4 00/10] migration/cpr: support vhost-vsock devices Andrey Drobyshev
2026-09-07 10:07 ` Stefano Garzarella
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=ap7I31Lch-pyql9J@sgarzare-redhat \
--to=sgarzare@redhat.com \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=bchaney@akamai.com \
--cc=den@openvz.org \
--cc=dongli.zhang@oracle.com \
--cc=farosas@suse.de \
--cc=maciej.szmigiero@oracle.com \
--cc=mark.kanda@oracle.com \
--cc=mst@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/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.