From 1f19c3d6eecd1d2854073527720c78aae931fc77 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 24 Jan 2025 14:36:32 +0100 Subject: [PATCH] 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 Signed-off-by: Gerd Hoffmann --- .../GenericQemuLoadImageLib.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c index 9d0ba77755..4087093864 100644 --- a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c +++ b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c @@ -294,7 +294,11 @@ QemuLoadKernelImage ( Status = GetQemuKernelLoaderBlobSize (Root, L"cmdline", &CommandLineSize); if (EFI_ERROR (Status)) { - goto CloseRoot; + if (Status == EFI_NOT_FOUND) { + CommandLineSize = 0; + } else { + goto CloseRoot; + } } if (CommandLineSize == 0) { @@ -337,7 +341,11 @@ QemuLoadKernelImage ( Status = GetQemuKernelLoaderBlobSize (Root, L"initrd", &InitrdSize); if (EFI_ERROR (Status)) { - goto FreeCommandLine; + if (Status == EFI_NOT_FOUND) { + InitrdSize = 0; + } else { + goto FreeCommandLine; + } } if (InitrdSize > 0) {