add generic vDPA device support
v3 cover add generic vDPA device support
From: Longpeng <[email protected]>
Hi guys,
With the generic vDPA device, QEMU won't need to touch the device types any more, such like vfio.
We can use the generic vDPA device as follow:
-device vhost-vdpa-device-pci,vdpa-dev=/dev/vhost-vdpa-X
I've done some simple tests on Huawei's offloading card (net, 0.95) and vdpa_sim_blk (1.0);
The kernel part:
https://lkml.org/lkml/2022/3/14/1636
Changes v2 -> v3
Patch 4 & 5:
- only call vdpa ioctls in vdpa-dev.c [Stefano, Longpeng]
- s/VQS_NUM/VQS_COUNT [Stefano]
- check both vdpa_dev_fd and vdpa_dev [Stefano]
Patch 6:
- move all steps into vhost_vdpa_device_unrealize. [Stefano]
Changes RFC -> v2
Patch 1:
- rename 'pdev_id' to 'trans_devid' [Michael]
- only use transitional device id for the devices listed in the spec [Michael]
- use macros to make the id_info table clearer [Longpeng]
- add some modern devices in the id_info table [Longpeng]
Patch 2:
- remove the GET_VECTORS_NUM command [Jason]
Patch 4:
- expose vdpa_dev_fd as a QOM preperty [Stefan]
- introduce vhost_vdpa_device_get_u32 as a common function to make the code clearer [Stefan]
- fix the misleading description of 'dc->desc' [Stefano]
Patch 5:
- check returned number of virtqueues [Stefan]
Patch 6:
- init s->num_queues [Stefano]
- free s->dev.vqs [Stefano]
Longpeng (Mike) (10):
virtio: get class_id and pci device id by the virtio id update linux headers
vdpa: add the infrastructure of vdpa-dev
vdpa-dev: implement the instance_init/class_init interface
vdpa-dev: implement the realize interface
vdpa-dev: implement the unrealize interface
vdpa-dev: implement the get_config/set_config interface
vdpa-dev: implement the get_features interface
vdpa-dev: implement the set_status interface
vdpa-dev: mark the device as unmigratable
hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 2 + hw/virtio/vdpa-dev-pci.c | 101 +++++++++ hw/virtio/vdpa-dev.c | 384 +++++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.c | 77 +++++++ hw/virtio/virtio-pci.h | 5 + include/hw/virtio/vdpa-dev.h | 43 ++++ linux-headers/linux/vhost.h | 7 + 8 files changed, 624 insertions(+) create mode 100644 hw/virtio/vdpa-dev-pci.c create mode 100644 hw/virtio/vdpa-dev.c create mode 100644 include/hw/virtio/vdpa-dev.h
Signature · 1 line
2.23.0
PATCH v3 1/10 virtio: get class_id and pci device id by the virtio id
From: Longpeng <[email protected]>
Add helpers to get the "Transitional PCI Device ID" and "class_id" of the device specified by the "Virtio Device ID".
These helpers will be used to build the generic vDPA device later.
--- hw/virtio/virtio-pci.c | 77 ++++++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-pci.h | 5 +++ 2 files changed, 82 insertions(+)
hw/virtio/virtio-pci.c +77 -0
@@ -19,6 +19,7 @@#include "exec/memop.h" #include "standard-headers/linux/virtio_pci.h" +#include "standard-headers/linux/virtio_ids.h" #include "hw/boards.h" #include "hw/virtio/virtio.h" #include "migration/qemu-file-types.h"
@@ -212,6 +213,79 @@ static int virtio_pci_load_queue(DeviceState *d, int n, QEMUFile *f)return 0 ; } +typedef struct VirtIOPCIIDInfo { +/* virtio id */ +uint16_t vdev_id; +/* pci device id for the transitional device */ +uint16_t trans_devid; +uint16_t class_id; +}VirtIOPCIIDInfo ; + +#define VIRTIO_TRANS_DEV_ID_INFO (name, class) \ + { \ + .vdev_id = VIRTIO_ID_##name, \ + .trans_devid = PCI_DEVICE_ID_VIRTIO_##name, \ + .class_id = class, \ + } + +#define VIRTIO_MODERN_DEV_ID_NFO (name, class) \ + { \ + .vdev_id = VIRTIO_ID_##name, \ + .class_id = class, \ + } + +static const VirtIOPCIIDInfo virtio_pci_id_info[] = { +/* Non-transitional devices */ +VIRTIO_MODERN_DEV_ID_NFO (CRYPTO ,PCI_CLASS_OTHERS ), +VIRTIO_MODERN_DEV_ID_NFO (FS ,PCI_CLASS_STORAGE_OTHER ), +/* Transitional devices */ +VIRTIO_TRANS_DEV_ID_INFO (NET ,PCI_CLASS_NETWORK_ETHERNET ), +VIRTIO_TRANS_DEV_ID_INFO (BLOCK ,PCI_CLASS_STORAGE_SCSI ), +VIRTIO_TRANS_DEV_ID_INFO (CONSOLE ,PCI_CLASS_COMMUNICATION_OTHER ), +VIRTIO_TRANS_DEV_ID_INFO (SCSI ,PCI_CLASS_STORAGE_SCSI ), +VIRTIO_TRANS_DEV_ID_INFO (9P ,PCI_BASE_CLASS_NETWORK ), +VIRTIO_TRANS_DEV_ID_INFO (BALLOON ,PCI_CLASS_OTHERS ), +VIRTIO_TRANS_DEV_ID_INFO (RNG ,PCI_CLASS_OTHERS ), +}; + +static const VirtIOPCIIDInfo *virtio_pci_get_id_info (uint16_t vdev_id) +{ +const VirtIOPCIIDInfo *info =NULL ; +int i; + +for (i =0 ; i <ARRAY_SIZE (virtio_pci_id_info); i++) { +if (virtio_pci_id_info[i].vdev_id == vdev_id) { + info = &virtio_pci_id_info[i]; +break ; + } + } + +if (!info) { +/* The device id is invalid or not added to the id_info yet. */ +error_report ("Invalid virtio device(id %u)" , vdev_id); +abort (); + } + +return info; +} + +/* +* Get the Transitional Device ID for the specific device, return +* zero if the device is non-transitional. +*/ +uint16_t virtio_pci_get_trans_devid (uint16_t device_id) +{ +return virtio_pci_get_id_info (device_id)->trans_devid; +} + +/* +* Get the Class ID for the specific device. +*/ +uint16_t virtio_pci_get_class_id (uint16_t device_id) +{ +return virtio_pci_get_id_info (device_id)->class_id; +} +static bool virtio_pci_ioeventfd_enabled (DeviceState *d) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d);
@@ -1673,6 +1747,9 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)* is set to PCI_SUBVENDOR_ID_REDHAT_QUMRANET by default. */ pci_set_word (config +PCI_SUBSYSTEM_ID ,virtio_bus_get_vdev_id (bus)); +if (proxy->trans_devid) { +pci_config_set_device_id (config, proxy->trans_devid); + } }else {/* pure virtio-1.0 */ pci_set_word(config + PCI_VENDOR_ID,
hw/virtio/virtio-pci.h +5 -0
@@ -146,6 +146,8 @@ struct VirtIOPCIProxy {bool disable_modern;bool ignore_backend_features;OnOffAuto disable_legacy; +/* Transitional device id */ +uint16_t trans_devid;uint32_t class_code;uint32_t nvectors;uint32_t dfselect;
@@ -158,6 +160,9 @@ struct VirtIOPCIProxy {VirtioBusState bus; }; +uint16_t virtio_pci_get_trans_devid (uint16_t device_id); +uint16_t virtio_pci_get_class_id (uint16_t device_id); +static inline bool virtio_pci_modern (VirtIOPCIProxy *proxy) {return !proxy->disable_modern;
Signature · 1 line
2.23.0
PATCH v3 2/10 update linux headers
In reply to Longpeng(Mike) viaFrom: Longpeng <[email protected]>
Update linux headers to 5.xxx (kernel part is not merged yet)
To support generic vdpa deivce, we need add the following ioctls:
- VHOST_VDPA_GET_CONFIG_SIZE: get the configuration size.
- VHOST_VDPA_GET_VQS_COUNT: get the count of supported virtqueues.
--- linux-headers/linux/vhost.h | 7 +++++++ 1 file changed, 7 insertions(+)
linux-headers/linux/vhost.h +7 -0
@@ -150,4 +150,11 @@/* Get the valid iova range */ #define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \ struct vhost_vdpa_iova_range) + +/* Get the config size */ +#define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32) + +/* Get the count of all virtqueues */ +#define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32) +#endif
Signature · 1 line
2.23.0
PATCH v3 3/10 vdpa: add the infrastructure of vdpa-dev
In reply to Longpeng(Mike) viaFrom: Longpeng <[email protected]>
Add the infrastructure of vdpa-dev (the generic vDPA device), we can add a generic vDPA device as follow:
-device vhost-vdpa-device-pci,vdpa-dev=/dev/vhost-vdpa-X
--- hw/virtio/Kconfig | 5 +++ hw/virtio/meson.build | 2 ++ hw/virtio/vdpa-dev-pci.c | 65 ++++++++++++++++++++++++++++++++++++ hw/virtio/vdpa-dev.c | 55 ++++++++++++++++++++++++++++++ include/hw/virtio/vdpa-dev.h | 30 +++++++++++++++++ 5 files changed, 157 insertions(+) create mode 100644 hw/virtio/vdpa-dev-pci.c create mode 100644 hw/virtio/vdpa-dev.c create mode 100644 include/hw/virtio/vdpa-dev.h
hw/virtio/Kconfig +5 -0
@@ -68,3 +68,8 @@ config VHOST_USER_RNG bool default y depends on VIRTIO && VHOST_USER + +config VHOST_VDPA_DEV + bool + default y if VIRTIO_PCI + depends on VIRTIO && VHOST_VDPA && LINUX
hw/virtio/meson.build +2 -0
@@ -29,6 +29,7 @@ virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_I2C'], if_true: files('vhost-user-i2c-pci.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) virtio_ss.add(when: ['CONFIG_VHOST_USER_RNG', 'CONFIG_VIRTIO_PCI'], if_true: files('vhost-user-rng-pci.c')) +virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
@@ -49,6 +50,7 @@ virtio_pci_ss.add(when: 'CONFIG_VIRTIO_SERIAL', if_true: files('virtio-serial-pc virtio_pci_ss.add(when: 'CONFIG_VIRTIO_PMEM', if_true: files('virtio-pmem-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem-pci.c')) +virtio_pci_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev-pci.c')) virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss)
hw/virtio/vdpa-dev-pci.c new file +65 -0
65 lines not on this page · raw message
hw/virtio/vdpa-dev.c new file +55 -0
55 lines not on this page · raw message
include/hw/virtio/vdpa-dev.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Vhost Vdpa Device +* +* Copyright (c) Huawei Technologies Co., Ltd. 2022. All Rights Reserved. +* +* Authors: +* Longpeng <[email protected]> +* +* Largely based on the "vhost-user-blk.h" implemented by: +* Changpeng Liu <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2 or later. +* See the COPYING.LIB file in the top-level directory. +*/ +#ifndef _VHOST_VDPA_DEVICE_H +#define _VHOST_VDPA_DEVICE_H + +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-vdpa.h" +#include "qom/object.h" + + +#define TYPE_VHOST_VDPA_DEVICE "vhost-vdpa-device" +OBJECT_DECLARE_SIMPLE_TYPE(VhostVdpaDevice, VHOST_VDPA_DEVICE) + +struct VhostVdpaDevice { +VirtIODevice parent_obj; +}; + +#endif
Signature · 1 line
2.23.0
PATCH v3 4/10 vdpa-dev: implement the instance_init/class_init interface
In reply to Longpeng(Mike) viaFrom: Longpeng <[email protected]>
Implements the .instance_init and the .class_init interface.
--- hw/virtio/vdpa-dev-pci.c | 22 +++++++++++- hw/virtio/vdpa-dev.c | 69 ++++++++++++++++++++++++++++++++++-- include/hw/virtio/vdpa-dev.h | 3 ++ 3 files changed, 91 insertions(+), 3 deletions(-)
hw/virtio/vdpa-dev-pci.c +21 -1
@@ -38,13 +38,33 @@ struct VhostVdpaDevicePCI { };static void vhost_vdpa_device_pci_instance_init (Object *obj) +{ +VhostVdpaDevicePCI *dev =VHOST_VDPA_DEVICE_PCI (obj); + +virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev), +TYPE_VHOST_VDPA_DEVICE ); +object_property_add_alias (obj,"bootindex" ,OBJECT (&dev->vdev), +"bootindex" ); +} + +static Property vhost_vdpa_device_pci_properties[] = { +DEFINE_PROP_END_OF_LIST (), +}; + +static void +vhost_vdpa_device_pci_realize (VirtIOPCIProxy *vpci_dev,Error **errp) {return ; }static void vhost_vdpa_device_pci_class_init (ObjectClass *klass,void *data) { -return ; +DeviceClass *dc =DEVICE_CLASS (klass); +VirtioPCIClass *k =VIRTIO_PCI_CLASS (klass); + +set_bit (DEVICE_CATEGORY_MISC , dc->categories); +device_class_set_props (dc, vhost_vdpa_device_pci_properties); + k->realize = vhost_vdpa_device_pci_realize; }static const VirtioPCIDeviceTypeInfo vhost_vdpa_device_pci_info = {
hw/virtio/vdpa-dev.c +67 -2
83 lines not on this page · raw message
include/hw/virtio/vdpa-dev.h +3 -0
@@ -25,6 +25,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(VhostVdpaDevice, VHOST_VDPA_DEVICE)struct VhostVdpaDevice {VirtIODevice parent_obj; +char *vdpa_dev; +int vdpa_dev_fd; +int32_t bootindex; };#endif
Signature · 1 line
2.23.0
PATCH v3 5/10 vdpa-dev: implement the realize interface
In reply to Longpeng(Mike) viaFrom: Longpeng <[email protected]>
Implements the .realize interface.
--- hw/virtio/vdpa-dev-pci.c | 18 ++++- hw/virtio/vdpa-dev.c | 132 +++++++++++++++++++++++++++++++++++ include/hw/virtio/vdpa-dev.h | 10 +++ 3 files changed, 159 insertions(+), 1 deletion(-)
hw/virtio/vdpa-dev-pci.c +17 -1
@@ -51,10 +51,26 @@ static Property vhost_vdpa_device_pci_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static int vhost_vdpa_device_pci_post_init (VhostVdpaDevice *v,Error **errp) +{ +VhostVdpaDevicePCI *dev =container_of (v, VhostVdpaDevicePCI, vdev); +VirtIOPCIProxy *vpci_dev = &dev->parent_obj; + + vpci_dev->class_code =virtio_pci_get_class_id (v->vdev_id); + vpci_dev->trans_devid =virtio_pci_get_trans_devid (v->vdev_id); +/* one for config vector */ + vpci_dev->nvectors = v->num_queues +1 ; + +return 0 ; +} +static void vhost_vdpa_device_pci_realize (VirtIOPCIProxy *vpci_dev,Error **errp) { -return ; +VhostVdpaDevicePCI *dev =VHOST_VDPA_DEVICE_PCI (vpci_dev); + + dev->vdev.post_init = vhost_vdpa_device_pci_post_init; +qdev_realize (DEVICE (&dev->vdev),BUS (&vpci_dev->bus), errp); }static void vhost_vdpa_device_pci_class_init (ObjectClass *klass,void *data)
hw/virtio/vdpa-dev.c +132 -0
147 lines not on this page · raw message
include/hw/virtio/vdpa-dev.h +10 -0
@@ -28,6 +28,16 @@ struct VhostVdpaDevice {char *vdpa_dev;int vdpa_dev_fd;int32_t bootindex; +uint32_t vdev_id; +uint32_t num_queues; +struct vhost_dev dev; +struct vhost_vdpa vdpa; +VirtQueue **virtqs; +uint8_t *config; +int config_size; +uint16_t queue_size; +bool started; + int (*post_init)(VhostVdpaDevice *v, Error **errp); };#endif
Signature · 1 line
2.23.0
Re: [PATCH v3 05/10] vdpa-dev: implement the realize interface
Quoted 69 lines · Longpeng(Mike)
From: Longpeng <[email protected]>
Implements the .realize interface.
Signed-off-by Longpeng <[email protected]>---
hw/virtio/vdpa-dev-pci.c | 18 ++++- hw/virtio/vdpa-dev.c | 132 +++++++++++++++++++++++++++++++++++ include/hw/virtio/vdpa-dev.h | 10 +++ 3 files changed, 159 insertions(+), 1 deletion(-)hw/virtio/vdpa-dev-pci.c +13
-0@@ -51,10 +51,26 @@ static Property vhost_vdpa_device_pci_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static int vhost_vdpa_device_pci_post_init (VhostVdpaDevice *v,Error **errp) +{ +VhostVdpaDevicePCI *dev =container_of (v, VhostVdpaDevicePCI, vdev); +VirtIOPCIProxy *vpci_dev = &dev->parent_obj; + + vpci_dev->class_code =virtio_pci_get_class_id (v->vdev_id); + vpci_dev->trans_devid =virtio_pci_get_trans_devid (v->vdev_id); +/* one for config vector */ + vpci_dev->nvectors = v->num_queues +1 ; + +return 0 ; +} +static void
vhost_vdpa_device_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp){hw/virtio/vdpa-dev-pci.c +4
-1-return ; +VhostVdpaDevicePCI *dev =VHOST_VDPA_DEVICE_PCI (vpci_dev); + + dev->vdev.post_init = vhost_vdpa_device_pci_post_init; +qdev_realize (DEVICE (&dev->vdev),BUS (&vpci_dev->bus), errp);}
static void
vhost_vdpa_device_pci_class_init(ObjectClass *klass, void *data)hw/virtio/vdpa-dev.c +18
-0@@ -29,9 +29,140 @@#include "sysemu/sysemu.h" #include "sysemu/runstate.h" +static void +vhost_vdpa_device_dummy_handle_output (VirtIODevice *vdev,VirtQueue *vq) +{ +/* Nothing to do */ +} + +static uint32_t +vhost_vdpa_device_get_u32 (int fd,unsigned long int cmd,Error **errp) +{ +uint32_t val = (uint32_t )-1 ; + +if (ioctl (fd, cmd, &val) <0 ) { +error_setg (errp,"vhost-vdpa-device: cmd 0x%lx failed: %s" , + cmd,strerror (errno)); + } + +return val; +}
hw/virtio/vdpa-dev.c line 59
Quoted 10 lines
hw/virtio/vdpa-dev.c +8
-0+static void vhost_vdpa_device_realize (DeviceState *dev,Error **errp) { +VirtIODevice *vdev =VIRTIO_DEVICE (dev); +VhostVdpaDevice *v =VHOST_VDPA_DEVICE (vdev); +uint32_t max_queue_size; +struct vhost_virtqueue *vqs; +int i, ret; + +if (!v->vdpa_dev || v->vdpa_dev_fd ==-1 ) {
^
Should we use && operator here?
I can't start QEMU, how did you test this series?
$ ./qemu-system-x86_64 -m 512M -smp 2 -M q35,accel=kvm \ ... -device vhost-vdpa-device-pci,vdpa-dev=/dev/vhost-vdpa-0 qemu-system-x86_64: -device vhost-vdpa-device-pci,vdpa-dev=/dev/vhost-vdpa-0: both vpda-dev and vpda-dev-fd are missing
hw/virtio/vdpa-dev.c line 60
Quoted 1 line
hw/virtio/vdpa-dev.c +1
-0+error_setg (errp,"both vpda-dev and vpda-dev-fd are missing" );
Typo s/vpda/vdpa
hw/virtio/vdpa-dev.c line 65
Quoted 5 lines
hw/virtio/vdpa-dev.c +5
-0+return ; + } + +if (v->vdpa_dev && v->vdpa_dev_fd !=-1 ) { +error_setg (errp,"both vpda-dev and vpda-dev-fd are set" );
Ditto
Quoted 104 lines
hw/virtio/vdpa-dev.c +99
-0+return ; + } + +if (v->vdpa_dev_fd ==-1 ) { + v->vdpa_dev_fd =qemu_open (v->vdpa_dev,O_RDWR , errp); +if (*errp) { +return ; + } + } + v->vdpa.device_fd = v->vdpa_dev_fd; + + v->vdev_id =vhost_vdpa_device_get_u32 (v->vdpa_dev_fd, +VHOST_VDPA_GET_DEVICE_ID , errp); +if (*errp) { + goto out; + } + + max_queue_size =vhost_vdpa_device_get_u32 (v->vdpa_dev_fd, +VHOST_VDPA_GET_VRING_NUM , errp); +if (*errp) { + goto out; + } + +if (v->queue_size > max_queue_size) { +error_setg (errp,"vhost-vdpa-device: invalid queue_size: %u (max:%u)" , + v->queue_size, max_queue_size); + goto out; + }else if (!v->queue_size) { + v->queue_size = max_queue_size; + } + + v->num_queues =vhost_vdpa_device_get_u32 (v->vdpa_dev_fd, +VHOST_VDPA_GET_VQS_COUNT , errp); +if (*errp) { + goto out; + } + +if (!v->num_queues || v->num_queues >VIRTIO_QUEUE_MAX ) { +error_setg (errp,"invalid number of virtqueues: %u (max:%u)" , + v->num_queues,VIRTIO_QUEUE_MAX ); + goto out; + } + + v->dev.nvqs = v->num_queues; + vqs = g_new0(struct vhost_virtqueue, v->dev.nvqs); + v->dev.vqs = vqs; + v->dev.vq_index =0 ; + v->dev.vq_index_end = v->dev.nvqs; + v->dev.backend_features =0 ; + v->started = false; + + ret =vhost_dev_init (&v->dev, &v->vdpa,VHOST_BACKEND_TYPE_VDPA ,0 ,NULL ); +if (ret <0 ) { +error_setg (errp,"vhost-vdpa-device: vhost initialization failed: %s" , +strerror (-ret)); + goto free_vqs; + } + + v->config_size =vhost_vdpa_device_get_u32 (v->vdpa_dev_fd, +VHOST_VDPA_GET_CONFIG_SIZE , errp); +if (*errp) { + goto vhost_cleanup; + } + v->config =g_malloc0 (v->config_size); + + ret =vhost_dev_get_config (&v->dev, v->config, v->config_size,NULL ); +if (ret <0 ) { +error_setg (errp,"vhost-vdpa-device: get config failed" ); + goto free_config; + } + +virtio_init (vdev,"vhost-vdpa" , v->vdev_id, v->config_size); + + v->virtqs = g_new0(VirtQueue *, v->dev.nvqs); +for (i =0 ; i < v->dev.nvqs; i++) { + v->virtqs[i] =virtio_add_queue (vdev, v->queue_size, + vhost_vdpa_device_dummy_handle_output); + } + +if (v->post_init && v->post_init (v, errp) <0 ) { + goto free_virtio; + } +return ; + +free_virtio: +for (i =0 ; i < v->num_queues; i++) { +virtio_delete_queue (v->virtqs[i]); + } +g_free (v->virtqs); +virtio_cleanup (vdev); +free_config: +g_free (v->config); +vhost_cleanup: +vhost_dev_cleanup (&v->dev); +free_vqs: +g_free (vqs); +out: +qemu_close (v->vdpa_dev_fd); + v->vdpa_dev_fd =-1 ; }static void vhost_vdpa_device_unrealize (DeviceState *dev)
hw/virtio/vdpa-dev.c static void vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status) · line 199
Quoted 3 lines
hw/virtio/vdpa-dev.c +0
-0@@ -66,6 +197,7 @@ static void vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status)static Property vhost_vdpa_device_properties[] = {DEFINE_PROP_STRING ("vdpa-dev" , VhostVdpaDevice, vdpa_dev),DEFINE_PROP_INT32 ("vdpa-dev-fd" , VhostVdpaDevice, vdpa_dev_fd,-1 ),
Other vhost devices use the vhostfd property, maybe we should use the same name.
If we go for this change, then maybe we also need to change vdpa-dev to vhostpath or something like that
Thanks,
Stefano
Quoted 28 lines
hw/virtio/vdpa-dev.c +1
-0+DEFINE_PROP_UINT16 ("queue-size" , VhostVdpaDevice, queue_size,0 ), DEFINE_PROP_END_OF_LIST(), };include/hw/virtio/vdpa-dev.h +10
-1@@ -28,6 +28,16 @@ struct VhostVdpaDevice {char *vdpa_dev;int vdpa_dev_fd;int32_t bootindex; +uint32_t vdev_id; +uint32_t num_queues; +struct vhost_dev dev; +struct vhost_vdpa vdpa; +VirtQueue **virtqs; +uint8_t *config; +int config_size; +uint16_t queue_size; +bool started; + int (*post_init)(VhostVdpaDevice *v, Error **errp); };#endif --2.23.0
RE: [PATCH v3 05/10] vdpa-dev: implement the realize interface
Quoted 94 lines
-----Original Message-----
From: Stefano Garzarella [mailto:[email protected]]
Sent: Monday, March 28, 2022 11:00 PM
To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>; Michael Tsirkin <[email protected]>; Cornelia Huck <[email protected]>; Paolo Bonzini <[email protected]>; Gonglei (Arei) <[email protected]>; Yechuan <[email protected]>; Huangzhichao <[email protected]>; qemu devel list <[email protected]>
Subject: Re: [PATCH v3 05/10] vdpa-dev: implement the realize interfaceQuoted 69 lines · Longpeng(Mike)
From: Longpeng <[email protected]>
Implements the .realize interface.
Signed-off-by Longpeng <[email protected]>---
hw/virtio/vdpa-dev-pci.c | 18 ++++- hw/virtio/vdpa-dev.c | 132 +++++++++++++++++++++++++++++++++++ include/hw/virtio/vdpa-dev.h | 10 +++ 3 files changed, 159 insertions(+), 1 deletion(-)hw/virtio/vdpa-dev-pci.c +13
-0@@ -51,10 +51,26 @@ static Property vhost_vdpa_device_pci_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static int vhost_vdpa_device_pci_post_init (VhostVdpaDevice *v,Error **errp) +{ +VhostVdpaDevicePCI *dev =container_of (v, VhostVdpaDevicePCI, vdev); +VirtIOPCIProxy *vpci_dev = &dev->parent_obj; + + vpci_dev->class_code =virtio_pci_get_class_id (v->vdev_id); + vpci_dev->trans_devid =virtio_pci_get_trans_devid (v->vdev_id); +/* one for config vector */ + vpci_dev->nvectors = v->num_queues +1 ; + +return 0 ; +} +static void
vhost_vdpa_device_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp){hw/virtio/vdpa-dev-pci.c +4
-1-return ; +VhostVdpaDevicePCI *dev =VHOST_VDPA_DEVICE_PCI (vpci_dev); + + dev->vdev.post_init = vhost_vdpa_device_pci_post_init; +qdev_realize (DEVICE (&dev->vdev),BUS (&vpci_dev->bus), errp);}
static void
vhost_vdpa_device_pci_class_init(ObjectClass *klass, void *data)hw/virtio/vdpa-dev.c +18
-0@@ -29,9 +29,140 @@#include "sysemu/sysemu.h" #include "sysemu/runstate.h" +static void +vhost_vdpa_device_dummy_handle_output (VirtIODevice *vdev,VirtQueue *vq) +{ +/* Nothing to do */ +} + +static uint32_t +vhost_vdpa_device_get_u32 (int fd,unsigned long int cmd,Error **errp) +{ +uint32_t val = (uint32_t )-1 ; + +if (ioctl (fd, cmd, &val) <0 ) { +error_setg (errp,"vhost-vdpa-device: cmd 0x%lx failed: %s" , + cmd,strerror (errno)); + } + +return val; +}hw/virtio/vdpa-dev.c line 59
Quoted 10 lines
hw/virtio/vdpa-dev.c +8
-0+static void vhost_vdpa_device_realize (DeviceState *dev,Error **errp) { +VirtIODevice *vdev =VIRTIO_DEVICE (dev); +VhostVdpaDevice *v =VHOST_VDPA_DEVICE (vdev); +uint32_t max_queue_size; +struct vhost_virtqueue *vqs; +int i, ret; + +if (!v->vdpa_dev || v->vdpa_dev_fd ==-1 ) {^
Quoted 4 lines
Should we use && operator here?
I can't start QEMU, how did you test this series?
Oh! I changed to && operator in my local environment when I test this series but forgot to include it.
I'll fix it in the next version.
Quoted 11 lines
$ ./qemu-system-x86_64 -m 512M -smp 2 -M q35,accel=kvm \ ... -device vhost-vdpa-device-pci,vdpa-dev=/dev/vhost-vdpa-0 qemu-system-x86_64: -device vhost-vdpa-device-pci,vdpa-dev=/dev/vhost-vdpa-0: both vpda-dev and vpda-dev-fd are missinghw/virtio/vdpa-dev.c line 60
Quoted 1 line
hw/virtio/vdpa-dev.c +1
-0+error_setg (errp,"both vpda-dev and vpda-dev-fd are missing" );Typo s/vpda/vdpa
OK.
Quoted 8 lines
hw/virtio/vdpa-dev.c line 65
Quoted 5 lines
hw/virtio/vdpa-dev.c +5
-0+return ; + } + +if (v->vdpa_dev && v->vdpa_dev_fd !=-1 ) { +error_setg (errp,"both vpda-dev and vpda-dev-fd are set" );Ditto
OK.
Quoted 151 lines
Quoted 15 lines
hw/virtio/vdpa-dev.c +15
-0+return ; + } + +if (v->vdpa_dev_fd ==-1 ) { + v->vdpa_dev_fd =qemu_open (v->vdpa_dev,O_RDWR , errp); +if (*errp) { +return ; + } + } + v->vdpa.device_fd = v->vdpa_dev_fd; + + v->vdev_id =vhost_vdpa_device_get_u32 (v->vdpa_dev_fd, +VHOST_VDPA_GET_DEVICE_ID , errp); +if (*errp) { + goto out;hw/virtio/vdpa-dev.c
Quoted 10 lines
hw/virtio/vdpa-dev.c +10
-0+ } + + max_queue_size =vhost_vdpa_device_get_u32 (v->vdpa_dev_fd, +VHOST_VDPA_GET_VRING_NUM , errp); +if (*errp) { + goto out; + } + +if (v->queue_size > max_queue_size) { + error_setg(errp, "vhost-vdpa-device: invalid queue_size: %u(max:%u)",
Quoted 17 lines
hw/virtio/vdpa-dev.c +17
-0+ v->queue_size, max_queue_size); + goto out; + }else if (!v->queue_size) { + v->queue_size = max_queue_size; + } + + v->num_queues =vhost_vdpa_device_get_u32 (v->vdpa_dev_fd, +VHOST_VDPA_GET_VQS_COUNT , errp); +if (*errp) { + goto out; + } + +if (!v->num_queues || v->num_queues >VIRTIO_QUEUE_MAX ) { +error_setg (errp,"invalid number of virtqueues: %u (max:%u)" , + v->num_queues,VIRTIO_QUEUE_MAX ); + goto out; + }hw/virtio/vdpa-dev.c
Quoted 10 lines
hw/virtio/vdpa-dev.c +10
-0+ + v->dev.nvqs = v->num_queues; + vqs = g_new0(struct vhost_virtqueue, v->dev.nvqs); + v->dev.vqs = vqs; + v->dev.vq_index =0 ; + v->dev.vq_index_end = v->dev.nvqs; + v->dev.backend_features =0 ; + v->started = false; + + ret = vhost_dev_init(&v->dev, &v->vdpa, VHOST_BACKEND_TYPE_VDPA, 0,NULL);
hw/virtio/vdpa-dev.c line 119
Quoted 2 lines
hw/virtio/vdpa-dev.c +2
-0+if (ret <0 ) { + error_setg(errp, "vhost-vdpa-device: vhost initializationfailed: %s",
hw/virtio/vdpa-dev.c
Quoted 6 lines
hw/virtio/vdpa-dev.c +6
-0+ strerror(-ret)); + goto free_vqs; + } + + v->config_size = vhost_vdpa_device_get_u32(v->vdpa_dev_fd, + VHOST_VDPA_GET_CONFIG_SIZE,errp);
Quoted 7 lines
hw/virtio/vdpa-dev.c +7
-0+if (*errp) { + goto vhost_cleanup; + } + v->config =g_malloc0 (v->config_size); + + ret =vhost_dev_get_config (&v->dev, v->config, v->config_size,NULL ); +if (ret <0 ) {hw/virtio/vdpa-dev.c line 144
Quoted 10 lines
hw/virtio/vdpa-dev.c +10
-0+error_setg (errp,"vhost-vdpa-device: get config failed" ); + goto free_config; + } + +virtio_init (vdev,"vhost-vdpa" , v->vdev_id, v->config_size); + + v->virtqs = g_new0(VirtQueue *, v->dev.nvqs); +for (i =0 ; i < v->dev.nvqs; i++) { + v->virtqs[i] = virtio_add_queue(vdev, v->queue_size, +
vhost_vdpa_device_dummy_handle_output);hw/virtio/vdpa-dev.c static void vhost_vdpa_device_set_status(VirtIODevice *vdev,
Quoted 27 lines
hw/virtio/vdpa-dev.c +22
-0+ } + +if (v->post_init && v->post_init (v, errp) <0 ) { + goto free_virtio; + } +return ; + +free_virtio: +for (i =0 ; i < v->num_queues; i++) { +virtio_delete_queue (v->virtqs[i]); + } +g_free (v->virtqs); +virtio_cleanup (vdev); +free_config: +g_free (v->config); +vhost_cleanup: +vhost_dev_cleanup (&v->dev); +free_vqs: +g_free (vqs); +out: +qemu_close (v->vdpa_dev_fd); + v->vdpa_dev_fd =-1 ; }static void vhost_vdpa_device_unrealize (DeviceState *dev)@@ -66,6 +197,7 @@ static void vhost_vdpa_device_set_status(VirtIODevice *vdev,
uint8_tstatus)hw/virtio/vdpa-dev.c static void vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status) · line 199
Quoted 3 lines
hw/virtio/vdpa-dev.c +0
-0static Property vhost_vdpa_device_properties[] = {DEFINE_PROP_STRING ("vdpa-dev" , VhostVdpaDevice, vdpa_dev),DEFINE_PROP_INT32 ("vdpa-dev-fd" , VhostVdpaDevice, vdpa_dev_fd,-1 ),Other vhost devices use the
vhostfdproperty, maybe we should use the same name.If we go for this change, then maybe we also need to change
vdpa-devtovhostpathor something like thatThanks,
StefanoQuoted 28 lines
hw/virtio/vdpa-dev.c +1
-0+DEFINE_PROP_UINT16 ("queue-size" , VhostVdpaDevice, queue_size,0 ), DEFINE_PROP_END_OF_LIST(), };include/hw/virtio/vdpa-dev.h +10
-1@@ -28,6 +28,16 @@ struct VhostVdpaDevice {char *vdpa_dev;int vdpa_dev_fd;int32_t bootindex; +uint32_t vdev_id; +uint32_t num_queues; +struct vhost_dev dev; +struct vhost_vdpa vdpa; +VirtQueue **virtqs; +uint8_t *config; +int config_size; +uint16_t queue_size; +bool started; + int (*post_init)(VhostVdpaDevice *v, Error **errp); };#endif --2.23.0
RE: [PATCH v3 05/10] vdpa-dev: implement the realize interface
In reply to Stefano GarzarellaQuoted 13 lines
-----Original Message-----
From: Stefano Garzarella [mailto:[email protected]]
Sent: Monday, March 28, 2022 11:00 PM
To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>; Michael Tsirkin <[email protected]>; Cornelia Huck <[email protected]>; Paolo Bonzini <[email protected]>; Gonglei (Arei) <[email protected]>; Yechuan <[email protected]>; Huangzhichao <[email protected]>; qemu devel list <[email protected]>
Subject: Re: [PATCH v3 05/10] vdpa-dev: implement the realize interface
Quoted 3 lines
Quoted 2 lines · Longpeng(Mike)
From: Longpeng <[email protected]>
[snap]
Quoted 7 lines
Review static void vhost_vdpa_device_set_status(VirtIODevice *vdev,
Quoted 2 lines
static void
vhost_vdpa_device_unrealize(DeviceState *dev)(quoted diff) +0
-0@@ -66,6 +197,7 @@ static void vhost_vdpa_device_set_status(VirtIODevice *vdev,
uint8_tstatus)hw/virtio/vdpa-dev.c static void vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status) · line 199
Quoted 3 lines
hw/virtio/vdpa-dev.c +0
-0static Property vhost_vdpa_device_properties[] = {DEFINE_PROP_STRING ("vdpa-dev" , VhostVdpaDevice, vdpa_dev),DEFINE_PROP_INT32 ("vdpa-dev-fd" , VhostVdpaDevice, vdpa_dev_fd,-1 ),
Quoted 6 lines
Other vhost devices use the
vhostfdproperty, maybe we should use the same name.If we go for this change, then maybe we also need to change
vdpa-devtovhostpathor something like that
Make sense.
I prefer to use 'vhostdev' for the file path, just like the usage in Netdev:
-netdev type=vhost-vdpa,vhostdev=/dev/vhost-vdpa-0,id=vhostvdpa1
Quoted 31 lines
Thanks,
StefanoQuoted 28 lines
hw/virtio/vdpa-dev.c +1
-0+DEFINE_PROP_UINT16 ("queue-size" , VhostVdpaDevice, queue_size,0 ), DEFINE_PROP_END_OF_LIST(), };include/hw/virtio/vdpa-dev.h +10
-1@@ -28,6 +28,16 @@ struct VhostVdpaDevice {char *vdpa_dev;int vdpa_dev_fd;int32_t bootindex; +uint32_t vdev_id; +uint32_t num_queues; +struct vhost_dev dev; +struct vhost_vdpa vdpa; +VirtQueue **virtqs; +uint8_t *config; +int config_size; +uint16_t queue_size; +bool started; + int (*post_init)(VhostVdpaDevice *v, Error **errp); };#endif --2.23.0
Re: [PATCH v3 05/10] vdpa-dev: implement the realize interface
Quoted 16 lines · Cloud Infrastructure Service Product Dept.)
Quoted 3 lines · Longpeng(Mike)
Quoted 2 lines
From: Longpeng <[email protected]>
[snap]
Quoted 10 lines
Review static void vhost_vdpa_device_set_status(VirtIODevice *vdev,
Quoted 2 lines
static void
vhost_vdpa_device_unrealize(DeviceState *dev)(quoted diff) +0
-0@@ -66,6 +197,7 @@ static void vhost_vdpa_device_set_status(VirtIODevice *vdev,
uint8_tstatus)hw/virtio/vdpa-dev.c static void vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status) · line 199
Quoted 3 lines
hw/virtio/vdpa-dev.c +0
-0static Property vhost_vdpa_device_properties[] = {DEFINE_PROP_STRING ("vdpa-dev" , VhostVdpaDevice, vdpa_dev),DEFINE_PROP_INT32 ("vdpa-dev-fd" , VhostVdpaDevice, vdpa_dev_fd,-1 ),Other vhost devices use the
vhostfdproperty, maybe we should use the same name.
Quoted 9 lines
Quoted 3 lines
If we go for this change, then maybe we also need to change
vdpa-devtovhostpathor something like thatMake sense.
I prefer to use 'vhostdev' for the file path, just like the usage in Netdev:
-netdev type=vhost-vdpa,vhostdev=/dev/vhost-vdpa-0,id=vhostvdpa1
Yep, I agree with 'vhostdev'.
Thanks,
Stefano
PATCH v3 6/10 vdpa-dev: implement the unrealize interface
In reply to Longpeng(Mike) viaFrom: Longpeng <[email protected]>
Implements the .unrealize interface.
--- hw/virtio/vdpa-dev.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
hw/virtio/vdpa-dev.c +17 -1
@@ -167,7 +167,23 @@ out:static void vhost_vdpa_device_unrealize (DeviceState *dev) { -return ; +VirtIODevice *vdev =VIRTIO_DEVICE (dev); +VhostVdpaDevice *s =VHOST_VDPA_DEVICE (vdev); +int i; + +virtio_set_status (vdev,0 ); + +for (i =0 ; i < s->num_queues; i++) { +virtio_delete_queue (s->virtqs[i]); + } +g_free (s->virtqs); +virtio_cleanup (vdev); + +g_free (s->config); +g_free (s->dev.vqs); +vhost_dev_cleanup (&s->dev); +qemu_close (s->vdpa_dev_fd); + s->vdpa_dev_fd =-1 ; } static void
Signature · 1 line
2.23.0
PATCH v3 7/10 vdpa-dev: implement the get_config/set_config interface
In reply to Longpeng(Mike) viaFrom: Longpeng <[email protected]>
Implements the .get_config and .set_config interface.
--- hw/virtio/vdpa-dev.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
hw/virtio/vdpa-dev.c +12 -2
@@ -189,13 +189,23 @@ static void vhost_vdpa_device_unrealize(DeviceState *dev)static void vhost_vdpa_device_get_config (VirtIODevice *vdev,uint8_t *config) { -return ; +VhostVdpaDevice *s =VHOST_VDPA_DEVICE (vdev); + +memcpy (config, s->config, s->config_size); }static void vhost_vdpa_device_set_config (VirtIODevice *vdev,const uint8_t *config) { -return ; +VhostVdpaDevice *s =VHOST_VDPA_DEVICE (vdev); +int ret; + + ret =vhost_dev_set_config (&s->dev, s->config,0 , s->config_size, +VHOST_SET_CONFIG_TYPE_MASTER ); +if (ret) { +error_report ("set device config space failed" ); +return ; + } } static uint64_t vhost_vdpa_device_get_features(VirtIODevice *vdev,
Signature · 1 line
2.23.0
PATCH v3 8/10 vdpa-dev: implement the get_features interface
In reply to Longpeng(Mike) viaFrom: Longpeng <[email protected]>
Implements the .get_features interface.
--- hw/virtio/vdpa-dev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
hw/virtio/vdpa-dev.c +8 -1
@@ -212,7 +212,14 @@ static uint64_t vhost_vdpa_device_get_features(VirtIODevice *vdev,uint64_t features, Error **errp) { - return (uint64_t)-1; + VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev); +uint64_t backend_features = s->dev.features; + +if (!virtio_has_feature (features,VIRTIO_F_IOMMU_PLATFORM )) { +virtio_clear_feature (&backend_features,VIRTIO_F_IOMMU_PLATFORM ); + } + +return backend_features; }static void vhost_vdpa_device_set_status (VirtIODevice *vdev,uint8_t status)
Signature · 1 line
2.23.0
PATCH v3 9/10 vdpa-dev: implement the set_status interface
In reply to Longpeng(Mike) viaFrom: Longpeng <[email protected]>
Implements the .set_status interface.
--- hw/virtio/vdpa-dev.c | 100 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-)
hw/virtio/vdpa-dev.c +99 -1
@@ -222,9 +222,107 @@ static uint64_t vhost_vdpa_device_get_features(VirtIODevice *vdev,return backend_features; } +static int vhost_vdpa_device_start (VirtIODevice *vdev,Error **errp) +{ +VhostVdpaDevice *s =VHOST_VDPA_DEVICE (vdev); +BusState *qbus =BUS (qdev_get_parent_bus (DEVICE (vdev))); +VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (qbus); +int i, ret; + +if (!k->set_guest_notifiers) { +error_setg (errp,"binding does not support guest notifiers" ); +return -ENOSYS ; + } + + ret =vhost_dev_enable_notifiers (&s->dev, vdev); +if (ret <0 ) { +error_setg_errno (errp, -ret,"Error enabling host notifiers" ); +return ret; + } + + ret = k->set_guest_notifiers (qbus->parent, s->dev.nvqs, true); +if (ret <0 ) { +error_setg_errno (errp, -ret,"Error binding guest notifier" ); + goto err_host_notifiers; + } + + s->dev.acked_features = vdev->guest_features; + + ret =vhost_dev_start (&s->dev, vdev); +if (ret <0 ) { +error_setg_errno (errp, -ret,"Error starting vhost" ); + goto err_guest_notifiers; + } + s->started = true; + +/* +* guest_notifier_mask/pending not used yet, so just unmask +* everything here. virtio-pci will do the right thing by +* enabling/disabling irqfd. +*/ +for (i =0 ; i < s->dev.nvqs; i++) { +vhost_virtqueue_mask (&s->dev, vdev, i, false); + } + +return ret; + +err_guest_notifiers: + k->set_guest_notifiers (qbus->parent, s->dev.nvqs, false); +err_host_notifiers: +vhost_dev_disable_notifiers (&s->dev, vdev); +return ret; +} + +static void vhost_vdpa_device_stop (VirtIODevice *vdev) +{ +VhostVdpaDevice *s =VHOST_VDPA_DEVICE (vdev); +BusState *qbus =BUS (qdev_get_parent_bus (DEVICE (vdev))); +VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (qbus); +int ret; + +if (!s->started) { +return ; + } + s->started = false; + +if (!k->set_guest_notifiers) { +return ; + } + +vhost_dev_stop (&s->dev, vdev); + + ret = k->set_guest_notifiers (qbus->parent, s->dev.nvqs, false); +if (ret <0 ) { +error_report ("vhost guest notifier cleanup failed: %d" , ret); +return ; + } + +vhost_dev_disable_notifiers (&s->dev, vdev); +} +static void vhost_vdpa_device_set_status (VirtIODevice *vdev,uint8_t status) { -return ; +VhostVdpaDevice *s =VHOST_VDPA_DEVICE (vdev); +bool should_start =virtio_device_started (vdev, status); +Error *local_err =NULL ; +int ret; + +if (!vdev->vm_running) { + should_start = false; + } + +if (s->started == should_start) { +return ; + } + +if (should_start) { + ret =vhost_vdpa_device_start (vdev, &local_err); +if (ret <0 ) { +error_reportf_err (local_err,"vhost-vdpa-device: start failed: " ); + } + }else { +vhost_vdpa_device_stop (vdev); + } }static Property vhost_vdpa_device_properties[] = {
Signature · 1 line
2.23.0
PATCH v3 10/10 vdpa-dev: mark the device as unmigratable
In reply to Longpeng(Mike) viaFrom: Longpeng <[email protected]>
The generic vDPA device doesn't support migration currently, so mark it as unmigratable temporarily.
--- hw/virtio/vdpa-dev.c | 1 + 1 file changed, 1 insertion(+)
hw/virtio/vdpa-dev.c +1 -0
@@ -334,6 +334,7 @@ static Property vhost_vdpa_device_properties[] = {static const VMStateDescription vmstate_vhost_vdpa_device = { .name ="vhost-vdpa-device" , + .unmigratable =1 , .minimum_version_id =1 , .version_id =1 , .fields = (VMStateField []) {
Signature · 1 line
2.23.0
Quoted 4 lines · Longpeng(Mike)
From: Longpeng <[email protected]>
Hi guys,
Quoted 8 lines
With the generic vDPA device, QEMU won't need to touch the device types any more, such like vfio.
We can use the generic vDPA device as follow:
-device vhost-vdpa-device-pci,vdpa-dev=/dev/vhost-vdpa-XI've done some simple tests on Huawei's offloading card (net, 0.95) and
vdpa_sim_blk(1.0);
The whole seems almost okay, I left you some comments, but for the next version maybe it's better to reorganize the series differently.
Instead of adding vdpa-dev and vdpa-dev-pci incrementally, with stub functions and untestable parts, I would make a patch that adds vdpa-dev in full and then one that adds vdpa-dev-pci. The first 2 patches on the other hand are okay, maybe patch 2 won't be needed since I think we will sync the headers after the 7.0 release, but is better to keep it for now to simplify the review.
Thanks,
Stefano
Quoted 27 lines
-----Original Message-----
From: Stefano Garzarella [mailto:[email protected]]
Sent: Monday, March 28, 2022 11:12 PM
To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Gonglei (Arei) <[email protected]>; Yechuan <[email protected]>; Huangzhichao <[email protected]>; [email protected]
Subject: Re: [PATCH v3 00/10] add generic vDPA device supportQuoted 4 lines · Longpeng(Mike)
From: Longpeng <[email protected]>
Hi guys,
Quoted 8 lines
With the generic vDPA device, QEMU won't need to touch the device types any more, such like vfio.
We can use the generic vDPA device as follow:
-device vhost-vdpa-device-pci,vdpa-dev=/dev/vhost-vdpa-XI've done some simple tests on Huawei's offloading card (net, 0.95) and
vdpa_sim_blk(1.0);
Quoted 6 lines
The whole seems almost okay, I left you some comments, but for the next version maybe it's better to reorganize the series differently.
Instead of adding vdpa-dev and vdpa-dev-pci incrementally, with stub functions and untestable parts, I would make a patch that adds vdpa-dev in full and then one that adds vdpa-dev-pci.
Ok, will do in next version.
Quoted 4 lines
The first 2 patches on the other hand are okay, maybe patch 2 won't be needed since I think we will sync the headers after the 7.0 release, but is better to keep it for now to simplify the review.
Yes, that's also my original intent. Thanks.
Quoted 2 lines
Thanks,
Stefano