vhost-user: Add and consolidate qdev properties
cover vhost-user: Add and consolidate qdev properties
[1/2] Consolidate chardev qdev property definitions in the VHostUserBase family of devices. Now, the definition only takes place within VHostUserBase initialization and is inherited by children.
[2/2] 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.
These patches are grouped together as they both touch on qdev properties held in common by all vhost-user devices. Taken together, these patches ensure that commmon properties are defined in the same location and way.
---
ConKite (2):
vhost-user: Consolidate chardev property definitions
vhost-user: Add memory-isolation qdev property to vhost-user devices
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(-)
Signature · 1 line
2.43.0
PATCH 1/2 vhost-user: Consolidate chardev property definitions
Move chardev qdev property definitions from children into VHostUserBase. This reduces code duplication and allows children to simply inherit the property during initialization.
--- hw/virtio/vhost-user-base.c | 9 +++++++++ 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-snd.c | 1 - hw/virtio/vhost-user-spi.c | 5 ----- hw/virtio/vhost-user-test-device.c | 1 - 9 files changed, 9 insertions(+), 30 deletions(-)
hw/virtio/vhost-user-base.c +9 -0
@@ -353,9 +353,16 @@ static void vub_device_unrealize(DeviceState *dev)do_vhost_user_cleanup (vdev, vub); } +/*Define common qdev properties. Inherited by all children*/ +static const Property vub_properties[] = { +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 +370,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[] = {
hw/virtio/vhost-user-gpio.c +0 -4
@@ -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);
hw/virtio/vhost-user-i2c.c +0 -5
@@ -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);
hw/virtio/vhost-user-input.c +0 -5
@@ -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);
hw/virtio/vhost-user-rng.c +0 -5
@@ -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);
hw/virtio/vhost-user-rtc.c +0 -4
@@ -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);
hw/virtio/vhost-user-snd.c +0 -1
@@ -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), };
hw/virtio/vhost-user-spi.c +0 -5
@@ -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);
hw/virtio/vhost-user-test-device.c +0 -1
@@ -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 ),
Signature · 1 line
2.43.0
Re: [PATCH 1/2] vhost-user: Consolidate chardev property definitions
Quoted 7 lines · ConKite
Move chardev qdev property definitions from children into VHostUserBase. This reduces code duplication and allows children to simply inherit the property during initialization.
Signed-off-by Connor Kite <[email protected]>
Quoted 11 lines
--- hw/virtio/vhost-user-base.c | 9 +++++++++ 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-snd.c | 1 - hw/virtio/vhost-user-spi.c | 5 ----- hw/virtio/vhost-user-test-device.c | 1 - 9 files changed, 9 insertions(+), 30 deletions(-)
PATCH 2/2 vhost-user: Add memory-isolation qdev property
In reply to ConKiteIn 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.
--- 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 | 3 ++- hw/virtio/vhost-user-fs.c | 1 + hw/virtio/vhost-user-scmi.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 + 14 files changed, 15 insertions(+), 1 deletion(-)
hw/block/vhost-user-blk.c +1 -0
@@ -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, memory_isolation, false),DEFINE_PROP_UINT16 ("num-queues" , VHostUserBlk, num_queues,VHOST_USER_BLK_AUTO_NUM_QUEUES ),DEFINE_PROP_UINT32 ("queue-size" , VHostUserBlk, queue_size,128 ),
hw/display/vhost-user-gpu.c +1 -0
@@ -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, memory_isolation, false), }; static void
hw/scsi/vhost-user-scsi.c +1 -0
@@ -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.memory_isolation, 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 ),
hw/virtio/vhost-user-base.c +2 -1
@@ -355,7 +355,8 @@ static void vub_device_unrealize(DeviceState *dev)/*Define common qdev properties. Inherited by all children*/ static const Property vub_properties[] = { -DEFINE_PROP_CHR ("chardev" , VHostUserBase, chardev) +DEFINE_PROP_CHR ("chardev" , VHostUserBase, chardev), +DEFINE_PROP_BOOL ("memory-isolation" , VHostUserBase, memory_isolation, false) };
hw/virtio/vhost-user-fs.c +1 -0
@@ -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.memory_isolation, false),DEFINE_PROP_STRING ("tag" , VHostUserFS, conf.tag),DEFINE_PROP_UINT16 ("num-request-queues" , VHostUserFS, conf.num_request_queues,1 ),
hw/virtio/vhost-user-scmi.c +1 -0
@@ -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, memory_isolation, false), };static void vu_scmi_class_init (ObjectClass *klass,const void *data)
hw/virtio/vhost-user-vsock.c +1 -0
@@ -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.memory_isolation, false), };static void vuv_class_init (ObjectClass *klass,const void *data)
include/hw/virtio/vhost-user-base.h +1 -0
@@ -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 memory_isolation;/* State tracking */ VhostUserState vhost_user;struct vhost_virtqueue *vhost_vq;
include/hw/virtio/vhost-user-blk.h +1 -0
@@ -30,6 +30,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserBlk, VHOST_USER_BLK)struct VHostUserBlk {VirtIODevice parent_obj;CharFrontend chardev; +bool memory_isolation;int32_t bootindex;struct virtio_blk_config blkcfg;uint16_t num_queues;
include/hw/virtio/vhost-user-fs.h +1 -0
@@ -28,6 +28,7 @@ typedef struct {char *tag;uint16_t num_request_queues;uint16_t queue_size; +bool memory_isolation; } VHostUserFSConf;struct VHostUserFS {
include/hw/virtio/vhost-user-scmi.h +1 -0
@@ -19,6 +19,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserSCMI, VHOST_USER_SCMI);struct VHostUserSCMI {VirtIODevice parent;CharFrontend chardev; +bool memory_isolation;struct vhost_virtqueue *vhost_vqs;struct vhost_dev vhost_dev;VhostUserState vhost_user;
include/hw/virtio/vhost-user-vsock.h +1 -0
@@ -21,6 +21,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserVSock, VHOST_USER_VSOCK)typedef struct {CharFrontend chardev; +bool memory_isolation; }VHostUserVSockConf ;struct VHostUserVSock {
include/hw/virtio/virtio-gpu.h +1 -0
@@ -276,6 +276,7 @@ struct VhostUserGPU {CharFrontend vhost_chr;QemuDmaBuf *dmabuf[VIRTIO_GPU_MAX_SCANOUTS ];bool backend_blocked; +bool memory_isolation; };#define MAX_SLOTS 4096
include/hw/virtio/virtio-scsi.h +1 -0
@@ -59,6 +59,7 @@ struct VirtIOSCSIConf {char *vhostfd;char *wwpn;CharFrontend chardev; +bool memory_isolation;uint32_t boot_tpgt;IOThread *iothread;IOThreadVirtQueueMappingList *iothread_vq_mapping_list;
Signature · 1 line
2.43.0
Re: [PATCH 2/2] vhost-user: Add memory-isolation qdev property
Quoted 7 lines · ConKite
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.
Signed-of-by Connor Kite <[email protected]>
Quoted 16 lines
--- 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 | 3 ++- hw/virtio/vhost-user-fs.c | 1 + hw/virtio/vhost-user-scmi.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 + 14 files changed, 15 insertions(+), 1 deletion(-)
This patch can be applied after the memory isolation internals are merged in the future. For now it should stay out-of-tree because it's a user-visible option that is currently unimplemented.
Quoted 4 lines · ConKite
[1/2] Consolidate chardev qdev property definitions in the VHostUserBase family of devices. Now, the definition only takes place within VHostUserBase initialization and is inherited by children.
This patch can be merged right away. It's a cleanup for vhost-user-base.
Quoted 5 lines
[2/2] 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.
This patch will need to wait until the memory isolation work is completed since the qdev property currently does nothing.
Quoted 38 lines
These patches are grouped together as they both touch on qdev properties held in common by all vhost-user devices. Taken together, these patches ensure that commmon properties are defined in the same location and way.
Signed-off-by Connor Kite <[email protected]>---
ConKite (2):
vhost-user: Consolidate chardev property definitions
vhost-user: Add memory-isolation qdev property to vhost-user deviceshw/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(-)--
2.43.0