hw/block/vhost-user-blk.c | 1 + hw/display/vhost-user-gpu.c | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/virtio/vhost-user-base.c | 10 ++++++++++ hw/virtio/vhost-user-fs.c | 1 + hw/virtio/vhost-user-gpio.c | 4 ---- hw/virtio/vhost-user-i2c.c | 5 ----- hw/virtio/vhost-user-input.c | 5 ----- hw/virtio/vhost-user-rng.c | 5 ----- hw/virtio/vhost-user-rtc.c | 4 ---- hw/virtio/vhost-user-scmi.c | 1 + hw/virtio/vhost-user-snd.c | 1 - hw/virtio/vhost-user-spi.c | 5 ----- hw/virtio/vhost-user-test-device.c | 1 - hw/virtio/vhost-user-vsock.c | 1 + include/hw/virtio/vhost-user-base.h | 1 + include/hw/virtio/vhost-user-blk.h | 1 + include/hw/virtio/vhost-user-fs.h | 1 + include/hw/virtio/vhost-user-scmi.h | 1 + include/hw/virtio/vhost-user-vsock.h | 1 + include/hw/virtio/virtio-gpu.h | 1 + include/hw/virtio/virtio-scsi.h | 1 + 22 files changed, 23 insertions(+), 30 deletions(-)
In support of future work to add a memory isolation mode to vhost-user devices, a
qdev property, "memory-isolation", is added to all vhost-user devices. This is
simply a bool representing whether the mode is active or not.
Additionally, common property definitions for all children of vhost-user-base are
consolidated. Those property definitions now occur when VHostUserBase is initialized
Signed-off-by: Connor Kite <connorkite@gmail.com>
---
hw/block/vhost-user-blk.c | 1 +
hw/display/vhost-user-gpu.c | 1 +
hw/scsi/vhost-user-scsi.c | 1 +
hw/virtio/vhost-user-base.c | 10 ++++++++++
hw/virtio/vhost-user-fs.c | 1 +
hw/virtio/vhost-user-gpio.c | 4 ----
hw/virtio/vhost-user-i2c.c | 5 -----
hw/virtio/vhost-user-input.c | 5 -----
hw/virtio/vhost-user-rng.c | 5 -----
hw/virtio/vhost-user-rtc.c | 4 ----
hw/virtio/vhost-user-scmi.c | 1 +
hw/virtio/vhost-user-snd.c | 1 -
hw/virtio/vhost-user-spi.c | 5 -----
hw/virtio/vhost-user-test-device.c | 1 -
hw/virtio/vhost-user-vsock.c | 1 +
include/hw/virtio/vhost-user-base.h | 1 +
include/hw/virtio/vhost-user-blk.h | 1 +
include/hw/virtio/vhost-user-fs.h | 1 +
include/hw/virtio/vhost-user-scmi.h | 1 +
include/hw/virtio/vhost-user-vsock.h | 1 +
include/hw/virtio/virtio-gpu.h | 1 +
include/hw/virtio/virtio-scsi.h | 1 +
22 files changed, 23 insertions(+), 30 deletions(-)
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index c151e83677..849f437d9e 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -605,6 +605,7 @@ static const VMStateDescription vmstate_vhost_user_blk = {
static const Property vhost_user_blk_properties[] = {
DEFINE_PROP_CHR("chardev", VHostUserBlk, chardev),
+ DEFINE_PROP_BOOL("memory-isolation", VHostUserBlk, memoryIsolation, false),
DEFINE_PROP_UINT16("num-queues", VHostUserBlk, num_queues,
VHOST_USER_BLK_AUTO_NUM_QUEUES),
DEFINE_PROP_UINT32("queue-size", VHostUserBlk, queue_size, 128),
diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c
index 6e5e6540a4..d7a94fc856 100644
--- a/hw/display/vhost-user-gpu.c
+++ b/hw/display/vhost-user-gpu.c
@@ -664,6 +664,7 @@ static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev)
static const Property vhost_user_gpu_properties[] = {
VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf),
+ DEFINE_PROP_BOOL("memory-isolation", VhostUserGPU, memoryIsolation, false),
};
static void
diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index 3612897d4b..6ec5236b1d 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -347,6 +347,7 @@ static void vhost_user_scsi_unrealize(DeviceState *dev)
static const Property vhost_user_scsi_properties[] = {
DEFINE_PROP_CHR("chardev", VirtIOSCSICommon, conf.chardev),
+ DEFINE_PROP_BOOL("memory-isolation", VirtIOSCSICommon, conf.memoryIsolation, false),
DEFINE_PROP_UINT32("boot_tpgt", VirtIOSCSICommon, conf.boot_tpgt, 0),
DEFINE_PROP_UINT32("num_queues", VirtIOSCSICommon, conf.num_queues,
VIRTIO_SCSI_AUTO_NUM_QUEUES),
diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c
index 01ab9ca56b..cbc5792ac7 100644
--- a/hw/virtio/vhost-user-base.c
+++ b/hw/virtio/vhost-user-base.c
@@ -353,9 +353,17 @@ static void vub_device_unrealize(DeviceState *dev)
do_vhost_user_cleanup(vdev, vub);
}
+//Define common properties
+static const Property vub_properties[] = {
+ DEFINE_PROP_BOOL("memory-isolation", VHostUserBase, memoryIsolation, false),
+ DEFINE_PROP_CHR("chardev", VHostUserBase, chardev)
+};
+
+
static void vub_class_init(ObjectClass *klass, const void *data)
{
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(klass);
vdc->realize = vub_device_realize;
vdc->unrealize = vub_device_unrealize;
@@ -363,6 +371,8 @@ static void vub_class_init(ObjectClass *klass, const void *data)
vdc->get_config = vub_get_config;
vdc->set_config = vub_set_config;
vdc->set_status = vub_set_status;
+
+ device_class_set_props(dc, vub_properties);
}
static const TypeInfo vub_types[] = {
diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
index ad6fcacf06..df2dd5e775 100644
--- a/hw/virtio/vhost-user-fs.c
+++ b/hw/virtio/vhost-user-fs.c
@@ -409,6 +409,7 @@ static const VMStateDescription vuf_backend_vmstate = {
static const Property vuf_properties[] = {
DEFINE_PROP_CHR("chardev", VHostUserFS, conf.chardev),
+ DEFINE_PROP_BOOL("memory-isolation", VHostUserFS, conf.memoryIsolation, false),
DEFINE_PROP_STRING("tag", VHostUserFS, conf.tag),
DEFINE_PROP_UINT16("num-request-queues", VHostUserFS,
conf.num_request_queues, 1),
diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c
index d473f87077..33b8752282 100644
--- a/hw/virtio/vhost-user-gpio.c
+++ b/hw/virtio/vhost-user-gpio.c
@@ -14,9 +14,6 @@
#include "standard-headers/linux/virtio_ids.h"
#include "standard-headers/linux/virtio_gpio.h"
-static const Property vgpio_properties[] = {
- DEFINE_PROP_CHR("chardev", VHostUserBase, chardev),
-};
static void vgpio_realize(DeviceState *dev, Error **errp)
{
@@ -42,7 +39,6 @@ static void vu_gpio_class_init(ObjectClass *klass, const void *data)
VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass);
dc->vmsd = &vu_gpio_vmstate;
- device_class_set_props(dc, vgpio_properties);
device_class_set_parent_realize(dc, vgpio_realize,
&vubc->parent_realize);
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c
index 152b1f6740..3f5427b5b2 100644
--- a/hw/virtio/vhost-user-i2c.c
+++ b/hw/virtio/vhost-user-i2c.c
@@ -14,10 +14,6 @@
#include "qemu/error-report.h"
#include "standard-headers/linux/virtio_ids.h"
-static const Property vi2c_properties[] = {
- DEFINE_PROP_CHR("chardev", VHostUserBase, chardev),
-};
-
static void vi2c_realize(DeviceState *dev, Error **errp)
{
VHostUserBase *vub = VHOST_USER_BASE(dev);
@@ -42,7 +38,6 @@ static void vu_i2c_class_init(ObjectClass *klass, const void *data)
VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass);
dc->vmsd = &vu_i2c_vmstate;
- device_class_set_props(dc, vi2c_properties);
device_class_set_parent_realize(dc, vi2c_realize,
&vubc->parent_realize);
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
diff --git a/hw/virtio/vhost-user-input.c b/hw/virtio/vhost-user-input.c
index 5cfc5bbb56..8fe6349ffc 100644
--- a/hw/virtio/vhost-user-input.c
+++ b/hw/virtio/vhost-user-input.c
@@ -7,10 +7,6 @@
#include "qemu/osdep.h"
#include "hw/virtio/virtio-input.h"
-static const Property vinput_properties[] = {
- DEFINE_PROP_CHR("chardev", VHostUserBase, chardev),
-};
-
static void vinput_realize(DeviceState *dev, Error **errp)
{
VHostUserBase *vub = VHOST_USER_BASE(dev);
@@ -36,7 +32,6 @@ static void vhost_input_class_init(ObjectClass *klass, const void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
dc->vmsd = &vmstate_vhost_input;
- device_class_set_props(dc, vinput_properties);
device_class_set_parent_realize(dc, vinput_realize,
&vubc->parent_realize);
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c
index 106c8f211a..664aee403d 100644
--- a/hw/virtio/vhost-user-rng.c
+++ b/hw/virtio/vhost-user-rng.c
@@ -20,10 +20,6 @@ static const VMStateDescription vu_rng_vmstate = {
.unmigratable = 1,
};
-static const Property vrng_properties[] = {
- DEFINE_PROP_CHR("chardev", VHostUserBase, chardev),
-};
-
static void vu_rng_base_realize(DeviceState *dev, Error **errp)
{
VHostUserBase *vub = VHOST_USER_BASE(dev);
@@ -43,7 +39,6 @@ static void vu_rng_class_init(ObjectClass *klass, const void *data)
VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass);
dc->vmsd = &vu_rng_vmstate;
- device_class_set_props(dc, vrng_properties);
device_class_set_parent_realize(dc, vu_rng_base_realize,
&vubc->parent_realize);
diff --git a/hw/virtio/vhost-user-rtc.c b/hw/virtio/vhost-user-rtc.c
index 88b0c70b90..6d80cb6263 100644
--- a/hw/virtio/vhost-user-rtc.c
+++ b/hw/virtio/vhost-user-rtc.c
@@ -19,9 +19,6 @@ static const VMStateDescription vu_rtc_vmstate = {
.unmigratable = 1,
};
-static const Property vrtc_properties[] = {
- DEFINE_PROP_CHR("chardev", VHostUserBase, chardev),
-};
static void vu_rtc_base_realize(DeviceState *dev, Error **errp)
{
@@ -42,7 +39,6 @@ static void vu_rtc_class_init(ObjectClass *klass, const void *data)
VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass);
dc->vmsd = &vu_rtc_vmstate;
- device_class_set_props(dc, vrtc_properties);
device_class_set_parent_realize(dc, vu_rtc_base_realize,
&vubc->parent_realize);
diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c
index f9264c4374..0f586adfb1 100644
--- a/hw/virtio/vhost-user-scmi.c
+++ b/hw/virtio/vhost-user-scmi.c
@@ -282,6 +282,7 @@ static const VMStateDescription vu_scmi_vmstate = {
static const Property vu_scmi_properties[] = {
DEFINE_PROP_CHR("chardev", VHostUserSCMI, chardev),
+ DEFINE_PROP_BOOL("memory-isolation", VHostUserSCMI, memoryIsolation, false),
};
static void vu_scmi_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/virtio/vhost-user-snd.c b/hw/virtio/vhost-user-snd.c
index 7129b77d9c..3663450aed 100644
--- a/hw/virtio/vhost-user-snd.c
+++ b/hw/virtio/vhost-user-snd.c
@@ -34,7 +34,6 @@ static const VMStateDescription vu_snd_vmstate = {
};
static const Property vsnd_properties[] = {
- DEFINE_PROP_CHR("chardev", VHostUserBase, chardev),
DEFINE_PROP_BIT64("controls", VHostUserBase,
parent_obj.host_features, VIRTIO_SND_F_CTLS, false),
};
diff --git a/hw/virtio/vhost-user-spi.c b/hw/virtio/vhost-user-spi.c
index 707f96c250..fb6168d391 100644
--- a/hw/virtio/vhost-user-spi.c
+++ b/hw/virtio/vhost-user-spi.c
@@ -15,10 +15,6 @@
#include "standard-headers/linux/virtio_ids.h"
#include "standard-headers/linux/virtio_spi.h"
-static const Property vspi_properties[] = {
- DEFINE_PROP_CHR("chardev", VHostUserBase, chardev),
-};
-
static void vspi_realize(DeviceState *dev, Error **errp)
{
VHostUserBase *vub = VHOST_USER_BASE(dev);
@@ -44,7 +40,6 @@ static void vu_spi_class_init(ObjectClass *klass, const void *data)
VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass);
dc->vmsd = &vu_spi_vmstate;
- device_class_set_props(dc, vspi_properties);
device_class_set_parent_realize(dc, vspi_realize,
&vubc->parent_realize);
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
diff --git a/hw/virtio/vhost-user-test-device.c b/hw/virtio/vhost-user-test-device.c
index a2f963fdf6..91e23bf07a 100644
--- a/hw/virtio/vhost-user-test-device.c
+++ b/hw/virtio/vhost-user-test-device.c
@@ -30,7 +30,6 @@ static const VMStateDescription vud_vmstate = {
};
static const Property vud_properties[] = {
- DEFINE_PROP_CHR("chardev", VHostUserBase, chardev),
DEFINE_PROP_UINT16("virtio-id", VHostUserBase, virtio_id, 0),
DEFINE_PROP_UINT32("vq_size", VHostUserBase, vq_size, 64),
DEFINE_PROP_UINT32("num_vqs", VHostUserBase, num_vqs, 1),
diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c
index c2cd376e73..8170b12ae9 100644
--- a/hw/virtio/vhost-user-vsock.c
+++ b/hw/virtio/vhost-user-vsock.c
@@ -154,6 +154,7 @@ static void vuv_device_unrealize(DeviceState *dev)
static const Property vuv_properties[] = {
DEFINE_PROP_CHR("chardev", VHostUserVSock, conf.chardev),
+ DEFINE_PROP_BOOL("memory-isolation", VHostUserVSock, conf.memoryIsolation, false),
};
static void vuv_class_init(ObjectClass *klass, const void *data)
diff --git a/include/hw/virtio/vhost-user-base.h b/include/hw/virtio/vhost-user-base.h
index d5d2f081ae..23dc667d05 100644
--- a/include/hw/virtio/vhost-user-base.h
+++ b/include/hw/virtio/vhost-user-base.h
@@ -25,6 +25,7 @@ struct VHostUserBase {
uint32_t num_vqs;
uint32_t vq_size; /* can't exceed VIRTIO_QUEUE_MAX */
uint32_t config_size;
+ bool memoryIsolation;
/* State tracking */
VhostUserState vhost_user;
struct vhost_virtqueue *vhost_vq;
diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-user-blk.h
index 1e41a2bcdf..d4dfce824e 100644
--- a/include/hw/virtio/vhost-user-blk.h
+++ b/include/hw/virtio/vhost-user-blk.h
@@ -30,6 +30,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserBlk, VHOST_USER_BLK)
struct VHostUserBlk {
VirtIODevice parent_obj;
CharFrontend chardev;
+ bool memoryIsolation;
int32_t bootindex;
struct virtio_blk_config blkcfg;
uint16_t num_queues;
diff --git a/include/hw/virtio/vhost-user-fs.h b/include/hw/virtio/vhost-user-fs.h
index 5699ea03a1..47e253db07 100644
--- a/include/hw/virtio/vhost-user-fs.h
+++ b/include/hw/virtio/vhost-user-fs.h
@@ -28,6 +28,7 @@ typedef struct {
char *tag;
uint16_t num_request_queues;
uint16_t queue_size;
+ bool memoryIsolation;
} VHostUserFSConf;
struct VHostUserFS {
diff --git a/include/hw/virtio/vhost-user-scmi.h b/include/hw/virtio/vhost-user-scmi.h
index 30ab0d7ab7..ad91216ac6 100644
--- a/include/hw/virtio/vhost-user-scmi.h
+++ b/include/hw/virtio/vhost-user-scmi.h
@@ -19,6 +19,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserSCMI, VHOST_USER_SCMI);
struct VHostUserSCMI {
VirtIODevice parent;
CharFrontend chardev;
+ bool memoryIsolation;
struct vhost_virtqueue *vhost_vqs;
struct vhost_dev vhost_dev;
VhostUserState vhost_user;
diff --git a/include/hw/virtio/vhost-user-vsock.h b/include/hw/virtio/vhost-user-vsock.h
index 5db6938b8b..2f455bc1dc 100644
--- a/include/hw/virtio/vhost-user-vsock.h
+++ b/include/hw/virtio/vhost-user-vsock.h
@@ -21,6 +21,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserVSock, VHOST_USER_VSOCK)
typedef struct {
CharFrontend chardev;
+ bool memoryIsolation;
} VHostUserVSockConf;
struct VHostUserVSock {
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index f69fc19462..1d02e106c0 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -276,6 +276,7 @@ struct VhostUserGPU {
CharFrontend vhost_chr;
QemuDmaBuf *dmabuf[VIRTIO_GPU_MAX_SCANOUTS];
bool backend_blocked;
+ bool memoryIsolation;
};
#define MAX_SLOTS 4096
diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
index b6028bb5cd..afe02f8d21 100644
--- a/include/hw/virtio/virtio-scsi.h
+++ b/include/hw/virtio/virtio-scsi.h
@@ -59,6 +59,7 @@ struct VirtIOSCSIConf {
char *vhostfd;
char *wwpn;
CharFrontend chardev;
+ bool memoryIsolation;
uint32_t boot_tpgt;
IOThread *iothread;
IOThreadVirtQueueMappingList *iothread_vq_mapping_list;
--
2.43.0
On Wed, Jun 3, 2026 at 1:33 PM ConKite <connorkite@gmail.com> wrote:
> diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c
> index 01ab9ca56b..cbc5792ac7 100644
> --- a/hw/virtio/vhost-user-base.c
> +++ b/hw/virtio/vhost-user-base.c
> @@ -353,9 +353,17 @@ static void vub_device_unrealize(DeviceState *dev)
> do_vhost_user_cleanup(vdev, vub);
> }
>
> +//Define common properties
> +static const Property vub_properties[] = {
> + DEFINE_PROP_BOOL("memory-isolation", VHostUserBase, memoryIsolation, false),
From docs/devel/style.rst:
- "We use traditional C-style /``*`` ``*``/ comments and avoid // comments."
- "Variables are lower_case_with_underscores". memoryIsolation ->
memory_isolation.
You can run scripts/checkpatch.pl to catch many coding style issues.
Here is a git-hook to automatically do that when you commit:
https://blog.vmsplice.net/2011/03/how-to-automatically-run-checkpatchpl.html
> diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c
> index d473f87077..33b8752282 100644
> --- a/hw/virtio/vhost-user-gpio.c
> +++ b/hw/virtio/vhost-user-gpio.c
> @@ -14,9 +14,6 @@
> #include "standard-headers/linux/virtio_ids.h"
> #include "standard-headers/linux/virtio_gpio.h"
>
> -static const Property vgpio_properties[] = {
> - DEFINE_PROP_CHR("chardev", VHostUserBase, chardev),
> -};
>
> static void vgpio_realize(DeviceState *dev, Error **errp)
> {
> @@ -42,7 +39,6 @@ static void vu_gpio_class_init(ObjectClass *klass, const void *data)
> VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass);
>
> dc->vmsd = &vu_gpio_vmstate;
> - device_class_set_props(dc, vgpio_properties);
> device_class_set_parent_realize(dc, vgpio_realize,
> &vubc->parent_realize);
> set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
Moving chardev into the base class is a nice refactoring in itself and
its independent of introducing the memory-isolation property.
Separating self-contained changes into their own commits makes it
easier for reviewers to understand your patch series and it helps with
backporting and bisection (e.g. which change caused the breakage:
introducing memory-isolation or moving chardev?).
I suggest splitting this commit into two commits:
1. Move chardev into the base class.
2. Add the memory-isolation property.
© 2016 - 2026 Red Hat, Inc.