Skip to contentSkip to conversation

pc: Support firmware configuration with -blockdev (splitted)

RFC PATCH In review Philippe Mathieu-Daudé 3 participants 13 messages Mar 4, 2019 – Mar 7, 2019

lore
Share & tools
lore
#0 lore raw

cover pc: Support firmware configuration with -blockdev (splitted)

While reviewing Markus' series [*] I splitted the last patch (6/6) to understand it better.

[*] https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg06798.html

Based-on: <[email protected]>

Markus Armbruster (1):
pc: Support firmware configuration with -blockdev

Philippe Mathieu-Daudé (3):
pflash_cfi01: Add pflash_cfi01_get_blk() helper hw/i386/pc_sysfw: Remove obsolete PcSysFwDevice hw/i386/pc_sysfw: Let pc_system_firmware_init() access PCMachineState

 hw/block/pflash_cfi01.c  |   5 +
 hw/i386/pc.c             |   4 +-
 hw/i386/pc_sysfw.c       | 232 +++++++++++++++++++++++++--------------
 include/hw/block/flash.h |   1 +
 include/hw/i386/pc.h     |   6 +-
 5 files changed, 164 insertions(+), 84 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/4 pflash_cfi01: Add pflash_cfi01_get_blk() helper

Add an helper to access the opaque struct PFlashCFI01.

[PMD: Extracted from bigger patch]
---
 hw/block/pflash_cfi01.c  | 5 +++++
 include/hw/block/flash.h | 1 +
 2 files changed, 6 insertions(+)
hw/block/pflash_cfi01.c +5 -0
index 9d1c356eb6..9ecab693e8 100644
@@ -972,6 +972,11 @@ MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl)
     return &fl->mem;
 }
 
+BlockBackend *pflash_cfi01_get_blk(PFlashCFI01 *fl)
+{
+    return fl->blk;
+}
+
 static void postload_update_cb(void *opaque, int running, RunState state)
 {
     PFlashCFI01 *pfl = opaque;
include/hw/block/flash.h +1 -0
index 914932eaec..a0f488732a 100644
@@ -22,6 +22,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base,
                                    uint16_t id0, uint16_t id1,
                                    uint16_t id2, uint16_t id3,
                                    int be);
+BlockBackend *pflash_cfi01_get_blk(PFlashCFI01 *fl);
 MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl);
 
 /* pflash_cfi02.c */
Signature · 1 line
2.20.1
Reviewed-by on v1 1/4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/4] pflash_cfi01: Add pflash_cfi01_get_blk() helper

Quoted 32 lines · Philippe Mathieu-Daudé

Add an helper to access the opaque struct PFlashCFI01.

[PMD: Extracted from bigger patch]
---
 hw/block/pflash_cfi01.c  | 5 +++++
 include/hw/block/flash.h | 1 +
 2 files changed, 6 insertions(+)
hw/block/pflash_cfi01.c +5 -0
index 9d1c356eb6..9ecab693e8 100644
@@ -972,6 +972,11 @@ MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl)
     return &fl->mem;
 }
 
+BlockBackend *pflash_cfi01_get_blk(PFlashCFI01 *fl)
+{
+    return fl->blk;
+}
+
 static void postload_update_cb(void *opaque, int running, RunState state)
 {
     PFlashCFI01 *pfl = opaque;
include/hw/block/flash.h +0 -0
index 914932eaec..a0f488732a 100644

include/hw/block/flash.h PFlashCFI01 *pflash_cfi01_register(hwaddr base, · line 28

Quoted 7 lines
include/hw/block/flash.h +1 -0
@@ -22,6 +22,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base,
                                    uint16_t id0, uint16_t id1,
                                    uint16_t id2, uint16_t id3,
                                    int be);
+BlockBackend *pflash_cfi01_get_blk(PFlashCFI01 *fl);
 MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl);
 
 /* pflash_cfi02.c */

I generally prefer to keep the same order between declarations of functions, and definitions of the same functions. Compare pflash_cfi01_get_memory() here.

With that updated,

Thanks
Laszlo

#3 lore raw

Re: [Qemu-devel] [PATCH 1/4] pflash_cfi01: Add pflash_cfi01_get_blk() helper

Quoted 38 lines · Laszlo Ersek
Quoted 37 lines · Philippe Mathieu-Daudé

Add an helper to access the opaque struct PFlashCFI01.

[PMD: Extracted from bigger patch]
---
 hw/block/pflash_cfi01.c  | 5 +++++
 include/hw/block/flash.h | 1 +
 2 files changed, 6 insertions(+)
hw/block/pflash_cfi01.c +5 -0
index 9d1c356eb6..9ecab693e8 100644
@@ -972,6 +972,11 @@ MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl)
     return &fl->mem;
 }
 
+BlockBackend *pflash_cfi01_get_blk(PFlashCFI01 *fl)
+{
+    return fl->blk;
+}
+
 static void postload_update_cb(void *opaque, int running, RunState state)
 {
     PFlashCFI01 *pfl = opaque;
include/hw/block/flash.h +1 -0
index 914932eaec..a0f488732a 100644
@@ -22,6 +22,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base,
                                    uint16_t id0, uint16_t id1,
                                    uint16_t id2, uint16_t id3,
                                    int be);
+BlockBackend *pflash_cfi01_get_blk(PFlashCFI01 *fl);
 MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl);
 
Quoted 6 lines

include/hw/block/flash.h PFlashCFI01 *pflash_cfi01_register(hwaddr base, · line 28

Quoted 2 lines
include/hw/block/flash.h +0 -0
 /* pflash_cfi02.c */

I generally prefer to keep the same order between declarations of functions, and definitions of the same functions. Compare pflash_cfi01_get_memory() here.

My fault, not Philippe's.

Quoted 3 lines

With that updated,

Thanks!

#4 lore raw

PATCH 2/4 hw/i386/pc_sysfw: Remove obsolete PcSysFwDevice

In reply to Philippe Mathieu-Daudé

This structure is not used since 6dd2a5c98a.

---
 hw/i386/pc_sysfw.c | 5 -----
 1 file changed, 5 deletions(-)
hw/i386/pc_sysfw.c +0 -5
index 34727c5b1f..46b87afe23 100644
@@ -40,11 +40,6 @@
 
 #define BIOS_FILENAME "bios.bin"
 
-typedef struct PcSysFwDevice {
-    SysBusDevice busdev;
-    uint8_t isapc_ram_fw;
-} PcSysFwDevice;
-
 static void pc_isa_bios_init(MemoryRegion *rom_memory,
                              MemoryRegion *flash_mem,
                              int ram_size)
Signature · 1 line
2.20.1
Reviewed-by on v1 2/4
#5 lore raw

Re: [Qemu-devel] [PATCH 2/4] hw/i386/pc_sysfw: Remove obsolete PcSysFwDevice

Quoted 14 lines · Philippe Mathieu-Daudé

This structure is not used since 6dd2a5c98a.

---
 hw/i386/pc_sysfw.c | 5 -----
 1 file changed, 5 deletions(-)
hw/i386/pc_sysfw.c +0 -0
index 34727c5b1f..46b87afe23 100644
@@ -40,11 +40,6 @@
 

hw/i386/pc_sysfw.c line 45

Quoted 10 lines
hw/i386/pc_sysfw.c +0 -5
 #define BIOS_FILENAME "bios.bin"
 
-typedef struct PcSysFwDevice {
-    SysBusDevice busdev;
-    uint8_t isapc_ram_fw;
-} PcSysFwDevice;
-
 static void pc_isa_bios_init(MemoryRegion *rom_memory,
                              MemoryRegion *flash_mem,
                              int ram_size)

Looks sane, and the commit reference is precise.

Thanks
Laszlo

#6 lore raw

PATCH 3/4 hw/i386/pc_sysfw: Let pc_system_firmware_init() access PCMachineState

In reply to Philippe Mathieu-Daudé

PCMachineState will be used in the next patch. Since We can access PCMachineClass from it, directly use it. We can also access pcmc->pci_enabled, remove the isapc_ram_fw argument.

[PMD: Extracted from bigger patch]
---
 hw/i386/pc.c         | 2 +-
 hw/i386/pc_sysfw.c   | 8 +++++---
 include/hw/i386/pc.h | 3 +--
 3 files changed, 7 insertions(+), 6 deletions(-)
hw/i386/pc.c +1 -1
index 3889eccdc3..3cd8ed1794 100644
@@ -1830,7 +1830,7 @@ void pc_memory_init(PCMachineState *pcms,
     }
 
     /* Initialize PC system firmware */
-    pc_system_firmware_init(rom_memory, !pcmc->pci_enabled);
+    pc_system_firmware_init(pcms, rom_memory);
 
     option_rom_mr = g_malloc(sizeof(*option_rom_mr));
     memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE,
hw/i386/pc_sysfw.c +5 -3
index 46b87afe23..55a3c563df 100644
@@ -231,15 +231,17 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
                                 bios);
 }
 
-void pc_system_firmware_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
+void pc_system_firmware_init(PCMachineState *pcms,
+                             MemoryRegion *rom_memory)
 {
+    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
     DriveInfo *pflash_drv;
 
     pflash_drv = drive_get(IF_PFLASH, 0, 0);
 
-    if (isapc_ram_fw || pflash_drv == NULL) {
+    if (!pcmc->pci_enabled || pflash_drv == NULL) {
         /* When a pflash drive is not found, use rom-mode */
-        old_pc_system_rom_init(rom_memory, isapc_ram_fw);
+        old_pc_system_rom_init(rom_memory, true);
         return;
     }
 
include/hw/i386/pc.h +1 -2
index 3ff127ebd0..eb7360feac 100644
@@ -278,8 +278,7 @@ extern PCIDevice *piix4_dev;
 int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
 
 /* pc_sysfw.c */
-void pc_system_firmware_init(MemoryRegion *rom_memory,
-                             bool isapc_ram_fw);
+void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory);
 
 /* acpi-build.c */
 void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
Signature · 1 line
2.20.1
#7 lore raw

Re: [Qemu-devel] [PATCH 3/4] hw/i386/pc_sysfw: Let pc_system_firmware_init() access PCMachineState

Quoted 42 lines · Philippe Mathieu-Daudé

PCMachineState will be used in the next patch. Since We can access PCMachineClass from it, directly use it. We can also access pcmc->pci_enabled, remove the isapc_ram_fw argument.

[PMD: Extracted from bigger patch]
---
 hw/i386/pc.c         | 2 +-
 hw/i386/pc_sysfw.c   | 8 +++++---
 include/hw/i386/pc.h | 3 +--
 3 files changed, 7 insertions(+), 6 deletions(-)
hw/i386/pc.c +1 -1
index 3889eccdc3..3cd8ed1794 100644
@@ -1830,7 +1830,7 @@ void pc_memory_init(PCMachineState *pcms,
     }
 
     /* Initialize PC system firmware */
-    pc_system_firmware_init(rom_memory, !pcmc->pci_enabled);
+    pc_system_firmware_init(pcms, rom_memory);
 
     option_rom_mr = g_malloc(sizeof(*option_rom_mr));
     memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE,
hw/i386/pc_sysfw.c +3 -1
index 46b87afe23..55a3c563df 100644
@@ -231,15 +231,17 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
                                 bios);
 }
 
-void pc_system_firmware_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
+void pc_system_firmware_init(PCMachineState *pcms,
+                             MemoryRegion *rom_memory)
 {
+    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
     DriveInfo *pflash_drv;
 

hw/i386/pc_sysfw.c static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw) · line 247

Quoted 10 lines
hw/i386/pc_sysfw.c +2 -2
     pflash_drv = drive_get(IF_PFLASH, 0, 0);
 
-    if (isapc_ram_fw || pflash_drv == NULL) {
+    if (!pcmc->pci_enabled || pflash_drv == NULL) {
         /* When a pflash drive is not found, use rom-mode */
-        old_pc_system_rom_init(rom_memory, isapc_ram_fw);
+        old_pc_system_rom_init(rom_memory, true);
         return;
     }
 

This code extraction (as a pure refactoring) is incorrect.

In Markus's patch at
<https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg06804.html>,
the condition that guards the old_pc_system_rom_init() call loses one half of the disjunction:

- if (isapc_ram_fw || pflash_drv == NULL) {
+ if (!pcmc->pci_enabled) {

namely the "pflash_drv == NULL" sub-condition. Therefore the old_pc_system_rom_init() call can hardwire the second argument as "true":

- old_pc_system_rom_init(rom_memory, isapc_ram_fw);
+ old_pc_system_rom_init(rom_memory, true);

However, in this refactoring, the (pflash_drv == NULL) subcondition is not deleted; only the original condition is expressed differently. Therefore we can't replace the "isapc_ram_fw" argument of old_pc_system_rom_init() with plain "true", we have to use "!pcmc->pci_enabled" instead.

However, if we write down "!pcmc->pci_enabled" twice for this purpose, then it becomes too complex to read (for me anyway). So in that case I'd even suggest keeping the "isapc_ram_fw" local variable, just turn it into a normal local variable rather than take it as a parameter.

In the next patch, "isapc_ram_fw" can be killed just the same.

Thanks
Laszlo

Quoted 15 lines
include/hw/i386/pc.h +1 -2
index 3ff127ebd0..eb7360feac 100644
@@ -278,8 +278,7 @@ extern PCIDevice *piix4_dev;
 int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
 
 /* pc_sysfw.c */
-void pc_system_firmware_init(MemoryRegion *rom_memory,
-                             bool isapc_ram_fw);
+void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory);
 
 /* acpi-build.c */
 void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
#8 lore raw

Re: [Qemu-devel] [PATCH 3/4] hw/i386/pc_sysfw: Let pc_system_firmware_init() access PCMachineState

Quoted 70 lines · Laszlo Ersek
Quoted 42 lines · Philippe Mathieu-Daudé

PCMachineState will be used in the next patch. Since We can access PCMachineClass from it, directly use it. We can also access pcmc->pci_enabled, remove the isapc_ram_fw argument.

[PMD: Extracted from bigger patch]
---
 hw/i386/pc.c         | 2 +-
 hw/i386/pc_sysfw.c   | 8 +++++---
 include/hw/i386/pc.h | 3 +--
 3 files changed, 7 insertions(+), 6 deletions(-)
hw/i386/pc.c +1 -1
index 3889eccdc3..3cd8ed1794 100644
@@ -1830,7 +1830,7 @@ void pc_memory_init(PCMachineState *pcms,
     }
 
     /* Initialize PC system firmware */
-    pc_system_firmware_init(rom_memory, !pcmc->pci_enabled);
+    pc_system_firmware_init(pcms, rom_memory);
 
     option_rom_mr = g_malloc(sizeof(*option_rom_mr));
     memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE,
hw/i386/pc_sysfw.c +3 -1
index 46b87afe23..55a3c563df 100644
@@ -231,15 +231,17 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
                                 bios);
 }
 
-void pc_system_firmware_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
+void pc_system_firmware_init(PCMachineState *pcms,
+                             MemoryRegion *rom_memory)
 {
+    PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
     DriveInfo *pflash_drv;
 

hw/i386/pc_sysfw.c static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw) · line 247

Quoted 10 lines
hw/i386/pc_sysfw.c +2 -2
     pflash_drv = drive_get(IF_PFLASH, 0, 0);
 
-    if (isapc_ram_fw || pflash_drv == NULL) {
+    if (!pcmc->pci_enabled || pflash_drv == NULL) {
         /* When a pflash drive is not found, use rom-mode */
-        old_pc_system_rom_init(rom_memory, isapc_ram_fw);
+        old_pc_system_rom_init(rom_memory, true);
         return;
     }
 

This code extraction (as a pure refactoring) is incorrect.

In Markus's patch at
<https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg06804.html>,
the condition that guards the old_pc_system_rom_init() call loses one half of the disjunction:

(quoted diff) +1 -1
-    if (isapc_ram_fw || pflash_drv == NULL) {
+    if (!pcmc->pci_enabled) {

namely the "pflash_drv == NULL" sub-condition. Therefore the old_pc_system_rom_init() call can hardwire the second argument as "true":

hw/i386/pc_sysfw.c +1 -1
-        old_pc_system_rom_init(rom_memory, isapc_ram_fw);
+        old_pc_system_rom_init(rom_memory, true);
Quoted 5 lines

However, in this refactoring, the (pflash_drv == NULL) subcondition is not deleted; only the original condition is expressed differently. Therefore we can't replace the "isapc_ram_fw" argument of old_pc_system_rom_init() with plain "true", we have to use "!pcmc->pci_enabled" instead.

You're right

Quoted 6 lines

However, if we write down "!pcmc->pci_enabled" twice for this purpose, then it becomes too complex to read (for me anyway). So in that case I'd even suggest keeping the "isapc_ram_fw" local variable, just turn it into a normal local variable rather than take it as a parameter.

In the next patch, "isapc_ram_fw" can be killed just the same.

I'm doing that in my tree now. Thanks!

#9 lore raw

RFC PATCH 4/4 pc: Support firmware configuration with -blockdev

In reply to Philippe Mathieu-Daudé

From: Markus Armbruster <[email protected]>

The PC machines put firmware in ROM by default. To get it put into flash memory (required by OVMF), you have to use -drive if=pflash,unit=0,... and optionally -drive if=pflash,unit=1,...

Why two -drive? This permits setting up one part of the flash memory read-only, and the other part read/write. Below the hood, it creates two separate flash devices, because we were too lazy to improve our flash device models to support sector protection.

The problem at hand is to do the same with -blockdev somehow, as one more step towards deprecating -drive.

Mapping -drive if=none,... to -blockdev is a solved problem. With if=T other than if=none, -drive additionally configures a block device frontend. For non-onboard devices, that part maps to -device. Also a solved problem. For onboard devices such as PC flash memory, we have an unsolved problem.

This is actually an instance of a wider problem: our general device configuration interface doesn't cover onboard devices. Instead, we have a zoo of ad hoc interfaces that are much more limited. Some of them we'd rather deprecate (-drive, -net), but can't until we have suitable replacements.

Sadly, I can't attack the wider problem today. So back to the narrow problem.

My first idea was to reduce it to its solved buddy by using pluggable instead of onboard devices for the flash memory. Workable, but it requires some extra smarts in firmware descriptors and libvirt. Paolo had an idea that is simpler for libvirt: keep the devices onboard, and add machine properties for their block backends.

The implementation is less than straightforward, I'm afraid.

First, block backend properties are *qdev* properties. Machines can't have those, as they're not devices. I could duplicate these qdev properties as QOM properties, but I hate that.

More seriously, the properties do not belong to the machine, they belong to the onboard flash devices. Adding them to the machine would then require bad magic to somehow transfer them to the flash devices. Fortunately, QOM provides the means to handle exactly this case: add alias properties to the machine that forward to the onboard devices' properties.

Properties need to be created in .instance_init() methods. For PC machines, that's pc_machine_initfn(). To make alias properties work, we need to create the onboard flash devices there, too. Requires several bug fixes, in the previous commits. We also have to realize the devices. More on that below.

If the user sets pflash0, firmware resides in flash memory. pc_system_firmware_init() maps and realizes the flash devices.

Else, firmware resides in ROM. The onboard flash devices aren't used then. pc_system_firmware_init() destroys them unrealized, along with the alias properties. Except I can't figure out how to destroy the devices correctly. Marked FIXME.

The existing code to pick up drives defined with -drive if=pflash is replaced by code to desugar into the machine properties.

[PMD: rebased on 'pflash: Fixes and cleanups'

      replaced CFI_PFLASH01 -> PFLASH_CFI01]

---
I included the hack in pc_system_flash_cleanup_unused() from <[email protected]>:
https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg00759.html

 hw/i386/pc.c         |   2 +
 hw/i386/pc_sysfw.c   | 221 ++++++++++++++++++++++++++++---------------
 include/hw/i386/pc.h |   3 +
 3 files changed, 152 insertions(+), 74 deletions(-)
hw/i386/pc.c +2 -0
index 3cd8ed1794..420a0c5c9e 100644
@@ -2671,6 +2671,8 @@ static void pc_machine_initfn(Object *obj)
     pcms->smbus_enabled = true;
     pcms->sata_enabled = true;
     pcms->pit_enabled = true;
+
+    pc_system_flash_create(pcms);
 }
 
 static void pc_machine_reset(void)
hw/i386/pc_sysfw.c +147 -74

264 lines not on this page · raw message

include/hw/i386/pc.h +3 -0
index eb7360feac..266639ca8c 100644
@@ -6,6 +6,7 @@
 #include "hw/boards.h"
 #include "hw/isa/isa.h"
 #include "hw/block/fdc.h"
+#include "hw/block/flash.h"
 #include "net/net.h"
 #include "hw/i386/ioapic.h"
 
@@ -39,6 +40,7 @@ struct PCMachineState {
     PCIBus *bus;
     FWCfgState *fw_cfg;
     qemu_irq *gsi;
+    PFlashCFI01 *flash[2];
 
     /* Configuration options: */
     uint64_t max_ram_below_4g;
@@ -278,6 +280,7 @@ extern PCIDevice *piix4_dev;
 int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);
 
 /* pc_sysfw.c */
+void pc_system_flash_create(PCMachineState *pcms);
 void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory);
 
 /* acpi-build.c */
Signature · 1 line
2.20.1
#10 lore raw

Re: [Qemu-devel] [RFC PATCH 4/4] pc: Support firmware configuration with -blockdev

Hi Phil,

Quoted 2 lines · Philippe Mathieu-Daudé

[PMD: rebased on 'pflash: Fixes and cleanups'

      replaced CFI_PFLASH01 -> PFLASH_CFI01]

[...]

Quoted 6 lines
hw/i386/pc_sysfw.c +5 -1
-#define FLASH_MAP_UNIT_MAX 2
+static PFlashCFI01 *pc_pflash_create(const char *name)
+{
+    DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01);
+
+    qdev_prop_set_uint64(dev, "sector-length", 4096);

[...]

Quoted 13 lines
hw/i386/pc_sysfw.c +4 -5
-static void pc_system_flash_init(MemoryRegion *rom_memory)
+static void pc_system_flash_map(PCMachineState *pcms,
+                                MemoryRegion *rom_memory)
 {
-    int unit;
-    DriveInfo *pflash_drv;
+    hwaddr total_size = 0;
+    int i;
     BlockBackend *blk;
     int64_t size;
-    char *fatal_errmsg = NULL;
-    hwaddr phys_addr = 0x100000000ULL;
     uint32_t sector_size = 4096;

[...]

hw/i386/pc_sysfw.c static void pc_isa_bios_init(MemoryRegion *rom_memory, · line 175

Quoted 6 lines
hw/i386/pc_sysfw.c +6 -0
+        if (size == 0) {
+            error_report("system firmware block device %s is empty",
+                         blk_name(blk));
+            exit(1);
+        }
+        if (size == 0 || size % sector_size != 0) {

I think you missed my points (1) and (2), and Markus's followup, here:

https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg07018.html

Thanks
Laszlo

#11 lore raw

Re: [Qemu-devel] [RFC PATCH 4/4] pc: Support firmware configuration with -blockdev

Hi Laszlo!

Quoted 41 lines · Laszlo Ersek

Hi Phil,

Quoted 2 lines · Philippe Mathieu-Daudé

[PMD: rebased on 'pflash: Fixes and cleanups'

      replaced CFI_PFLASH01 -> PFLASH_CFI01]

[...]

Quoted 6 lines
hw/i386/pc_sysfw.c +5 -1
-#define FLASH_MAP_UNIT_MAX 2
+static PFlashCFI01 *pc_pflash_create(const char *name)
+{
+    DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01);
+
+    qdev_prop_set_uint64(dev, "sector-length", 4096);

[...]

Quoted 13 lines
hw/i386/pc_sysfw.c +4 -5
-static void pc_system_flash_init(MemoryRegion *rom_memory)
+static void pc_system_flash_map(PCMachineState *pcms,
+                                MemoryRegion *rom_memory)
 {
-    int unit;
-    DriveInfo *pflash_drv;
+    hwaddr total_size = 0;
+    int i;
     BlockBackend *blk;
     int64_t size;
-    char *fatal_errmsg = NULL;
-    hwaddr phys_addr = 0x100000000ULL;
     uint32_t sector_size = 4096;

[...]

hw/i386/pc_sysfw.c static void pc_isa_bios_init(MemoryRegion *rom_memory, · line 175

Quoted 6 lines
hw/i386/pc_sysfw.c +6 -0
+        if (size == 0) {
+            error_report("system firmware block device %s is empty",
+                         blk_name(blk));
+            exit(1);
+        }
+        if (size == 0 || size % sector_size != 0) {
Quoted 3 lines

I think you missed my points (1) and (2), and Markus's followup, here:

https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg07018.html

Actually I missed your whole mail...

I'll let Markus take what he likes from this 'splitting' series, and apply your comments on top if it :)

Markus: you can also drop patches 3/4 of this series if it makes your work harder.

Thanks both!

Phil.