Since the last commit, vfio_pci_igd_setup_opregion is only called in GVT-g mode. Move its functionality into vfio_pci_kvmgt_config_quirk for more GVT-g-specific error logging.
Also, hotplugging GVT-g vGPU is now always disallowed regardless of OpRegion to prevent potential issues. Intel has never claimed support for GVT-g hotplugging. Signed-off-by: Tomita Moeko <tomitamo...@gmail.com> --- hw/vfio/igd.c | 50 +++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 7a7c7735c1..cc397f8829 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -185,33 +185,6 @@ static bool vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, return true; } -static bool vfio_pci_igd_setup_opregion(VFIOPCIDevice *vdev, Error **errp) -{ - g_autofree struct vfio_region_info *opregion = NULL; - int ret; - - /* Hotplugging is not supported for opregion access */ - if (vdev->pdev.qdev.hotplugged) { - error_setg(errp, "IGD OpRegion is not supported on hotplugged device"); - return false; - } - - ret = vfio_device_get_region_info_type(&vdev->vbasedev, - VFIO_REGION_TYPE_PCI_VENDOR_TYPE | PCI_VENDOR_ID_INTEL, - VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION, &opregion); - if (ret) { - error_setg_errno(errp, -ret, - "Device does not supports IGD OpRegion feature"); - return false; - } - - if (!vfio_pci_igd_opregion_init(vdev, opregion, errp)) { - return false; - } - - return true; -} - /* * The rather short list of registers that we copy from the host devices. * The LPC/ISA bridge values are definitely needed to support the vBIOS, the @@ -681,11 +654,30 @@ error: */ static bool vfio_pci_kvmgt_config_quirk(VFIOPCIDevice *vdev, Error **errp) { - if ((vdev->features & VFIO_FEATURE_ENABLE_IGD_OPREGION) && - !vfio_pci_igd_setup_opregion(vdev, errp)) { + /* Hotplugging is not supported for opregion access */ + if (vdev->pdev.qdev.hotplugged) { + error_setg(errp, "Hotplugging Intel GVT-g vGPU is not supported."); return false; } + if (vdev->features & VFIO_FEATURE_ENABLE_IGD_OPREGION) { + g_autofree struct vfio_region_info *opregion = NULL; + int ret; + + ret = vfio_device_get_region_info_type(&vdev->vbasedev, + VFIO_REGION_TYPE_PCI_VENDOR_TYPE | PCI_VENDOR_ID_INTEL, + VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION, &opregion); + if (ret) { + /* Should never reach here, KVMGT always emulates OpRegion */ + error_setg(errp, "No OpRegion on Intel GVT-g vGPU."); + return false; + } + + if (!vfio_pci_igd_opregion_init(vdev, opregion, errp)) { + return false; + } + } + return true; } -- 2.47.2