Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 766743 - app-emulation/qemu-5.2.0-r1 installs malformed firmware metadata
Summary: app-emulation/qemu-5.2.0-r1 installs malformed firmware metadata
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Matthias Maier
Depends on:
Reported: 2021-01-23 20:07 UTC by Jannik Glückert
Modified: 2021-01-31 14:49 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---

fix prefix in firmware descriptors (qemu-firmware-prefix.patch,556 bytes, patch)
2021-01-26 00:25 UTC, Jannik Glückert
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jannik Glückert 2021-01-23 20:07:38 UTC
Qemu installs firmware descriptors in /usr/share/qemu/firmware to be consumed by e.g. libvirt. These descriptors contain the path where to find the actual firmware

As of qemu-5.2.0-r1 - potentially earlier - this path is malformed. An excerpt from one of the files:

    "mapping": {
        "device": "flash",
        "executable": {
            "filename": "share/qemu/edk2-x86_64-secure-code.fd",
            "format": "raw"
        "nvram-template": {
            "filename": "share/qemu/edk2-i386-vars.fd",
            "format": "raw"

Which should instead be /usr/share/...
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2021-01-24 17:05:38 UTC
Do you want to propose a patch to the ebuild? Ideally in 'git am' form so I could just apply it. It should also illustrate the error clearer.
Comment 2 Jannik Glückert 2021-01-26 00:25:16 UTC
Created attachment 684681 [details, diff]
fix prefix in firmware descriptors

To clarify: this bug caused a regression in libvirt - libvirt was no longer able to create new UEFI VMs because the path to the firmware was malformed

After doing *some* debugging, it seems to come down to this:

in the descriptor files, meson fills out
      "filename": "@DATADIR@/edk2-x86_64-secure-code.fd"
during install. DATADIR is set to qemu_datadir, which in turn is set in the main to
      qemu_datadir = get_option('datadir') / get_option('qemu_suffix')

however, meson strips 'prefix' from 'datadir' - with prefix being /usr, and datadir being /usr/share, datadir gets stripped to share. The second next line, qemu_moddir, is also affected by this.

This seems like an oversight on qemus part, but I'd like someone more knowledgeable with meson to confirm my diagnosis before I report this upstream.

Attached is a patch that adds get_option('prefix') / ... to the DATADIR in the descriptor files - I did not want to "fix" qemu_datadir and qemu_moddir in the main, as their path gets used in various other parts - however I didn't notice any other regressions caused by lack of prefix there.
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2021-01-31 08:51:30 UTC
Aha, it's specifically about firmware/50-edk2-x86_64-secure.json and friends. 

Posting the contents of /usr/share/qemu/firmware/50-edk2-x86_64-secure.json for posterity:


$ fgrep filename 50-edk2-x86_64-secure.json
            "filename": "/usr/share/qemu/edk2-x86_64-secure-code.fd",
            "filename": "/usr/share/qemu/edk2-i386-vars.fd",


$ fgrep filename 50-edk2-x86_64-secure.json
            "filename": "share/qemu/edk2-x86_64-secure-code.fd",
            "filename": "share/qemu/edk2-i386-vars.fd",
Comment 4 Larry the Git Cow gentoo-dev 2021-01-31 09:38:03 UTC
The bug has been closed via the following commit(s):

commit 365cea28d6623c3d7a12623573147d8998cfb314
Author:     Sergei Trofimovich <>
AuthorDate: 2021-01-31 09:37:31 +0000
Commit:     Sergei Trofimovich <>
CommitDate: 2021-01-31 09:37:57 +0000

    app-emulation/qemu: fix firmware paths in json files
    Fixed-by: Jannik Glückert
    Package-Manager: Portage-3.0.14, Repoman-3.0.2
    Signed-off-by: Sergei Trofimovich <>

 .../qemu/files/qemu-5.2.0-fix-firmware-path.patch  |  16 +
 app-emulation/qemu/qemu-5.2.0-r2.ebuild            | 858 +++++++++++++++++++++
 2 files changed, 874 insertions(+)
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2021-01-31 14:05:44 UTC
(existing) upstream bug:
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2021-01-31 14:49:15 UTC
Proposed your fix upstream as