[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 25/27] vfio/ccw: Move VFIODevice initializations in vfio_ccw_i
|
From: |
Zhenzhong Duan |
|
Subject: |
[PATCH v7 25/27] vfio/ccw: Move VFIODevice initializations in vfio_ccw_instance_init |
|
Date: |
Tue, 21 Nov 2023 16:44:24 +0800 |
Some of the VFIODevice initializations is in vfio_ccw_realize,
move all of them in vfio_ccw_instance_init.
No functional change intended.
Suggested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
---
hw/vfio/ccw.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 2afdf17dbe..6305a4c1b8 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -594,20 +594,6 @@ static void vfio_ccw_realize(DeviceState *dev, Error
**errp)
return;
}
- vbasedev->ops = &vfio_ccw_ops;
- vbasedev->type = VFIO_DEVICE_TYPE_CCW;
- vbasedev->dev = dev;
-
- /*
- * All vfio-ccw devices are believed to operate in a way compatible with
- * discarding of memory in RAM blocks, ie. pages pinned in the host are
- * in the current working set of the guest driver and therefore never
- * overlap e.g., with pages available to the guest balloon driver. This
- * needs to be set before vfio_get_device() for vfio common to handle
- * ram_block_discard_disable().
- */
- vbasedev->ram_block_discard_allowed = true;
-
ret = vfio_attach_device(cdev->mdevid, vbasedev,
&address_space_memory, errp);
if (ret) {
@@ -695,8 +681,22 @@ static const VMStateDescription vfio_ccw_vmstate = {
static void vfio_ccw_instance_init(Object *obj)
{
VFIOCCWDevice *vcdev = VFIO_CCW(obj);
+ VFIODevice *vbasedev = &vcdev->vdev;
+
+ vbasedev->type = VFIO_DEVICE_TYPE_CCW;
+ vbasedev->ops = &vfio_ccw_ops;
+ vbasedev->dev = DEVICE(vcdev);
+ vbasedev->fd = -1;
- vcdev->vdev.fd = -1;
+ /*
+ * All vfio-ccw devices are believed to operate in a way compatible with
+ * discarding of memory in RAM blocks, ie. pages pinned in the host are
+ * in the current working set of the guest driver and therefore never
+ * overlap e.g., with pages available to the guest balloon driver. This
+ * needs to be set before vfio_get_device() for vfio common to handle
+ * ram_block_discard_disable().
+ */
+ vbasedev->ram_block_discard_allowed = true;
}
#ifdef CONFIG_IOMMUFD
--
2.34.1
- [PATCH v7 15/27] vfio/ap: Make vfio cdev pre-openable by passing a file handle, (continued)
- [PATCH v7 15/27] vfio/ap: Make vfio cdev pre-openable by passing a file handle, Zhenzhong Duan, 2023/11/21
- [PATCH v7 12/27] vfio/platform: Allow the selection of a given iommu backend, Zhenzhong Duan, 2023/11/21
- [PATCH v7 16/27] vfio/ccw: Allow the selection of a given iommu backend, Zhenzhong Duan, 2023/11/21
- [PATCH v7 17/27] vfio/ccw: Make vfio cdev pre-openable by passing a file handle, Zhenzhong Duan, 2023/11/21
- [PATCH v7 19/27] hw/arm: Activate IOMMUFD for virt machines, Zhenzhong Duan, 2023/11/21
- [PATCH v7 18/27] vfio: Make VFIOContainerBase poiner parameter const in VFIOIOMMUOps callbacks, Zhenzhong Duan, 2023/11/21
- [PATCH v7 20/27] kconfig: Activate IOMMUFD for s390x machines, Zhenzhong Duan, 2023/11/21
- [PATCH v7 23/27] vfio/platform: Move VFIODevice initializations in vfio_platform_instance_init, Zhenzhong Duan, 2023/11/21
- [PATCH v7 22/27] vfio/pci: Move VFIODevice initializations in vfio_instance_init, Zhenzhong Duan, 2023/11/21
- [PATCH v7 24/27] vfio/ap: Move VFIODevice initializations in vfio_ap_instance_init, Zhenzhong Duan, 2023/11/21
- [PATCH v7 25/27] vfio/ccw: Move VFIODevice initializations in vfio_ccw_instance_init,
Zhenzhong Duan <=
- [PATCH v7 21/27] hw/i386: Activate IOMMUFD for q35 machines, Zhenzhong Duan, 2023/11/21
- [PATCH v7 27/27] docs/devel: Add VFIO iommufd backend documentation, Zhenzhong Duan, 2023/11/21
- [PATCH v7 26/27] vfio: Introduce a helper function to initialize VFIODevice, Zhenzhong Duan, 2023/11/21
- Re: [PATCH v7 00/27] vfio: Adopt iommufd, Cédric Le Goater, 2023/11/21
- Re: [PATCH v7 00/27] vfio: Adopt iommufd, Nicolin Chen, 2023/11/21
- Re: [PATCH v7 00/27] vfio: Adopt iommufd, Joao Martins, 2023/11/22