pc-bios/meson: split blobs by available targets
RFC PATCH 1/1 pc-bios/meson: split blobs by available targets
While building some kvm-unit-tests inside a buildroot environment I noticed the QEMU installer installs all blobs regardless of the enabled targets. Buildroot images typically try and keep filesystem and thin as possible we probably should skip blobs that will never be used.
We could also go further and refer to enabled devices to further filter out things like option roms.
--- pc-bios/meson.build | 202 ++++++++++++++++++++++++++++---------------- 1 file changed, 129 insertions(+), 73 deletions(-)
pc-bios/meson.build +129 -73
@@ -1,19 +1,36 @@ roms = [] if unpack_edk2_blobs - fds = [ - 'edk2-aarch64-code.fd', - 'edk2-arm-code.fd', - 'edk2-arm-vars.fd', - 'edk2-riscv-code.fd', - 'edk2-riscv-vars.fd', - 'edk2-i386-code.fd', - 'edk2-i386-secure-code.fd', - 'edk2-i386-vars.fd', - 'edk2-x86_64-code.fd', - 'edk2-x86_64-secure-code.fd', - 'edk2-loongarch64-code.fd', - 'edk2-loongarch64-vars.fd', - ] + + fds = [] + if 'aarch64-softmmu' in target_dirs + fds += [ 'edk2-aarch64-code.fd' ] + endif + + if 'arm-softmmu' in target_dirs or 'aarch64-softmmu' in target_dirs + fds += [ 'edk2-arm-code.fd', + 'edk2-arm-vars.fd' ] + endif + + if 'riscv64-softmmu' in target_dirs + fds += [ 'edk2-riscv-code.fd', + 'edk2-riscv-vars.fd' ] + endif + + if 'i386-softmmu' in target_dirs + fds += [ 'edk2-i386-code.fd', + 'edk2-i386-secure-code.fd', + 'edk2-i386-vars.fd' ] + endif + + if 'x86_64-softmmu' in target_dirs + fds += [ 'edk2-x86_64-code.fd', + 'edk2-x86_64-secure-code.fd' ] + endif + + if 'loongarch64' in target_dirs + fds += [ 'edk2-loongarch64-code.fd', + 'edk2-loongarch64-vars.fd' ] + endif foreach f : fds roms += custom_target(f,
@@ -27,65 +44,104 @@ if unpack_edk2_blobs endforeach endif -blobs = [ - 'ast27x0_bootrom.bin', - 'bios.bin', - 'bios-256k.bin', - 'bios-microvm.bin', - 'qboot.rom', - 'vgabios.bin', - 'vgabios-cirrus.bin', - 'vgabios-stdvga.bin', - 'vgabios-vmware.bin', - 'vgabios-qxl.bin', - 'vgabios-virtio.bin', - 'vgabios-ramfb.bin', - 'vgabios-bochs-display.bin', - 'vgabios-ati.bin', - 'openbios-sparc32', - 'openbios-sparc64', - 'openbios-ppc', - 'QEMU,tcx.bin', - 'QEMU,cgthree.bin', - 'pxe-e1000.rom', - 'pxe-eepro100.rom', - 'pxe-ne2k_pci.rom', - 'pxe-pcnet.rom', - 'pxe-rtl8139.rom', - 'pxe-virtio.rom', - 'efi-e1000.rom', - 'efi-eepro100.rom', - 'efi-ne2k_pci.rom', - 'efi-pcnet.rom', - 'efi-rtl8139.rom', - 'efi-virtio.rom', - 'efi-e1000e.rom', - 'efi-vmxnet3.rom', - 'qemu-nsis.bmp', - 'multiboot.bin', - 'multiboot_dma.bin', - 'linuxboot.bin', - 'linuxboot_dma.bin', - 'kvmvapic.bin', - 'pvh.bin', - 's390-ccw.img', - 'slof.bin', - 'skiboot.lid', - 'pnv-pnor.bin', - 'palcode-clipper', - 'u-boot.e500', - 'u-boot-sam460-20100605.bin', - 'qemu_vga.ndrv', - 'edk2-licenses.txt', - 'hppa-firmware.img', - 'hppa-firmware64.img', - 'opensbi-riscv32-generic-fw_dynamic.bin', - 'opensbi-riscv64-generic-fw_dynamic.bin', - 'npcm7xx_bootrom.bin', - 'npcm8xx_bootrom.bin', - 'vof.bin', - 'vof-nvram.bin', -] +blobs = [] + +if 'aarch64-softmmu' in target_dirs + blobs += [ 'ast27x0_bootrom.bin', + 'npcm7xx_bootrom.bin', + 'npcm8xx_bootrom.bin' ] +endif + +# Most x86 blobs start in real mode anyway, need to check which blobs +# are x86_64 only. Also we could limit the option roms based on the +# build config. +if 'x86_64-softmmu' in target_dirs or 'i386-softmmu' in target_dirs + blobs += [ 'bios.bin', + 'bios-256k.bin', + 'bios-microvm.bin', + 'qboot.rom', + 'vgabios.bin', + 'vgabios-cirrus.bin', + 'vgabios-stdvga.bin', + 'vgabios-vmware.bin', + 'vgabios-qxl.bin', + 'vgabios-virtio.bin', + 'vgabios-ramfb.bin', + 'vgabios-bochs-display.bin', + 'vgabios-ati.bin', + 'pxe-e1000.rom', + 'pxe-eepro100.rom', + 'pxe-ne2k_pci.rom', + 'pxe-pcnet.rom', + 'pxe-rtl8139.rom', + 'pxe-virtio.rom', + 'efi-e1000.rom', + 'efi-eepro100.rom', + 'efi-ne2k_pci.rom', + 'efi-pcnet.rom', + 'efi-rtl8139.rom', + 'efi-virtio.rom', + 'efi-e1000e.rom', + 'efi-vmxnet3.rom', + 'multiboot.bin', + 'multiboot_dma.bin', + 'linuxboot.bin', + 'linuxboot_dma.bin', + 'kvmvapic.bin', + 'pvh.bin' ] +endif + +if 'sparc32-softmmu' in target_dirs + blobs += [ 'openbios-sparc32', + 'QEMU,tcx.bin', + 'QEMU,cgthree.bin' ] +endif + +if 'sparc64-softmmu' in target_dirs + blobs += [ 'openbios-sparc64' ] +endif + +if 'ppc64-softmmu' in target_dirs + blobs += [ 'openbios-ppc', + 'slof.bin', + 'skiboot.lid', + 'pnv-pnor.bin', + 'u-boot.e500', + 'u-boot-sam460-20100605.bin', + 'vof.bin', + 'vof-nvram.bin' ] +endif + +if 'ppc32-softmmu' in target_dirs + blobs += [ 'qemu_vga.ndrv' ] +endif + +if host_os == 'windows' + blobs += [ 'qemu-nsis.bmp' ] +endif + +if 's390x-softmmu' in target_dirs + blobs += [ 's390-ccw.img' ] +endif + +if 'alpha-softmmu' in target_dirs + blobs += [ 'palcode-clipper' ] +endif + +if 'hppa-softmmu' in target_dirs + blobs += [ 'hppa-firmware.img', + 'hppa-firmware64.img' ] +endif + +if 'riscv32-softmmu' in target_dirs + blobs += [ 'opensbi-riscv32-generic-fw_dynamic.bin' ] +endif + +if 'riscv64-softmmu' in target_dirs + blobs += [ 'opensbi-riscv64-generic-fw_dynamic.bin' ] +endif + +blobs += [ 'edk2-licenses.txt' ] if get_option('install_blobs') install_data(blobs, install_dir: qemu_datadir, install_mode: 'rw-r--r--')
Signature · 1 line
2.47.2
Quoted 40 lines · Alex Bennée
While building some kvm-unit-tests inside a buildroot environment I noticed the QEMU installer installs all blobs regardless of the enabled targets. Buildroot images typically try and keep filesystem and thin as possible we probably should skip blobs that will never be used.
We could also go further and refer to enabled devices to further filter out things like option roms.
Signed-off-by Alex Bennée <[email protected]>--- pc-bios/meson.build | 202 ++++++++++++++++++++++++++++---------------- 1 file changed, 129 insertions(+), 73 deletions(-)pc-bios/meson.build +5
-14@@ -1,19 +1,36 @@ roms = [] if unpack_edk2_blobs - fds = [ - 'edk2-aarch64-code.fd', - 'edk2-arm-code.fd', - 'edk2-arm-vars.fd', - 'edk2-riscv-code.fd', - 'edk2-riscv-vars.fd', - 'edk2-i386-code.fd', - 'edk2-i386-secure-code.fd', - 'edk2-i386-vars.fd', - 'edk2-x86_64-code.fd', - 'edk2-x86_64-secure-code.fd', - 'edk2-loongarch64-code.fd', - 'edk2-loongarch64-vars.fd', - ] + + fds = [] + if 'aarch64-softmmu' in target_dirs + fds += [ 'edk2-aarch64-code.fd' ] + endif
pc-bios/meson.build line 17
Quoted 10 lines
pc-bios/meson.build +10
-0+ + if 'arm-softmmu' in target_dirs or 'aarch64-softmmu' in target_dirs + fds += [ 'edk2-arm-code.fd', + 'edk2-arm-vars.fd' ] + endif + + if 'riscv64-softmmu' in target_dirs + fds += [ 'edk2-riscv-code.fd', + 'edk2-riscv-vars.fd' ] + endif
Given the repeated code pattern, how about making it a bit more metadata driven. eg something approx like
fdmap = {
'edk2-aarch64-code.fd': ["aarch64"],
'edk2-arm-code.fd': ["aarch64", "arm],
'edk2-arm-vars.fd',: ["aarch64", "arm"],
'edk2-riscv-code.fd': ["riscv64"],
'edk2-riscv-vars.fd': ["riscv64"],
....
}fds = []
foreach fd, targets: fdmap
want = false
foreach target: targets
if target + "-softmmu" in target_dirs
want = true
endif
endforeach
if want
fds += fd
endif
endforeach
pc-bios/meson.build line 23
Quoted 5 lines
pc-bios/meson.build +5
-0+ if 'i386-softmmu' in target_dirs + fds += [ 'edk2-i386-code.fd', + 'edk2-i386-secure-code.fd', + 'edk2-i386-vars.fd' ] + endif
I guess technically these could be used together with the x86_64 target too, as you've done with arm 32-bit edk ?
Quoted 181 lines
pc-bios/meson.build +108
-59+ + if 'x86_64-softmmu' in target_dirs + fds += [ 'edk2-x86_64-code.fd', + 'edk2-x86_64-secure-code.fd' ] + endif + + if 'loongarch64' in target_dirs + fds += [ 'edk2-loongarch64-code.fd', + 'edk2-loongarch64-vars.fd' ] + endif foreach f : fds roms += custom_target(f,@@ -27,65 +44,104 @@ if unpack_edk2_blobs endforeach endif -blobs = [ - 'ast27x0_bootrom.bin', - 'bios.bin', - 'bios-256k.bin', - 'bios-microvm.bin', - 'qboot.rom', - 'vgabios.bin', - 'vgabios-cirrus.bin', - 'vgabios-stdvga.bin', - 'vgabios-vmware.bin', - 'vgabios-qxl.bin', - 'vgabios-virtio.bin', - 'vgabios-ramfb.bin', - 'vgabios-bochs-display.bin', - 'vgabios-ati.bin', - 'openbios-sparc32', - 'openbios-sparc64', - 'openbios-ppc', - 'QEMU,tcx.bin', - 'QEMU,cgthree.bin', - 'pxe-e1000.rom', - 'pxe-eepro100.rom', - 'pxe-ne2k_pci.rom', - 'pxe-pcnet.rom', - 'pxe-rtl8139.rom', - 'pxe-virtio.rom', - 'efi-e1000.rom', - 'efi-eepro100.rom', - 'efi-ne2k_pci.rom', - 'efi-pcnet.rom', - 'efi-rtl8139.rom', - 'efi-virtio.rom', - 'efi-e1000e.rom', - 'efi-vmxnet3.rom', - 'qemu-nsis.bmp', - 'multiboot.bin', - 'multiboot_dma.bin', - 'linuxboot.bin', - 'linuxboot_dma.bin', - 'kvmvapic.bin', - 'pvh.bin', - 's390-ccw.img', - 'slof.bin', - 'skiboot.lid', - 'pnv-pnor.bin', - 'palcode-clipper', - 'u-boot.e500', - 'u-boot-sam460-20100605.bin', - 'qemu_vga.ndrv', - 'edk2-licenses.txt', - 'hppa-firmware.img', - 'hppa-firmware64.img', - 'opensbi-riscv32-generic-fw_dynamic.bin', - 'opensbi-riscv64-generic-fw_dynamic.bin', - 'npcm7xx_bootrom.bin', - 'npcm8xx_bootrom.bin', - 'vof.bin', - 'vof-nvram.bin', -] +blobs = [] + +if 'aarch64-softmmu' in target_dirs + blobs += [ 'ast27x0_bootrom.bin', + 'npcm7xx_bootrom.bin', + 'npcm8xx_bootrom.bin' ] +endif + +# Most x86 blobs start in real mode anyway, need to check which blobs +# are x86_64 only. Also we could limit the option roms based on the +# build config. +if 'x86_64-softmmu' in target_dirs or 'i386-softmmu' in target_dirs + blobs += [ 'bios.bin', + 'bios-256k.bin', + 'bios-microvm.bin', + 'qboot.rom', + 'vgabios.bin', + 'vgabios-cirrus.bin', + 'vgabios-stdvga.bin', + 'vgabios-vmware.bin', + 'vgabios-qxl.bin', + 'vgabios-virtio.bin', + 'vgabios-ramfb.bin', + 'vgabios-bochs-display.bin', + 'vgabios-ati.bin', + 'pxe-e1000.rom', + 'pxe-eepro100.rom', + 'pxe-ne2k_pci.rom', + 'pxe-pcnet.rom', + 'pxe-rtl8139.rom', + 'pxe-virtio.rom', + 'efi-e1000.rom', + 'efi-eepro100.rom', + 'efi-ne2k_pci.rom', + 'efi-pcnet.rom', + 'efi-rtl8139.rom', + 'efi-virtio.rom', + 'efi-e1000e.rom', + 'efi-vmxnet3.rom', + 'multiboot.bin', + 'multiboot_dma.bin', + 'linuxboot.bin', + 'linuxboot_dma.bin', + 'kvmvapic.bin', + 'pvh.bin' ] +endif + +if 'sparc32-softmmu' in target_dirs + blobs += [ 'openbios-sparc32', + 'QEMU,tcx.bin', + 'QEMU,cgthree.bin' ] +endif + +if 'sparc64-softmmu' in target_dirs + blobs += [ 'openbios-sparc64' ] +endif + +if 'ppc64-softmmu' in target_dirs + blobs += [ 'openbios-ppc', + 'slof.bin', + 'skiboot.lid', + 'pnv-pnor.bin', + 'u-boot.e500', + 'u-boot-sam460-20100605.bin', + 'vof.bin', + 'vof-nvram.bin' ] +endif + +if 'ppc32-softmmu' in target_dirs + blobs += [ 'qemu_vga.ndrv' ] +endif + +if host_os == 'windows' + blobs += [ 'qemu-nsis.bmp' ] +endif + +if 's390x-softmmu' in target_dirs + blobs += [ 's390-ccw.img' ] +endif + +if 'alpha-softmmu' in target_dirs + blobs += [ 'palcode-clipper' ] +endif + +if 'hppa-softmmu' in target_dirs + blobs += [ 'hppa-firmware.img', + 'hppa-firmware64.img' ] +endif + +if 'riscv32-softmmu' in target_dirs + blobs += [ 'opensbi-riscv32-generic-fw_dynamic.bin' ] +endif + +if 'riscv64-softmmu' in target_dirs + blobs += [ 'opensbi-riscv64-generic-fw_dynamic.bin' ] +endif + +blobs += [ 'edk2-licenses.txt' ] if get_option('install_blobs') install_data(blobs, install_dir: qemu_datadir, install_mode: 'rw-r--r--')Signature · 1 line
2.47.2
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 :|