OvmfPkg/GenericQemuLoadImageLib: fix cmdline + initrd handling

Commit 459f5ffa24ae ("OvmfPkg/QemuKernelLoaderFsDxe: rework direct
kernel boot filesystem") has a small change in behavior:  In case
there is no data the file is not created and attempts to open file
return EFI_NOT_FOUND.  Old behavior was to add a zero-length file
to the filesystem.

Fix GenericQemuLoadImageLib to handle EFI_NOT_FOUND correctly for
'initrd' and 'cmdline'.

Reported-by: Srikanth Aithal <sraithal@amd.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2025-01-24 14:36:32 +01:00 committed by mergify[bot]
parent b873e8b8e3
commit 1f19c3d6ee

View File

@ -294,8 +294,12 @@ QemuLoadKernelImage (
Status = GetQemuKernelLoaderBlobSize (Root, L"cmdline", &CommandLineSize); Status = GetQemuKernelLoaderBlobSize (Root, L"cmdline", &CommandLineSize);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND) {
CommandLineSize = 0;
} else {
goto CloseRoot; goto CloseRoot;
} }
}
if (CommandLineSize == 0) { if (CommandLineSize == 0) {
KernelLoadedImage->LoadOptionsSize = 0; KernelLoadedImage->LoadOptionsSize = 0;
@ -337,8 +341,12 @@ QemuLoadKernelImage (
Status = GetQemuKernelLoaderBlobSize (Root, L"initrd", &InitrdSize); Status = GetQemuKernelLoaderBlobSize (Root, L"initrd", &InitrdSize);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND) {
InitrdSize = 0;
} else {
goto FreeCommandLine; goto FreeCommandLine;
} }
}
if (InitrdSize > 0) { if (InitrdSize > 0) {
// //