From: Connor Kite <connorkite@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
"Stefano Garzarella" <sgarzare@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Mathieu Poirier" <mathieu.poirier@linaro.org>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Raphael Norwitz" <rnorwitz@nvidia.com>,
"Kevin Wolf" <kwolf@redhat.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Fam Zheng" <fam@euphon.net>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Milan Zamazal" <mzamazal@redhat.com>,
"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>,
"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
qemu-block@nongnu.org, virtio-fs@lists.linux.dev,
"Gonglei (Arei)" <arei.gonglei@huawei.com>,
"zhenwei pi" <zhenwei.pi@linux.dev>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Jason Wang" <jasowangio@gmail.com>,
"Peter Xu" <peterx@redhat.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Alyssa Ross" <hi@alyssa.is>,
"Demi Marie Obenour" <demiobenour@gmail.com>,
"Connor Kite" <connorkite@gmail.com>,
20260817233147.2867623-1-connorkite@gmail.com
Subject: [PATCH RFC v2 06/13] vhost-user: add memory_isolation to VhostUserState
Date: Mon, 17 Aug 2026 22:12:21 -0700 [thread overview]
Message-ID: <20260817-vhost-user-isolated-memory-v2-6-948aae960abb@gmail.com> (raw)
In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com>
Add a memory_isolation bool to the VhostUserState struct. This
bool is set within vhost_user_init(), which takes a
memory_isolation bool as an argument.
Refactor all call locations of vhost_user_init to include the new
argument.
Signed-off-by: Connor Kite <connorkite@gmail.com>
---
backends/cryptodev-vhost-user.c | 2 +-
backends/vhost-user.c | 4 ++--
hw/block/vhost-user-blk.c | 3 ++-
hw/display/vhost-user-gpu.c | 3 ++-
hw/scsi/vhost-user-scsi.c | 3 ++-
hw/virtio/vhost-stub.c | 3 ++-
hw/virtio/vhost-user-base.c | 3 ++-
hw/virtio/vhost-user-fs.c | 3 ++-
hw/virtio/vhost-user-scmi.c | 3 ++-
hw/virtio/vhost-user-vsock.c | 3 ++-
hw/virtio/vhost-user.c | 5 ++++-
include/hw/virtio/vhost-user.h | 6 +++++-
include/system/vhost-user-backend.h | 3 ++-
net/passt.c | 14 ++++++++++----
net/vhost-user.c | 8 +++++---
15 files changed, 45 insertions(+), 21 deletions(-)
diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index cc478d9902..fa1f9b76d3 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -213,7 +213,7 @@ static void cryptodev_vhost_user_init(
}
}
- if (!vhost_user_init(&s->vhost_user, &s->chr, errp)) {
+ if (!vhost_user_init(&s->vhost_user, &s->chr, false, errp)) {
return;
}
diff --git a/backends/vhost-user.c b/backends/vhost-user.c
index 380d825023..470eba1775 100644
--- a/backends/vhost-user.c
+++ b/backends/vhost-user.c
@@ -22,13 +22,13 @@
int
vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
- unsigned nvqs, Error **errp)
+ unsigned nvqs, bool memory_isolation, Error **errp)
{
int ret;
assert(!b->vdev && vdev);
- if (!vhost_user_init(&b->vhost_user, &b->chr, errp)) {
+ if (!vhost_user_init(&b->vhost_user, &b->chr, memory_isolation, errp)) {
return -1;
}
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 2e5b3ae1b1..4640d7da04 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -505,7 +505,8 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
return;
}
- if (!vhost_user_init(&s->vhost_user, &s->chardev, errp)) {
+ if (!vhost_user_init(&s->vhost_user, &s->chardev,
+ false, errp)) {
return;
}
diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c
index cd684d6363..6655585b43 100644
--- a/hw/display/vhost-user-gpu.c
+++ b/hw/display/vhost-user-gpu.c
@@ -663,7 +663,8 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error **errp)
VirtIODevice *vdev = VIRTIO_DEVICE(g);
vhost_dev_set_config_notifier(&g->vhost->dev, &config_ops);
- if (vhost_user_backend_dev_init(g->vhost, vdev, 2, errp) < 0) {
+ if (vhost_user_backend_dev_init(g->vhost, vdev, 2, false,
+ errp) < 0) {
return;
}
diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index 5070178dc2..05bc788304 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -276,7 +276,8 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
return;
}
- if (!vhost_user_init(&s->vhost_user, &vs->conf.chardev, errp)) {
+ if (!vhost_user_init(&s->vhost_user, &vs->conf.chardev,
+ false, errp)) {
goto free_virtio;
}
diff --git a/hw/virtio/vhost-stub.c b/hw/virtio/vhost-stub.c
index 7321dc9210..d1e1075a31 100644
--- a/hw/virtio/vhost-stub.c
+++ b/hw/virtio/vhost-stub.c
@@ -12,7 +12,8 @@ unsigned int vhost_get_free_memslots(void)
return UINT_MAX;
}
-bool vhost_user_init(VhostUserState *user, CharFrontend *chr, Error **errp)
+bool vhost_user_init(VhostUserState *user, CharFrontend *chr,
+ bool memory_isolation, Error **errp)
{
return false;
}
diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c
index 90bd2903db..c10851492a 100644
--- a/hw/virtio/vhost-user-base.c
+++ b/hw/virtio/vhost-user-base.c
@@ -317,7 +317,8 @@ static void vub_device_realize(DeviceState *dev, Error **errp)
vub->vhost_user.supports_config = true;
}
- if (!vhost_user_init(&vub->vhost_user, &vub->chardev, errp)) {
+ if (!vhost_user_init(&vub->vhost_user, &vub->chardev,
+ false, errp)) {
return;
}
diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
index 209993918a..34ccbdec10 100644
--- a/hw/virtio/vhost-user-fs.c
+++ b/hw/virtio/vhost-user-fs.c
@@ -238,7 +238,8 @@ static void vuf_device_realize(DeviceState *dev, Error **errp)
return;
}
- if (!vhost_user_init(&fs->vhost_user, &fs->conf.chardev, errp)) {
+ if (!vhost_user_init(&fs->vhost_user, &fs->conf.chardev,
+ false, errp)) {
return;
}
diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c
index 02dc088ea9..bd0ec64daf 100644
--- a/hw/virtio/vhost-user-scmi.c
+++ b/hw/virtio/vhost-user-scmi.c
@@ -244,7 +244,8 @@ static void vu_scmi_device_realize(DeviceState *dev, Error **errp)
vdev->host_features |= (1ULL << VIRTIO_SCMI_F_P2A_CHANNELS);
- if (!vhost_user_init(&scmi->vhost_user, &scmi->chardev, errp)) {
+ if (!vhost_user_init(&scmi->vhost_user, &scmi->chardev,
+ false, errp)) {
return;
}
diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c
index c2cd376e73..44a90c76ad 100644
--- a/hw/virtio/vhost-user-vsock.c
+++ b/hw/virtio/vhost-user-vsock.c
@@ -106,7 +106,8 @@ static void vuv_device_realize(DeviceState *dev, Error **errp)
return;
}
- if (!vhost_user_init(&vsock->vhost_user, &vsock->conf.chardev, errp)) {
+ if (!vhost_user_init(&vsock->vhost_user, &vsock->conf.chardev,
+ false, errp)) {
return;
}
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 2881cec72d..1c003e4d9d 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -3121,13 +3121,16 @@ static void vhost_user_state_destroy(gpointer data)
vhost_user_host_notifier_remove(n, NULL, true);
}
-bool vhost_user_init(VhostUserState *user, CharFrontend *chr, Error **errp)
+bool vhost_user_init(VhostUserState *user, CharFrontend *chr,
+ bool memory_isolation,
+ Error **errp)
{
if (user->chr) {
error_setg(errp, "Cannot initialize vhost-user state");
return false;
}
user->chr = chr;
+ user->memory_isolation = memory_isolation;
user->memory_slots = 0;
user->notifiers = g_ptr_array_new_full(VIRTIO_QUEUE_MAX / 4,
&vhost_user_state_destroy);
diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h
index 06c360af18..0eca9b1668 100644
--- a/include/hw/virtio/vhost-user.h
+++ b/include/hw/virtio/vhost-user.h
@@ -66,6 +66,7 @@ typedef struct VhostUserHostNotifier {
* @chr: the character backend for the socket
* @notifiers: GPtrArray of @VhostUserHostnotifier
* @memory_slots:
+ * @memory_isolation: determines whether data is shared or copied
*/
typedef struct VhostUserState {
CharFrontend *chr;
@@ -73,12 +74,14 @@ typedef struct VhostUserState {
int memory_slots;
bool supports_config;
bool supports_inflight_migration;
+ bool memory_isolation;
} VhostUserState;
/**
* vhost_user_init() - initialise shared vhost_user state
* @user: allocated area for storing shared state
* @chr: the chardev for the vhost socket
+ * @memory_isolation: restrict direct access to guest memory from back-end
* @errp: error handle
*
* User can either directly g_new() space for the state or embed
@@ -87,7 +90,8 @@ typedef struct VhostUserState {
*
* Return: true on success, false on error while setting errp.
*/
-bool vhost_user_init(VhostUserState *user, CharFrontend *chr, Error **errp);
+bool vhost_user_init(VhostUserState *user, CharFrontend *chr,
+ bool memory_isolation, Error **errp);
/**
* vhost_user_cleanup() - cleanup state
diff --git a/include/system/vhost-user-backend.h b/include/system/vhost-user-backend.h
index 3184c8e799..c23f689182 100644
--- a/include/system/vhost-user-backend.h
+++ b/include/system/vhost-user-backend.h
@@ -41,7 +41,8 @@ struct VhostUserBackend {
};
int vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
- unsigned nvqs, Error **errp);
+ unsigned nvqs, bool memory_isolation,
+ Error **errp);
void vhost_user_backend_start(VhostUserBackend *b);
int vhost_user_backend_stop(VhostUserBackend *b);
diff --git a/net/passt.c b/net/passt.c
index 45440c399b..35ec6ad6de 100644
--- a/net/passt.c
+++ b/net/passt.c
@@ -433,7 +433,9 @@ static void passt_vhost_user_event(void *opaque, QEMUChrEvent event)
}
}
-static int net_passt_vhost_user_init(NetPasstState *s, Error **errp)
+static int net_passt_vhost_user_init(NetPasstState *s,
+ bool memory_isolation,
+ Error **errp)
{
Chardev *chr;
int sv[2];
@@ -457,7 +459,8 @@ static int net_passt_vhost_user_init(NetPasstState *s, Error **errp)
s->vhost_user = g_new0(struct VhostUserState, 1);
if (!qemu_chr_fe_init(&s->vhost_chr, chr, errp) ||
- !vhost_user_init(s->vhost_user, &s->vhost_chr, errp)) {
+ !vhost_user_init(s->vhost_user, &s->vhost_chr, memory_isolation,
+ errp)) {
goto err;
}
@@ -487,7 +490,8 @@ err:
return -1;
}
#else
-static int net_passt_vhost_user_init(NetPasstState *s, Error **errp)
+static int net_passt_vhost_user_init(NetPasstState *s, bool memory_isolation,
+ Error **errp)
{
error_setg(errp, "vhost-user support has not been built");
@@ -735,7 +739,9 @@ int net_init_passt(const Netdev *netdev, const char *name,
s->pidfile = pidfile;
if (netdev->u.passt.has_vhost_user && netdev->u.passt.vhost_user) {
- if (net_passt_vhost_user_init(s, errp) == -1) {
+ bool memory_isolation = false;
+
+ if (net_passt_vhost_user_init(s, memory_isolation, errp) == -1) {
qemu_del_net_client(nc);
return -1;
}
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 2d0fc49b4d..b6ee9ed297 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -370,7 +370,7 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
static int net_vhost_user_init(NetClientState *peer, const char *device,
const char *name, Chardev *chr,
- int queues)
+ int queues, bool memory_isolation)
{
Error *err = NULL;
NetClientState *nc, *nc0 = NULL;
@@ -390,7 +390,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
nc0 = nc;
s = DO_UPCAST(NetVhostUserState, nc, nc);
if (!qemu_chr_fe_init(&s->chr, chr, &err) ||
- !vhost_user_init(user, &s->chr, &err)) {
+ !vhost_user_init(user, &s->chr, memory_isolation, &err)) {
error_report_err(err);
goto err;
}
@@ -459,6 +459,7 @@ int net_init_vhost_user(const Netdev *netdev, const char *name,
int queues;
const NetdevVhostUserOptions *vhost_user_opts;
Chardev *chr;
+ bool memory_isolation = false;
assert(netdev->type == NET_CLIENT_DRIVER_VHOST_USER);
vhost_user_opts = &netdev->u.vhost_user;
@@ -476,5 +477,6 @@ int net_init_vhost_user(const Netdev *netdev, const char *name,
return -1;
}
- return net_vhost_user_init(peer, "vhost_user", name, chr, queues);
+ return net_vhost_user_init(peer, "vhost_user", name, chr, queues,
+ memory_isolation);
}
--
2.43.0
next prev parent reply other threads:[~2026-08-18 5:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 5:12 [PATCH RFC v2 00/13] vhost-user: isolated memory Connor Kite
2026-08-18 5:12 ` [PATCH RFC v2 01/13] vhost-user: Consolidate chardev property definitions Connor Kite
2026-08-18 5:12 ` [PATCH RFC v2 02/13] util/iova-tree: g_tree_foreach wrapper Connor Kite
2026-08-18 5:12 ` [PATCH RFC v2 03/13] hw/virtio: iova_tree_foreach wrapper Connor Kite
2026-08-18 5:12 ` [PATCH RFC v2 04/13] hw/virtio/vhost-shadow-virtqueue: used callback Connor Kite
2026-08-18 5:12 ` [PATCH RFC v2 05/13] hw/virtio/vhost-shadow-virtqueue: specified vring placement Connor Kite
2026-08-18 5:12 ` Connor Kite [this message]
2026-08-18 5:12 ` [PATCH RFC v2 07/13] hw/virtio/vhost-user: create isolation region Connor Kite
2026-08-18 5:12 ` [PATCH RFC v2 08/13] hw/virtio/vhost-user: send isolation regions to device Connor Kite
2026-08-18 5:12 ` [PATCH RFC v2 09/13] hw/virtio/vhost-user: add shadow virtqueues and eventfd intercepts Connor Kite
2026-08-18 5:12 ` [PATCH RFC v2 10/13] hw/virtio/vhost-user: handle data movement with shadow vqs Connor Kite
2026-08-18 5:12 ` [PATCH RFC v2 11/13] vhost-user: Add memory-isolation qdev property to vhost-user devices Connor Kite
2026-08-18 5:12 ` [PATCH RFC v2 12/13] backends/cryptodev-vhost-user: add memory isolation bool Connor Kite
2026-08-18 5:12 ` [PATCH RFC v2 13/13] net/vhost-user: add memory isolation Connor Kite
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=20260817-vhost-user-isolated-memory-v2-6-948aae960abb@gmail.com \
--to=connorkite@gmail.com \
--cc=20260817233147.2867623-1-connorkite@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=demiobenour@gmail.com \
--cc=dmitry.osipenko@collabora.com \
--cc=eblake@redhat.com \
--cc=eperezma@redhat.com \
--cc=fam@euphon.net \
--cc=hi@alyssa.is \
--cc=hreitz@redhat.com \
--cc=jasowangio@gmail.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=manos.pitsidianakis@linaro.org \
--cc=marcandre.lureau@redhat.com \
--cc=mathieu.poirier@linaro.org \
--cc=mst@redhat.com \
--cc=mzamazal@redhat.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rnorwitz@nvidia.com \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=viresh.kumar@linaro.org \
--cc=virtio-fs@lists.linux.dev \
--cc=zhenwei.pi@linux.dev \
/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.