Commit 4225f2b6 authored by Alex Williamson's avatar Alex Williamson
Browse files

vfio/pci: Fix return of vfio_populate_vga()



This function returns success if either we setup the VGA region or
the host vfio doesn't return enough regions to support the VGA index.
This latter case doesn't make any sense.  If we're asked to populate
VGA, fail if it doesn't exist and let the caller decide if that's
important.

Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
Reviewed-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Tested-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent e61a424f
Loading
Loading
Loading
Loading
+26 −29
Original line number Diff line number Diff line
@@ -2061,9 +2061,7 @@ int vfio_populate_vga(VFIOPCIDevice *vdev)
    struct vfio_region_info *reg_info;
    int ret;

    if (vbasedev->num_regions > VFIO_PCI_VGA_REGION_INDEX) {
        ret = vfio_get_region_info(vbasedev,
                                   VFIO_PCI_VGA_REGION_INDEX, &reg_info);
    ret = vfio_get_region_info(vbasedev, VFIO_PCI_VGA_REGION_INDEX, &reg_info);
    if (ret) {
        return ret;
    }
@@ -2096,7 +2094,6 @@ int vfio_populate_vga(VFIOPCIDevice *vdev)
    vdev->vga->region[QEMU_PCI_VGA_IO_HI].offset = QEMU_PCI_VGA_IO_HI_BASE;
    vdev->vga->region[QEMU_PCI_VGA_IO_HI].nr = QEMU_PCI_VGA_IO_HI;
    QLIST_INIT(&vdev->vga->region[QEMU_PCI_VGA_IO_HI].quirks);
    }

    return 0;
}