Skip to contentSkip to conversation

ramfb: Add property to control if load the romfile

PATCH Superseded Shaoqin Huang 5 participants 10 messages Jun 5, 2025 – Jun 6, 2025

v1 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

So add a new property ramfb-romfile 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
index 1be106b57f..2b96a49baa 100644
@@ -17,6 +17,7 @@ struct RAMFBStandaloneState {
     QemuConsole *con;
     RAMFBState *state;
     bool migrate;
+    bool ramfb_romfile;
 };
 
 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->ramfb_romfile, 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("ramfb-romfile", RAMFBStandaloneState, ramfb_romfile, true),
 };
 
 static void ramfb_class_initfn(ObjectClass *klass, void *data)
hw/display/ramfb-stubs.c +1 -1
index cf64733b10..b83551357b 100644
@@ -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
index 8c0f907673..9a17d97d07 100644
@@ -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
index ea87830fe0..56f10564f9 100644
@@ -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->ramfb_romfile, 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->ramfb_romfile, errp);
         if (!vdev->dpy->ramfb) {
             return false;
         }
hw/vfio/pci.c +1 -0
index 7f1532fbed..bfdf365978 100644
@@ -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("ramfb-romfile", VFIOPCIDevice, ramfb_romfile, true),
     DEFINE_PROP_ON_OFF_AUTO("x-ramfb-migrate", VFIOPCIDevice, ramfb_migrate,
                             ON_OFF_AUTO_AUTO),
 };
hw/vfio/pci.h +1 -0
index d94ecaba68..d567de8f10 100644
@@ -177,6 +177,7 @@ struct VFIOPCIDevice {
     bool no_kvm_ioeventfd;
     bool no_vfio_ioeventfd;
     bool enable_ramfb;
+    bool ramfb_romfile;
     OnOffAuto ramfb_migrate;
     bool defer_kvm_irq_routing;
     bool clear_parent_atomics_on_exit;
include/hw/display/ramfb.h +1 -1
index a7e0019144..172aa6dc89 100644
@@ -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
#1 lore raw

Hi Shaoqin,

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.

So add a new property ramfb-romfile 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.

Quoted 9 lines
---
  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(-)

Simpler to directly pass the ROM path instead of using a boolean, so board (or CLI) could pass path to non-x86 rom.

hw/vfio/pci.c static const TypeInfo vfio_pci_dev_info = { · line 3567

Quoted 9 lines
hw/vfio/pci.c +1 -0
index 7f1532fbed..bfdf365978 100644
@@ -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("ramfb-romfile", VFIOPCIDevice, ramfb_romfile, true),
        DEFINE_PROP_STRING("rom-path", ...);

hw/vfio/pci.h struct VFIOPCIDevice { · line 180

Quoted 12 lines
hw/vfio/pci.c +0 -0
      DEFINE_PROP_ON_OFF_AUTO("x-ramfb-migrate", VFIOPCIDevice, ramfb_migrate,
                              ON_OFF_AUTO_AUTO),
  };
hw/vfio/pci.h +1 -0
index d94ecaba68..d567de8f10 100644
@@ -177,6 +177,7 @@ struct VFIOPCIDevice {
      bool no_kvm_ioeventfd;
      bool no_vfio_ioeventfd;
      bool enable_ramfb;
+    bool ramfb_romfile;
        char *rompath;

include/hw/display/ramfb.h line 9

Quoted 13 lines
hw/vfio/pci.h +0 -0
      OnOffAuto ramfb_migrate;
      bool defer_kvm_irq_routing;
      bool clear_parent_atomics_on_exit;
include/hw/display/ramfb.h +1 -1
index a7e0019144..172aa6dc89 100644
@@ -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);
  RAMFBState *ramfb_setup(char *rompath, Error **errp);
Quoted 3 lines
include/hw/display/ramfb.h +0 -0
  extern const VMStateDescription ramfb_vmstate;
 
#2 lore raw

Hi,

Quoted 6 lines
Quoted 3 lines

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.

Simpler to directly pass the ROM path instead of using a boolean, so board (or CLI) could pass path to non-x86 rom.

The rom is loaded into a fw_cfg file which only seabios will look at. So this rom logic is x86-specific.

edk2 ships an EFI driver for ramfb, that is how ramfb is used on !x86 platforms today, and I don't expect that to change.

IMHO a bool is perfectly fine here, I don't think we will ever need the flexibility to specify some other rom here.

take care,
Gerd

#3 lore raw
Quoted 6 lines · Gerd Hoffmann
   Hi,
Quoted 3 lines
Quoted 3 lines

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.

Quoted 8 lines
Quoted 2 lines

Simpler to directly pass the ROM path instead of using a boolean, so board (or CLI) could pass path to non-x86 rom.

The rom is loaded into a fw_cfg file which only seabios will look at. So this rom logic is x86-specific.

edk2 ships an EFI driver for ramfb, that is how ramfb is used on !x86 platforms today, and I don't expect that to change.

Should we also set the vfio-pci::ramfb-romfile property to false in a compat property for ARM machines then ? I don't know for RISC-V and PPC.

C.

Quoted 5 lines

IMHO a bool is perfectly fine here, I don't think we will ever need the flexibility to specify some other rom here.

Quoted 1 line

take care,

Gerd

#4 lore raw
Quoted 13 lines · Cédric Le Goater
Quoted 12 lines · Gerd Hoffmann
   Hi,
Quoted 6 lines
Quoted 3 lines

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.

Simpler to directly pass the ROM path instead of using a boolean, so board (or CLI) could pass path to non-x86 rom.

The rom is loaded into a fw_cfg file which only seabios will look at. So this rom logic is x86-specific.

Quoted 6 lines
Quoted 2 lines

edk2 ships an EFI driver for ramfb, that is how ramfb is used on !x86 platforms today, and I don't expect that to change.

Should we also set the vfio-pci::ramfb-romfile property to false in a compat property for ARM machines then ? I don't know for RISC-V and PPC.

Sounds like we'd be better setting the property to false by default, and then special case x86 machine types to set it to true.

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 :|
#5 lore raw

Hi Daniel,

Quoted 17 lines · Daniel P. Berrangé
Quoted 16 lines · Cédric Le Goater
Quoted 14 lines · Gerd Hoffmann
    Hi,
Quoted 6 lines
Quoted 3 lines

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.

Simpler to directly pass the ROM path instead of using a boolean, so board (or CLI) could pass path to non-x86 rom.

The rom is loaded into a fw_cfg file which only seabios will look at. So this rom logic is x86-specific.

edk2 ships an EFI driver for ramfb, that is how ramfb is used on !x86 platforms today, and I don't expect that to change.

Quoted 6 lines
Quoted 3 lines

Should we also set the vfio-pci::ramfb-romfile property to false in a compat property for ARM machines then ? I don't know for RISC-V and PPC.

Sounds like we'd be better setting the property to false by default, and then special case x86 machine types to set it to true.

I want to do that setting the property to false by default, and only the x86 machine types to set it to true.

But I didn't find the similar things on x86 with the arm_virt_compat[] in the hw/arm/virt.c which can set the compat global in one arch.

Thanks,
Shaoqin

Quoted 3 lines

With regards,
Daniel

Signature · 1 line
Shaoqin
#6 lore raw
In reply to Gerd Hoffmann
Quoted 9 lines · Gerd Hoffmann
   Hi,
Quoted 6 lines
Quoted 3 lines

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.

Simpler to directly pass the ROM path instead of using a boolean, so board (or CLI) could pass path to non-x86 rom.

Quoted 8 lines

The rom is loaded into a fw_cfg file which only seabios will look at. So this rom logic is x86-specific.

edk2 ships an EFI driver for ramfb, that is how ramfb is used on !x86 platforms today, and I don't expect that to change.

IMHO a bool is perfectly fine here, I don't think we will ever need the flexibility to specify some other rom here.

Understood, better then! Maybe name the boolean "use_legacy_x86_rom" and add a comment explaining EFI driver is expected on !x86?

Regards,

Phil.

#7 lore raw

Hi, guys

Thanks for all of your suggestions.

Quoted 13 lines · Philippe Mathieu-Daudé
Quoted 12 lines · Gerd Hoffmann

   Hi,

Quoted 6 lines
Quoted 3 lines

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.

Simpler to directly pass the ROM path instead of using a boolean, so board (or CLI) could pass path to non-x86 rom.

The rom is loaded into a fw_cfg file which only seabios will look at. So this rom logic is x86-specific.

Quoted 8 lines
Quoted 5 lines

edk2 ships an EFI driver for ramfb, that is how ramfb is used on !x86 platforms today, and I don't expect that to change.

IMHO a bool is perfectly fine here, I don't think we will ever need the flexibility to specify some other rom here.

Understood, better then! Maybe name the boolean "use_legacy_x86_rom" and add a comment explaining EFI driver is expected on !x86?

I think the "use_legacy_x86_rom" is good, I will change the name to it. And I will add a comment to explain it.

Thanks,
Shaoqin

Quoted 5 lines

Regards,

Phil.

Signature · 1 line
Shaoqin
#8 lore raw
Quoted 21 lines · Shaoqin Huang

Hi, guys

Thanks for all of your suggestions.

Quoted 16 lines · Philippe Mathieu-Daudé
Quoted 15 lines · Gerd Hoffmann

   Hi,

Quoted 6 lines
Quoted 3 lines

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.

Simpler to directly pass the ROM path instead of using a boolean, so board (or CLI) could pass path to non-x86 rom.

The rom is loaded into a fw_cfg file which only seabios will look at. So this rom logic is x86-specific.

edk2 ships an EFI driver for ramfb, that is how ramfb is used on !x86 platforms today, and I don't expect that to change.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

IMHO a bool is perfectly fine here, I don't think we will ever need the flexibility to specify some other rom here.

Understood, better then! Maybe name the boolean "use_legacy_x86_rom" and add a comment explaining EFI driver is expected on !x86?

I think the "use_legacy_x86_rom" is good, I will change the name to it. And I will add a comment to explain it.

Maybe even better could be to only register (expose) this property for x86 machines. We'll discuss that on your v2, no need to hold.

#9 lore raw
In reply to Shaoqin Huang
Quoted 127 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.

So add a new property ramfb-romfile 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
index 1be106b57f..2b96a49baa 100644
@@ -17,6 +17,7 @@ struct RAMFBStandaloneState {
      QemuConsole *con;
      RAMFBState *state;
      bool migrate;
+    bool ramfb_romfile;
  };
 
  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->ramfb_romfile, 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("ramfb-romfile", RAMFBStandaloneState, ramfb_romfile, true),
  };
 
  static void ramfb_class_initfn(ObjectClass *klass, void *data)
hw/display/ramfb-stubs.c +1 -1
index cf64733b10..b83551357b 100644
@@ -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
index 8c0f907673..9a17d97d07 100644
@@ -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
index ea87830fe0..56f10564f9 100644
@@ -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->ramfb_romfile, 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->ramfb_romfile, errp);
          if (!vdev->dpy->ramfb) {
              return false;
          }
hw/vfio/pci.c +1 -0
index 7f1532fbed..bfdf365978 100644
@@ -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("ramfb-romfile", VFIOPCIDevice, ramfb_romfile, true),
      DEFINE_PROP_ON_OFF_AUTO("x-ramfb-migrate", VFIOPCIDevice, ramfb_migrate,
                              ON_OFF_AUTO_AUTO),
  };
hw/vfio/pci.h +0 -0
index d94ecaba68..d567de8f10 100644

hw/vfio/pci.h struct VFIOPCIDevice { · line 180

Quoted 4 lines
hw/vfio/pci.h +1 -0
@@ -177,6 +177,7 @@ struct VFIOPCIDevice {
      bool no_kvm_ioeventfd;
      bool no_vfio_ioeventfd;
      bool enable_ramfb;
+    bool ramfb_romfile;

The attribute 'ramfb_romfile' sounds like a file name. Could you please add an 'enable' prefix or suffix.

Thanks,

C.

Quoted 16 lines
hw/vfio/pci.h +0 -0
      OnOffAuto ramfb_migrate;
      bool defer_kvm_irq_routing;
      bool clear_parent_atomics_on_exit;
include/hw/display/ramfb.h +1 -1
index a7e0019144..172aa6dc89 100644
@@ -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;