Date
1 - 1 of 1
How to pass load options to a QEMU UEFI guest via -fw_cfg.
Andrew Fish
Oh and Josh could you please file a BZ to document this, for the next person…
https://bugzilla.tianocore.org/
Thanks,
Andrew Fish
toggle quoted message
Show quoted text
https://bugzilla.tianocore.org/
Thanks,
Andrew Fish
On Dec 7, 2022, at 12:47 PM, Andrew Fish via groups.io <afish@...> wrote:
The other thing to look at is the history of that lib:
git log -- OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
But I still can’t find a reference for the bootorder file layout.
Thanks,
Andrew FishOn Dec 7, 2022, at 9:52 AM, Joshua Seaton <josh.a.seaton@... <mailto:josh.a.seaton@...>> wrote:
Alrighty - well thanks for the thought and time in any case.
As it turns out, I'm already familiar with the references you linked
(modulo being able to effectively read EDKII source - though I'm trying),
and my current research and experimentation have unfortunately hit a dead
end.
If something comes to mind later, more direct help out of my current hole
would be very appreciated.
Josh.
On Wed, Dec 7, 2022 at 9:46 AM Andrew Fish <afish@... <mailto:afish@...> <mailto:afish@...>> wrote:
On Dec 7, 2022, at 9:33 AM, Joshua Seaton <josh.a.seaton@... <mailto:josh.a.seaton@...>> wrote:
*oops: I do not believe that your references address my question, however.
I pointed to rules for constructing -fw_cfg options and I pointed to the
code in the edk2 that is processing the bootorder request. I also sent
reference on how boot order works in UEFI.
I don’t know the answer off the top of my head and I don’t have time to
research it. So I just dumped some context on how to get started
researching it.
For example from looking at [1] it looks like you pass a “bootoerder”
file.
So then I’d Google: QEMU fw_cfg bootorder
<https://www.google.com/search?client=safari&rls=en&q=QEMU+fw_cfg+bootorder&ie=UTF-8&oe=UTF-8&safari_group=9>
[1]
[image: edk2.png]
edk2/QemuBootOrderLib.c at master · tianocore/edk2
<https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c#L2172>
github.com <http://github.com/> <http://github.com/>
<https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c#L2172>
<https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c#L2172>
Thanks,
Andrew Fish
On Wed, Dec 7, 2022 at 9:23 AM Joshua Seaton <josh.a.seaton@... <mailto:josh.a.seaton@...> <mailto:josh.a.seaton@...>>
wrote:
Hi Andrew,
Thanks for the quick response. I do not believe that your references do
not address my question, however. If you feel that they do, could you
clarify how?
I am looking for how to specify load options on the QEMU command-line in
the case I gave above, and specifically how one might spell that with
"-fw_cfg" if possible.
Josh.
On Wed, Dec 7, 2022 at 9:18 AM Andrew Fish <afish@... <mailto:afish@...> <mailto:afish@...>> wrote:
Josh,
Here are generic fw_cfg rules:
QEMU fw cfg - OSDev Wiki <https://wiki.osdev.org/QEMU_fw_cfg>
wiki.osdev.org <http://wiki.osdev.org/> <http://wiki.osdev.org/> <https://wiki.osdev.org/QEMU_fw_cfg>
[image: favicon.ico] <https://wiki.osdev.org/QEMU_fw_cfg>
<https://wiki.osdev.org/QEMU_fw_cfg>
The edk2 code is:
[image: edk2.png]
edk2/QemuFwCfg.h at master · tianocore/edk2
<
https://github.com/tianocore/edk2/blob/master/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h
github.com <http://github.com/> <http://github.com/>
<
https://github.com/tianocore/edk2/blob/master/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h
<
https://github.com/tianocore/edk2/blob/master/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h
The edk2 code:
[image: edk2.png]
edk2/OvmfPkg/Library/QemuFwCfgLib at master · tianocore/edk2
<
https://github.com/tianocore/edk2/tree/master/OvmfPkg/Library/QemuFwCfgLib
github.com <http://github.com/> <http://github.com/>
<
https://github.com/tianocore/edk2/tree/master/OvmfPkg/Library/QemuFwCfgLib
<
https://github.com/tianocore/edk2/tree/master/OvmfPkg/Library/QemuFwCfgLib
[image: edk2.png]
edk2/QemuFwCfg.h at master · tianocore/edk2
<
https://github.com/tianocore/edk2/blob/master/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h
github.com <http://github.com/> <http://github.com/>
<
https://github.com/tianocore/edk2/blob/master/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h
<
https://github.com/tianocore/edk2/blob/master/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h
I think this code is consuming the boot order request:
[image: edk2.png]
edk2/QemuBootOrderLib.c at master · tianocore/edk2
<
https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
github.com <http://github.com/> <http://github.com/>
<
https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
<
https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
The rules around EFI NVRAM variable for boot policy are here:
3. Boot Manager — UEFI Specification 2.10 documentation
<https://uefi.org/specs/UEFI/2.10/03_Boot_Manager.html#>
uefi.org <http://uefi.org/> <http://uefi.org/> <https://uefi.org/specs/UEFI/2.10/03_Boot_Manager.html#>
[image: favicon.ico]
<https://uefi.org/specs/UEFI/2.10/03_Boot_Manager.html#>
<https://uefi.org/specs/UEFI/2.10/03_Boot_Manager.html#>
Thanks,
Andrew Fish
On Dec 7, 2022, at 8:31 AM, Joshua Seaton <josh.a.seaton@... <mailto:josh.a.seaton@...> <mailto:josh.a.seaton@...>>
wrote:
Hi all,
I am working on a project in which we are attempting to boot a non-Linux
QEMU guest through UEFI, for both x86-64 and arm64. This works fine,
except
for the fact that we are having difficulty figuring out how to specify
load
applications for our executed bootloader UEFI application.
Were we specifying `-kernel`, we would just use `-append`; however, we
currently are trying to operate by specifying a USB drive loaded with a
UEFI filesystem image on it instead (w/ `bootindex=0`), allowing us to
reuse that image for hardware cases as well. As a baseline with `-kernel`,
I've verified locally that `-append` does indeed result in the provided
string becoming the load option payload (modulo UTF-16 encoding).
Trying to read QEMU, OvmfPkg, and ArmVirtPkg source, as well as the OVMF
white paper , it seems clear that there should be some way to alternate
way
to spell "-append blah" with `-fw_cfg`, but it hasn't been clear to me
what
that spelling should be and how it can be made to work. Any pointers?
Does the fact that we are not having QEMU directly load the UEFI
application complicate the plumbing?
For reference, our QEMU command lines look like
```
qemu-system-x86_64 \
-drive if=pflash,format=raw,readonly=on,file=$EDK2_DIR/OVMF_CODE.fd \
-drive if=pflash,format=raw,snapshot=true,file=$EDK2_DIR/OVMF_VARS.fd \
-drive if=none,format=raw,file=$FILESYSTEM_IMAGE,id=uefi \
-device nec-usb-xhci,id=xhci0 \
-device usb-storage,bus=xhci0.0,removable=on,drive=uefi,bootindex=0 \
-m 8192 \
-device virtio-rng-pci \
-nographic \
-vga none \
-nic none \
-smp 4 \
-machine q35 \
-cpu Skylake-Client,-check \
-no-reboot
```
and
```
qemu-system-aarch64 \
-drive if=pflash,format=raw,readonly=on,file=$EDK2_DIR/QEMU_EFI.fd \
-drive if=pflash,format=raw,snapshot=true,file=$EDK2_DIR/QEMU_VARS.fd \
-drive if=none,format=raw,file=$FILESYSTEM_IMAGE,id=uefi \
-device nec-usb-xhci,id=xhci0 \
-device usb-storage,bus=xhci0.0,removable=on,drive=uefi,bootindex=0 \
-m 8192 \
-device virtio-rng-pci \
-nographic \
-vga none \
-nic none \
-smp 4 \
-machine virtualization=true \
-cpu max \
-machine virt-2.12,gic-version=max \
-no-reboot
```
Josh.
<favicon.ico><edk2.png><favicon.ico>
<edk2.png>