mirror of https://github.com/xemu-project/xemu.git
hw/vfio/display: add ramfb support
So we have a boot display when using a vgpu as primary display. ramfb depends on a fw_cfg file. fw_cfg files can not be added and removed at runtime, therefore a ramfb-enabled vfio device can't be hotplugged. Add a nohotplug variant of the vfio-pci device (as child class). Add the ramfb property to the nohotplug variant only. So to enable the vgpu display with boot support use this: -device vfio-pci-nohotplug,display=on,ramfb=on,sysfsdev=... Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
7f623d0834
commit
b290659fc3
|
@ -124,6 +124,9 @@ static void vfio_display_dmabuf_update(void *opaque)
|
||||||
|
|
||||||
primary = vfio_display_get_dmabuf(vdev, DRM_PLANE_TYPE_PRIMARY);
|
primary = vfio_display_get_dmabuf(vdev, DRM_PLANE_TYPE_PRIMARY);
|
||||||
if (primary == NULL) {
|
if (primary == NULL) {
|
||||||
|
if (dpy->ramfb) {
|
||||||
|
ramfb_display_update(dpy->con, dpy->ramfb);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +184,9 @@ static int vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp)
|
||||||
vdev->dpy->con = graphic_console_init(DEVICE(vdev), 0,
|
vdev->dpy->con = graphic_console_init(DEVICE(vdev), 0,
|
||||||
&vfio_display_dmabuf_ops,
|
&vfio_display_dmabuf_ops,
|
||||||
vdev);
|
vdev);
|
||||||
|
if (vdev->enable_ramfb) {
|
||||||
|
vdev->dpy->ramfb = ramfb_setup(errp);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +234,9 @@ static void vfio_display_region_update(void *opaque)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plane.drm_format || !plane.size) {
|
if (!plane.drm_format || !plane.size) {
|
||||||
|
if (dpy->ramfb) {
|
||||||
|
ramfb_display_update(dpy->con, dpy->ramfb);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
format = qemu_drm_format_to_pixman(plane.drm_format);
|
format = qemu_drm_format_to_pixman(plane.drm_format);
|
||||||
|
@ -300,6 +309,9 @@ static int vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp)
|
||||||
vdev->dpy->con = graphic_console_init(DEVICE(vdev), 0,
|
vdev->dpy->con = graphic_console_init(DEVICE(vdev), 0,
|
||||||
&vfio_display_region_ops,
|
&vfio_display_region_ops,
|
||||||
vdev);
|
vdev);
|
||||||
|
if (vdev->enable_ramfb) {
|
||||||
|
vdev->dpy->ramfb = ramfb_setup(errp);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3067,6 +3067,10 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
||||||
goto out_teardown;
|
goto out_teardown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (vdev->enable_ramfb && vdev->dpy == NULL) {
|
||||||
|
error_setg(errp, "ramfb=on requires display=on");
|
||||||
|
goto out_teardown;
|
||||||
|
}
|
||||||
|
|
||||||
vfio_register_err_notifier(vdev);
|
vfio_register_err_notifier(vdev);
|
||||||
vfio_register_req_notifier(vdev);
|
vfio_register_req_notifier(vdev);
|
||||||
|
@ -3258,9 +3262,30 @@ static const TypeInfo vfio_pci_dev_info = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static Property vfio_pci_dev_nohotplug_properties[] = {
|
||||||
|
DEFINE_PROP_BOOL("ramfb", VFIOPCIDevice, enable_ramfb, false),
|
||||||
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
};
|
||||||
|
|
||||||
|
static void vfio_pci_nohotplug_dev_class_init(ObjectClass *klass, void *data)
|
||||||
|
{
|
||||||
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
|
dc->props = vfio_pci_dev_nohotplug_properties;
|
||||||
|
dc->hotpluggable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const TypeInfo vfio_pci_nohotplug_dev_info = {
|
||||||
|
.name = "vfio-pci-nohotplug",
|
||||||
|
.parent = "vfio-pci",
|
||||||
|
.instance_size = sizeof(VFIOPCIDevice),
|
||||||
|
.class_init = vfio_pci_nohotplug_dev_class_init,
|
||||||
|
};
|
||||||
|
|
||||||
static void register_vfio_pci_dev_type(void)
|
static void register_vfio_pci_dev_type(void)
|
||||||
{
|
{
|
||||||
type_register_static(&vfio_pci_dev_info);
|
type_register_static(&vfio_pci_dev_info);
|
||||||
|
type_register_static(&vfio_pci_nohotplug_dev_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
type_init(register_vfio_pci_dev_type)
|
type_init(register_vfio_pci_dev_type)
|
||||||
|
|
|
@ -165,6 +165,7 @@ typedef struct VFIOPCIDevice {
|
||||||
bool no_geforce_quirks;
|
bool no_geforce_quirks;
|
||||||
bool no_kvm_ioeventfd;
|
bool no_kvm_ioeventfd;
|
||||||
bool no_vfio_ioeventfd;
|
bool no_vfio_ioeventfd;
|
||||||
|
bool enable_ramfb;
|
||||||
VFIODisplay *dpy;
|
VFIODisplay *dpy;
|
||||||
} VFIOPCIDevice;
|
} VFIOPCIDevice;
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "qemu/queue.h"
|
#include "qemu/queue.h"
|
||||||
#include "qemu/notify.h"
|
#include "qemu/notify.h"
|
||||||
#include "ui/console.h"
|
#include "ui/console.h"
|
||||||
|
#include "hw/display/ramfb.h"
|
||||||
#ifdef CONFIG_LINUX
|
#ifdef CONFIG_LINUX
|
||||||
#include <linux/vfio.h>
|
#include <linux/vfio.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -147,6 +148,7 @@ typedef struct VFIODMABuf {
|
||||||
|
|
||||||
typedef struct VFIODisplay {
|
typedef struct VFIODisplay {
|
||||||
QemuConsole *con;
|
QemuConsole *con;
|
||||||
|
RAMFBState *ramfb;
|
||||||
struct {
|
struct {
|
||||||
VFIORegion buffer;
|
VFIORegion buffer;
|
||||||
DisplaySurface *surface;
|
DisplaySurface *surface;
|
||||||
|
|
Loading…
Reference in New Issue