From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com, sgarzare@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,
andrey.drobyshev@virtuozzo.com
Subject: [PATCH v3 6/7] vhost: add vhost_dev_set_owner() / vhost_dev_reset_owner() helpers
Date: Fri, 26 Jun 2026 19:46:42 +0300 [thread overview]
Message-ID: <20260626164643.2526-7-andrey.drobyshev@virtuozzo.com> (raw)
In-Reply-To: <20260626164643.2526-1-andrey.drobyshev@virtuozzo.com>
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 f11588cc51a..7ae2abe33cd 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1689,6 +1689,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)
@@ -1706,7 +1724,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 bc81e09663e..a56a2b66bd5 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -175,6 +175,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
+ * @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-06-26 16:47 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 16:46 [PATCH v3 0/7] migration/cpr: support vhost-vsock devices Andrey Drobyshev
2026-06-26 16:46 ` [PATCH v3 1/7] vhost: add vhost_reset_owner op Andrey Drobyshev
2026-06-26 16:46 ` [PATCH v3 2/7] vhost-vsock: don't reset connections during CPR Andrey Drobyshev
2026-06-26 16:46 ` [PATCH v3 3/7] vhost-vsock: fix FD leak in realize() Andrey Drobyshev
2026-06-26 16:46 ` [PATCH v3 4/7] vhost-vsock: preserve vhost FD during CPR Andrey Drobyshev
2026-08-18 15:29 ` Stefano Garzarella
2026-08-19 14:38 ` Andrey Drobyshev
2026-08-19 15:11 ` Michael S. Tsirkin
2026-08-19 15:22 ` Andrey Drobyshev
2026-08-19 18:53 ` Michael S. Tsirkin
2026-06-26 16:46 ` [PATCH v3 5/7] vhost: factor out vhost_dev_init_backend() Andrey Drobyshev
2026-08-18 15:29 ` Stefano Garzarella
2026-08-19 14:38 ` Andrey Drobyshev
2026-06-26 16:46 ` Andrey Drobyshev [this message]
2026-06-26 16:46 ` [PATCH v3 7/7] vhost-vsock: hand off device ownership across CPR Andrey Drobyshev
2026-08-18 15:30 ` Stefano Garzarella
2026-08-19 14:38 ` Andrey Drobyshev
2026-06-30 18:35 ` [PATCH v3 0/7] migration/cpr: support vhost-vsock devices Maciej S. Szmigiero
2026-08-11 14:12 ` Andrey Drobyshev
2026-08-18 11:02 ` Andrey Drobyshev
2026-08-18 15:33 ` Stefano Garzarella
2026-08-19 14:39 ` Andrey Drobyshev
2026-07-14 16:03 ` Vladimir Sementsov-Ogievskiy
2026-07-15 10:25 ` Andrey Drobyshev
2026-07-15 10:48 ` Vladimir Sementsov-Ogievskiy
2026-07-15 12:11 ` Andrey Drobyshev
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=20260626164643.2526-7-andrey.drobyshev@virtuozzo.com \
--to=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 \
--cc=sgarzare@redhat.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.