ramfb: Add property to control if load the romfile
PATCH v2 1/1 ramfb: Add property to control if load the romfile
Now the ramfb will load the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.
Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.
So add a new property use_legacy_x86_rom in both ramfb and vfio_pci device, because the vfio display also use the ramfb_setup() to load the vgabios-ramfb.bin file.
After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.
--- hw/display/ramfb-standalone.c | 4 +++- hw/display/ramfb-stubs.c | 2 +- hw/display/ramfb.c | 6 ++++-- hw/vfio/display.c | 4 ++-- hw/vfio/pci.c | 1 + hw/vfio/pci.h | 1 + include/hw/display/ramfb.h | 2 +- 7 files changed, 13 insertions(+), 7 deletions(-)
hw/display/ramfb-standalone.c +3 -1
@@ -17,6 +17,7 @@ struct RAMFBStandaloneState {QemuConsole *con;RAMFBState *state;bool migrate; +bool use_legacy_x86_rom; };static void display_update_wrapper (void *dev)
@@ -39,7 +40,7 @@ static void ramfb_realizefn(DeviceState *dev, Error **errp)RAMFBStandaloneState *ramfb =RAMFB (dev); ramfb->con =graphic_console_init (dev,0 , &wrapper_ops, dev); - ramfb->state =ramfb_setup (errp); + ramfb->state =ramfb_setup (ramfb->use_legacy_x86_rom, errp); }static bool migrate_needed (void *opaque)
@@ -62,6 +63,7 @@ static const VMStateDescription ramfb_dev_vmstate = {static const Property ramfb_properties[] = {DEFINE_PROP_BOOL ("x-migrate" , RAMFBStandaloneState, migrate, true), +DEFINE_PROP_BOOL ("use-legacy-x86-rom" , RAMFBStandaloneState, use_legacy_x86_rom, true), };static void ramfb_class_initfn (ObjectClass *klass,void *data)
hw/display/ramfb-stubs.c +1 -1
@@ -8,7 +8,7 @@ void ramfb_display_update(QemuConsole *con, RAMFBState *s) { } -RAMFBState *ramfb_setup (Error **errp) +RAMFBState *ramfb_setup (bool romfile,Error **errp) {error_setg (errp,"ramfb support not available" );return NULL ;
hw/display/ramfb.c +4 -2
@@ -135,7 +135,7 @@ const VMStateDescription ramfb_vmstate = { } }; -RAMFBState *ramfb_setup (Error **errp) +RAMFBState *ramfb_setup (bool romfile,Error **errp) {FWCfgState *fw_cfg =fw_cfg_find ();RAMFBState *s;
@@ -147,7 +147,9 @@ RAMFBState *ramfb_setup(Error **errp) s =g_new0 (RAMFBState,1 ); -rom_add_vga ("vgabios-ramfb.bin" ); +if (romfile) { +rom_add_vga ("vgabios-ramfb.bin" ); + }fw_cfg_add_file_callback (fw_cfg,"etc/ramfb" ,NULL , ramfb_fw_cfg_write, s, &s->cfg,sizeof (s->cfg), false);
hw/vfio/display.c +2 -2
@@ -365,7 +365,7 @@ static bool vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp) &vfio_display_dmabuf_ops, vdev);if (vdev->enable_ramfb) { - vdev->dpy->ramfb =ramfb_setup (errp); + vdev->dpy->ramfb =ramfb_setup (vdev->use_legacy_x86_rom, errp);if (!vdev->dpy->ramfb) {return false; }
@@ -494,7 +494,7 @@ static bool vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp) &vfio_display_region_ops, vdev);if (vdev->enable_ramfb) { - vdev->dpy->ramfb =ramfb_setup (errp); + vdev->dpy->ramfb =ramfb_setup (vdev->use_legacy_x86_rom, errp);if (!vdev->dpy->ramfb) {return false; }
hw/vfio/pci.c +1 -0
@@ -3564,6 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {static const Property vfio_pci_dev_nohotplug_properties[] = {DEFINE_PROP_BOOL ("ramfb" , VFIOPCIDevice, enable_ramfb, false), +DEFINE_PROP_BOOL ("use_legacy_x86_rom" , VFIOPCIDevice, use_legacy_x86_rom, true),DEFINE_PROP_ON_OFF_AUTO ("x-ramfb-migrate" , VFIOPCIDevice, ramfb_migrate,ON_OFF_AUTO_AUTO ), };
hw/vfio/pci.h +1 -0
@@ -177,6 +177,7 @@ struct VFIOPCIDevice {bool no_kvm_ioeventfd;bool no_vfio_ioeventfd;bool enable_ramfb; +bool use_legacy_x86_rom;OnOffAuto ramfb_migrate;bool defer_kvm_irq_routing;bool clear_parent_atomics_on_exit;
include/hw/display/ramfb.h +1 -1
@@ -6,7 +6,7 @@/* ramfb.c */ typedef struct RAMFBState RAMFBState ;void ramfb_display_update (QemuConsole *con,RAMFBState *s); -RAMFBState *ramfb_setup (Error **errp); +RAMFBState *ramfb_setup (bool romfile,Error **errp);extern const VMStateDescription ramfb_vmstate;
Signature · 1 line
2.40.1
Quoted 8 lines · Shaoqin Huang
Now the ramfb will load the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.
Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.
Quoted 6 lines
So add a new property
use_legacy_x86_romin both ramfb andvfio_pcidevice, because the vfio display also use theramfb_setup()to load the vgabios-ramfb.bin file.After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.
Can you make this a series, with an additional patch that updates the current in-dev machine types to use this new property, so we're clear about the proposed usage.
Quoted 140 lines
Signed-off-by Shaoqin Huang <[email protected]>--- hw/display/ramfb-standalone.c | 4 +++- hw/display/ramfb-stubs.c | 2 +- hw/display/ramfb.c | 6 ++++-- hw/vfio/display.c | 4 ++-- hw/vfio/pci.c | 1 + hw/vfio/pci.h | 1 + include/hw/display/ramfb.h | 2 +- 7 files changed, 13 insertions(+), 7 deletions(-)hw/display/ramfb-standalone.c +3
-1@@ -17,6 +17,7 @@ struct RAMFBStandaloneState {QemuConsole *con;RAMFBState *state;bool migrate; +bool use_legacy_x86_rom; };static void display_update_wrapper (void *dev)@@ -39,7 +40,7 @@ static void ramfb_realizefn(DeviceState *dev, Error **errp)RAMFBStandaloneState *ramfb =RAMFB (dev); ramfb->con =graphic_console_init (dev,0 , &wrapper_ops, dev); - ramfb->state =ramfb_setup (errp); + ramfb->state =ramfb_setup (ramfb->use_legacy_x86_rom, errp); }static bool migrate_needed (void *opaque)@@ -62,6 +63,7 @@ static const VMStateDescription ramfb_dev_vmstate = {static const Property ramfb_properties[] = {DEFINE_PROP_BOOL ("x-migrate" , RAMFBStandaloneState, migrate, true), +DEFINE_PROP_BOOL ("use-legacy-x86-rom" , RAMFBStandaloneState, use_legacy_x86_rom, true), };static void ramfb_class_initfn (ObjectClass *klass,void *data)hw/display/ramfb-stubs.c +1
-1@@ -8,7 +8,7 @@ void ramfb_display_update(QemuConsole *con, RAMFBState *s) { } -RAMFBState *ramfb_setup (Error **errp) +RAMFBState *ramfb_setup (bool romfile,Error **errp) {error_setg (errp,"ramfb support not available" );return NULL ;hw/display/ramfb.c +4
-2@@ -135,7 +135,7 @@ const VMStateDescription ramfb_vmstate = { } }; -RAMFBState *ramfb_setup (Error **errp) +RAMFBState *ramfb_setup (bool romfile,Error **errp) {FWCfgState *fw_cfg =fw_cfg_find ();RAMFBState *s;@@ -147,7 +147,9 @@ RAMFBState *ramfb_setup(Error **errp) s =g_new0 (RAMFBState,1 ); -rom_add_vga ("vgabios-ramfb.bin" ); +if (romfile) { +rom_add_vga ("vgabios-ramfb.bin" ); + }fw_cfg_add_file_callback (fw_cfg,"etc/ramfb" ,NULL , ramfb_fw_cfg_write, s, &s->cfg,sizeof (s->cfg), false);hw/vfio/display.c +2
-2@@ -365,7 +365,7 @@ static bool vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp) &vfio_display_dmabuf_ops, vdev);if (vdev->enable_ramfb) { - vdev->dpy->ramfb =ramfb_setup (errp); + vdev->dpy->ramfb =ramfb_setup (vdev->use_legacy_x86_rom, errp);if (!vdev->dpy->ramfb) {return false; }@@ -494,7 +494,7 @@ static bool vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp) &vfio_display_region_ops, vdev);if (vdev->enable_ramfb) { - vdev->dpy->ramfb =ramfb_setup (errp); + vdev->dpy->ramfb =ramfb_setup (vdev->use_legacy_x86_rom, errp);if (!vdev->dpy->ramfb) {return false; }hw/vfio/pci.c +1
-0@@ -3564,6 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {static const Property vfio_pci_dev_nohotplug_properties[] = {DEFINE_PROP_BOOL ("ramfb" , VFIOPCIDevice, enable_ramfb, false), +DEFINE_PROP_BOOL ("use_legacy_x86_rom" , VFIOPCIDevice, use_legacy_x86_rom, true),DEFINE_PROP_ON_OFF_AUTO ("x-ramfb-migrate" , VFIOPCIDevice, ramfb_migrate,ON_OFF_AUTO_AUTO ), };hw/vfio/pci.h +1
-0@@ -177,6 +177,7 @@ struct VFIOPCIDevice {bool no_kvm_ioeventfd;bool no_vfio_ioeventfd;bool enable_ramfb; +bool use_legacy_x86_rom;OnOffAuto ramfb_migrate;bool defer_kvm_irq_routing;bool clear_parent_atomics_on_exit;include/hw/display/ramfb.h +1
-1@@ -6,7 +6,7 @@/* ramfb.c */ typedef struct RAMFBState RAMFBState ;void ramfb_display_update (QemuConsole *con,RAMFBState *s); -RAMFBState *ramfb_setup (Error **errp); +RAMFBState *ramfb_setup (bool romfile,Error **errp);extern const VMStateDescription ramfb_vmstate;Signature · 1 line
2.40.1
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 13 lines · Daniel P. Berrangé
Quoted 12 lines · Shaoqin Huang
Now the ramfb will load the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.
Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.
So add a new property
use_legacy_x86_romin both ramfb andvfio_pcidevice, because the vfio display also use theramfb_setup()to load the vgabios-ramfb.bin file.
Quoted 6 lines
Quoted 2 lines
After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.
Can you make this a series, with an additional patch that updates the current in-dev machine types to use this new property, so we're clear about the proposed usage.
yes. And please change the vfio-pci property name to use underscores.
C.
Quoted 14 lines · Cédric Le Goater
Quoted 13 lines · Daniel P. Berrangé
Quoted 12 lines · Shaoqin Huang
Now the ramfb will load the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.
Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.
So add a new property
use_legacy_x86_romin both ramfb andvfio_pcidevice, because the vfio display also use theramfb_setup()to load the vgabios-ramfb.bin file.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.
Can you make this a series, with an additional patch that updates the current in-dev machine types to use this new property, so we're clear about the proposed usage.
yes. And please change the vfio-pci property name to use underscores.
Sorry, to *not* use underscores : use-legacy-x86-rom
Thanks,
C.
Quoted 18 lines · Cédric Le Goater
Quoted 17 lines · Cédric Le Goater
Quoted 16 lines · Daniel P. Berrangé
Quoted 14 lines · Shaoqin Huang
Now the ramfb will load the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.
Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.
So add a new property
use_legacy_x86_romin both ramfb andvfio_pcidevice, because the vfio display also use theramfb_setup()to load the vgabios-ramfb.bin file.After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Can you make this a series, with an additional patch that updates the current in-dev machine types to use this new property, so we're clear about the proposed usage.
yes. And please change the vfio-pci property name to use underscores.
Sorry, to *not* use underscores : use-legacy-x86-rom
Thanks for pointing out it. Will fix it.
Thanks.
Quoted 7 lines
Thanks,
C.
Signature · 1 line
Shaoqin
Quoted 23 lines · On Mon, 9 Jun 2025 13:16:14 +0800 Shaoqin Huang <[email protected]> wrote:
Quoted 22 lines · Cédric Le Goater
Quoted 21 lines · Cédric Le Goater
Quoted 19 lines · Daniel P. Berrangé
Quoted 8 lines · Shaoqin Huang
Now the ramfb will load the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.
Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.
Quoted 6 lines
So add a new property
use_legacy_x86_romin both ramfb andvfio_pcidevice, because the vfio display also use theramfb_setup()to load the vgabios-ramfb.bin file.After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.
Can you make this a series, with an additional patch that updates the current in-dev machine types to use this new property, so we're clear about the proposed usage.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
yes. And please change the vfio-pci property name to use underscores.
Sorry, to *not* use underscores : use-legacy-x86-rom
Thanks for pointing out it. Will fix it.
It's also not evident from the property that this is restricted to ramfb behavior. Should the option on the vfio-pci device be prefixed with ramfb? Thanks,
Alex
Quoted 39 lines · Daniel P. Berrangé
Quoted 8 lines · Shaoqin Huang
Now the ramfb will load the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.
Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.
Quoted 6 lines
So add a new property
use_legacy_x86_romin both ramfb andvfio_pcidevice, because the vfio display also use theramfb_setup()to load the vgabios-ramfb.bin file.After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.
Can you make this a series, with an additional patch that updates the current in-dev machine types to use this new property, so we're clear about the proposed usage.
Quoted 19 lines
Signed-off-by Shaoqin Huang <[email protected]>--- hw/display/ramfb-standalone.c | 4 +++- hw/display/ramfb-stubs.c | 2 +- hw/display/ramfb.c | 6 ++++-- hw/vfio/display.c | 4 ++-- hw/vfio/pci.c | 1 + hw/vfio/pci.h | 1 + include/hw/display/ramfb.h | 2 +- 7 files changed, 13 insertions(+), 7 deletions(-)hw/vfio/pci.c +0
-0@@ -3564,6 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {
Quoted 6 lines
hw/vfio/pci.c static const TypeInfo vfio_pci_dev_info = { · line 3570
Quoted 6 lines
hw/vfio/pci.c +1
-0static const Property vfio_pci_dev_nohotplug_properties[] = {DEFINE_PROP_BOOL ("ramfb" , VFIOPCIDevice, enable_ramfb, false), +DEFINE_PROP_BOOL ("use_legacy_x86_rom" , VFIOPCIDevice, use_legacy_x86_rom, true),DEFINE_PROP_ON_OFF_AUTO ("x-ramfb-migrate" , VFIOPCIDevice, ramfb_migrate,ON_OFF_AUTO_AUTO ), };
Alternatively with target-info API:
-- >8 --
hw/display/ramfb.c +10 -1
@@ -12,6 +12,7 @@*/ #include "qemu/osdep.h" +#include "qemu/target-info.h" #include "qapi/error.h" #include "hw/loader.h" #include "hw/display/ramfb.h"
@@ -147,7 +148,15 @@ RAMFBState *ramfb_setup(Error **errp) s =g_new0 (RAMFBState,1 ); -rom_add_vga ("vgabios-ramfb.bin" ); +switch (target_system_arch ()) { +case SYS_EMU_TARGET_I386 : +case SYS_EMU_TARGET_X86_64 : +rom_add_vga ("vgabios-ramfb.bin" ); +break ; +default : +break ; + } +fw_cfg_add_file_callback (fw_cfg,"etc/ramfb" ,NULL , ramfb_fw_cfg_write, s, &s->cfg,sizeof (s->cfg), false);
---
Recent work event introduces target_base_FOO() so that'd be:
-- >8 --
hw/display/ramfb.c +5 -1
@@ -12,6 +12,7 @@*/ #include "qemu/osdep.h" +#include "qemu/target-info.h" #include "qapi/error.h" #include "hw/loader.h" #include "hw/display/ramfb.h"
@@ -147,7 +148,10 @@ RAMFBState *ramfb_setup(Error **errp) s =g_new0 (RAMFBState,1 ); -rom_add_vga ("vgabios-ramfb.bin" ); +if (target_base_x86 ()) { +rom_add_vga ("vgabios-ramfb.bin" ); + } +fw_cfg_add_file_callback (fw_cfg,"etc/ramfb" ,NULL , ramfb_fw_cfg_write, s, &s->cfg,sizeof (s->cfg), false);
---
Unfortunately I had to focus on more urgent stuff so this isn't merged yet (besides I hurt a finger yesterday and am now typing slower). I hope I'd be able to respin that next week.
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Daniel P. Berrangé
Quoted 8 lines · Shaoqin Huang
Now the ramfb will load the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.
Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.
Quoted 6 lines
So add a new property
use_legacy_x86_romin both ramfb andvfio_pcidevice, because the vfio display also use theramfb_setup()to load the vgabios-ramfb.bin file.After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.
Can you make this a series, with an additional patch that updates the current in-dev machine types to use this new property, so we're clear about the proposed usage.
Quoted 11 lines
Signed-off-by Shaoqin Huang <[email protected]>--- hw/display/ramfb-standalone.c | 4 +++- hw/display/ramfb-stubs.c | 2 +- hw/display/ramfb.c | 6 ++++-- hw/vfio/display.c | 4 ++-- hw/vfio/pci.c | 1 + hw/vfio/pci.h | 1 + include/hw/display/ramfb.h | 2 +- 7 files changed, 13 insertions(+), 7 deletions(-)
Quoted 13 lines
Quoted 11 lines
hw/vfio/pci.c static const TypeInfo vfio_pci_dev_info = { · line 3569
Quoted 11 lines
hw/vfio/pci.c +1
-0@@ -3564,6 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {static const Property vfio_pci_dev_nohotplug_properties[] = {DEFINE_PROP_BOOL ("ramfb" , VFIOPCIDevice, enable_ramfb, false), +DEFINE_PROP_BOOL ("use_legacy_x86_rom" , VFIOPCIDevice, use_legacy_x86_rom, true),DEFINE_PROP_ON_OFF_AUTO ("x-ramfb-migrate" , VFIOPCIDevice, ramfb_migrate,ON_OFF_AUTO_AUTO ), };Alternatively with target-info API:
Don't we need to use the property in order to tie this to the machine type ? Even if existing non-x86 machines are not using this ROM, the fact that QEMU loaded it will impact the guest memory layout which needs to be preserved across migration, and thus machine type versions.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 110 lines · Philippe Mathieu-Daudé
Quoted 39 lines · Daniel P. Berrangé
Quoted 8 lines · Shaoqin Huang
Now the ramfb will load the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.
Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.
Quoted 6 lines
So add a new property
use_legacy_x86_romin both ramfb andvfio_pcidevice, because the vfio display also use theramfb_setup()to load the vgabios-ramfb.bin file.After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.
Can you make this a series, with an additional patch that updates the current in-dev machine types to use this new property, so we're clear about the proposed usage.
Quoted 19 lines
Signed-off-by Shaoqin Huang <[email protected]>--- hw/display/ramfb-standalone.c | 4 +++- hw/display/ramfb-stubs.c | 2 +- hw/display/ramfb.c | 6 ++++-- hw/vfio/display.c | 4 ++-- hw/vfio/pci.c | 1 + hw/vfio/pci.h | 1 + include/hw/display/ramfb.h | 2 +- 7 files changed, 13 insertions(+), 7 deletions(-)hw/vfio/pci.c +0
-0@@ -3564,6 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {Quoted 6 lines
hw/vfio/pci.c static const TypeInfo vfio_pci_dev_info = { · line 3570
Quoted 6 lines
hw/vfio/pci.c +1
-0static const Property vfio_pci_dev_nohotplug_properties[] = {DEFINE_PROP_BOOL ("ramfb" , VFIOPCIDevice, enable_ramfb, false), +DEFINE_PROP_BOOL ("use_legacy_x86_rom" , VFIOPCIDevice, use_legacy_x86_rom, true),DEFINE_PROP_ON_OFF_AUTO ("x-ramfb-migrate" , VFIOPCIDevice, ramfb_migrate,ON_OFF_AUTO_AUTO ), };Alternatively with target-info API:
-- >8 --
hw/display/ramfb.c +10
-2@@ -12,6 +12,7 @@*/ #include "qemu/osdep.h" +#include "qemu/target-info.h" #include "qapi/error.h" #include "hw/loader.h" #include "hw/display/ramfb.h" @@ -147,7 +148,15 @@ RAMFBState *ramfb_setup(Error **errp) s =g_new0 (RAMFBState,1 ); -rom_add_vga ("vgabios-ramfb.bin" ); +switch (target_system_arch ()) { +case SYS_EMU_TARGET_I386 : +case SYS_EMU_TARGET_X86_64 : +rom_add_vga ("vgabios-ramfb.bin" ); +break ; +default : +break ; + } +fw_cfg_add_file_callback (fw_cfg,"etc/ramfb" ,NULL , ramfb_fw_cfg_write, s, &s->cfg,sizeof (s->cfg), false); ---Recent work event introduces
target_base_FOO()so that'd be:-- >8 --
hw/display/ramfb.c +5
-2@@ -12,6 +12,7 @@*/ #include "qemu/osdep.h" +#include "qemu/target-info.h" #include "qapi/error.h" #include "hw/loader.h" #include "hw/display/ramfb.h" @@ -147,7 +148,10 @@ RAMFBState *ramfb_setup(Error **errp) s =g_new0 (RAMFBState,1 ); -rom_add_vga ("vgabios-ramfb.bin" ); +if (target_base_x86 ()) { +rom_add_vga ("vgabios-ramfb.bin" ); + } +fw_cfg_add_file_callback (fw_cfg,"etc/ramfb" ,NULL , ramfb_fw_cfg_write, s, &s->cfg,sizeof (s->cfg), false); ---
Quoted 3 lines
Unfortunately I had to focus on more urgent stuff so this isn't merged yet (besides I hurt a finger yesterday and am now typing slower). I hope I'd be able to respin that next week.
In case it's too much effort to respin all the series in a close future, maybe it could be a good idea to just send target_system_arch(), so that people can start using it. From there, people can add target_base_FOO() easily on a as needed basis, without any hard conflict issue.
Thanks,
Pierrick
Hi Daniel,
Quoted 13 lines · Daniel P. Berrangé
Quoted 12 lines · Shaoqin Huang
Now the ramfb will load the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.
Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.
So add a new property
use_legacy_x86_romin both ramfb andvfio_pcidevice, because the vfio display also use theramfb_setup()to load the vgabios-ramfb.bin file.
Quoted 7 lines
Quoted 2 lines
After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.
Can you make this a series, with an additional patch that updates the current in-dev machine types to use this new property, so we're clear about the proposed usage.
Ok. Thanks for notification. I will update it in the version 3.
Quoted 143 lines
Quoted 140 lines
Signed-off-by Shaoqin Huang <[email protected]>--- hw/display/ramfb-standalone.c | 4 +++- hw/display/ramfb-stubs.c | 2 +- hw/display/ramfb.c | 6 ++++-- hw/vfio/display.c | 4 ++-- hw/vfio/pci.c | 1 + hw/vfio/pci.h | 1 + include/hw/display/ramfb.h | 2 +- 7 files changed, 13 insertions(+), 7 deletions(-)hw/display/ramfb-standalone.c +3
-1@@ -17,6 +17,7 @@ struct RAMFBStandaloneState {QemuConsole *con;RAMFBState *state;bool migrate; +bool use_legacy_x86_rom; };static void display_update_wrapper (void *dev)@@ -39,7 +40,7 @@ static void ramfb_realizefn(DeviceState *dev, Error **errp)RAMFBStandaloneState *ramfb =RAMFB (dev); ramfb->con =graphic_console_init (dev,0 , &wrapper_ops, dev); - ramfb->state =ramfb_setup (errp); + ramfb->state =ramfb_setup (ramfb->use_legacy_x86_rom, errp); }static bool migrate_needed (void *opaque)@@ -62,6 +63,7 @@ static const VMStateDescription ramfb_dev_vmstate = {static const Property ramfb_properties[] = {DEFINE_PROP_BOOL ("x-migrate" , RAMFBStandaloneState, migrate, true), +DEFINE_PROP_BOOL ("use-legacy-x86-rom" , RAMFBStandaloneState, use_legacy_x86_rom, true), };static void ramfb_class_initfn (ObjectClass *klass,void *data)hw/display/ramfb-stubs.c +1
-1@@ -8,7 +8,7 @@ void ramfb_display_update(QemuConsole *con, RAMFBState *s) { } -RAMFBState *ramfb_setup (Error **errp) +RAMFBState *ramfb_setup (bool romfile,Error **errp) {error_setg (errp,"ramfb support not available" );return NULL ;hw/display/ramfb.c +4
-2@@ -135,7 +135,7 @@ const VMStateDescription ramfb_vmstate = { } }; -RAMFBState *ramfb_setup (Error **errp) +RAMFBState *ramfb_setup (bool romfile,Error **errp) {FWCfgState *fw_cfg =fw_cfg_find ();RAMFBState *s;@@ -147,7 +147,9 @@ RAMFBState *ramfb_setup(Error **errp) s =g_new0 (RAMFBState,1 ); -rom_add_vga ("vgabios-ramfb.bin" ); +if (romfile) { +rom_add_vga ("vgabios-ramfb.bin" ); + }fw_cfg_add_file_callback (fw_cfg,"etc/ramfb" ,NULL , ramfb_fw_cfg_write, s, &s->cfg,sizeof (s->cfg), false);hw/vfio/display.c +2
-2@@ -365,7 +365,7 @@ static bool vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp) &vfio_display_dmabuf_ops, vdev);if (vdev->enable_ramfb) { - vdev->dpy->ramfb =ramfb_setup (errp); + vdev->dpy->ramfb =ramfb_setup (vdev->use_legacy_x86_rom, errp);if (!vdev->dpy->ramfb) {return false; }@@ -494,7 +494,7 @@ static bool vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp) &vfio_display_region_ops, vdev);if (vdev->enable_ramfb) { - vdev->dpy->ramfb =ramfb_setup (errp); + vdev->dpy->ramfb =ramfb_setup (vdev->use_legacy_x86_rom, errp);if (!vdev->dpy->ramfb) {return false; }hw/vfio/pci.c +1
-0@@ -3564,6 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {static const Property vfio_pci_dev_nohotplug_properties[] = {DEFINE_PROP_BOOL ("ramfb" , VFIOPCIDevice, enable_ramfb, false), +DEFINE_PROP_BOOL ("use_legacy_x86_rom" , VFIOPCIDevice, use_legacy_x86_rom, true),DEFINE_PROP_ON_OFF_AUTO ("x-ramfb-migrate" , VFIOPCIDevice, ramfb_migrate,ON_OFF_AUTO_AUTO ), };hw/vfio/pci.h +1
-0@@ -177,6 +177,7 @@ struct VFIOPCIDevice {bool no_kvm_ioeventfd;bool no_vfio_ioeventfd;bool enable_ramfb; +bool use_legacy_x86_rom;OnOffAuto ramfb_migrate;bool defer_kvm_irq_routing;bool clear_parent_atomics_on_exit;include/hw/display/ramfb.h +1
-1@@ -6,7 +6,7 @@/* ramfb.c */ typedef struct RAMFBState RAMFBState ;void ramfb_display_update (QemuConsole *con,RAMFBState *s); -RAMFBState *ramfb_setup (Error **errp); +RAMFBState *ramfb_setup (bool romfile,Error **errp);extern const VMStateDescription ramfb_vmstate;Signature · 1 line
2.40.1With regards,
Daniel
Signature · 1 line
Shaoqin