aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhenzhong Duan <zhenzhong.duan@intel.com>2023-11-21 16:44:24 +0800
committerCédric Le Goater <clg@redhat.com>2023-12-19 19:03:38 +0100
commitc12b55ad6f9d3b4792b590e9211bd7319e4a2d70 (patch)
tree1de1c73900f790a60e664b98e3d0df286249c9d4
parentcbbcc2f1706aa1a08637142744d2f5f6515ac93f (diff)
downloadqemu-c12b55ad6f9d3b4792b590e9211bd7319e4a2d70.zip
qemu-c12b55ad6f9d3b4792b590e9211bd7319e4a2d70.tar.gz
qemu-c12b55ad6f9d3b4792b590e9211bd7319e4a2d70.tar.bz2
vfio/ccw: Move VFIODevice initializations in vfio_ccw_instance_init
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> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>
-rw-r--r--hw/vfio/ccw.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 2afdf17..6305a4c 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