Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
vfio/ap: Move VFIODevice initializations in vfio_ap_instance_init
Some of the VFIODevice initializations is in vfio_ap_realize,
move all of them in vfio_ap_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>
  • Loading branch information
duanzhenzhong authored and legoater committed Dec 19, 2023
1 parent a0cf44c commit cbbcc2f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions hw/vfio/ap.c
Expand Up @@ -164,18 +164,6 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
return;
}

vbasedev->ops = &vfio_ap_ops;
vbasedev->type = VFIO_DEVICE_TYPE_AP;
vbasedev->dev = dev;

/*
* vfio-ap devices operate in a way compatible with discarding of
* memory in RAM blocks, as no pages are pinned in the host.
* This needs to be set before vfio_get_device() for vfio common to
* handle ram_block_discard_disable().
*/
vapdev->vdev.ram_block_discard_allowed = true;

ret = vfio_attach_device(vbasedev->name, vbasedev,
&address_space_memory, errp);
if (ret) {
Expand Down Expand Up @@ -236,8 +224,20 @@ static const VMStateDescription vfio_ap_vmstate = {
static void vfio_ap_instance_init(Object *obj)
{
VFIOAPDevice *vapdev = VFIO_AP_DEVICE(obj);
VFIODevice *vbasedev = &vapdev->vdev;

vapdev->vdev.fd = -1;
vbasedev->type = VFIO_DEVICE_TYPE_AP;
vbasedev->ops = &vfio_ap_ops;
vbasedev->dev = DEVICE(vapdev);
vbasedev->fd = -1;

/*
* vfio-ap devices operate in a way compatible with discarding of
* memory in RAM blocks, as no pages are pinned in the host.
* 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
Expand Down

0 comments on commit cbbcc2f

Please sign in to comment.