From: Simon Glass <simon.glass@canonical.com>
Add a 'quiet' field to struct pxe_context to allow callers to suppress
the "Retrieving file" message when loading files. This is useful when
using the parser API to inspect labels without booting, where the
message would be noise.
Normal boot flows leave quiet as false (the default) so the message is
still printed. Parse-only callers can set ctx.quiet = true to suppress
it.
Update the PXE parser test to use quiet mode.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
boot/pxe_utils.c | 3 ++-
include/pxe_utils.h | 2 ++
test/boot/pxe.c | 12 ++++++------
3 files changed, 10 insertions(+), 7 deletions(-)
@@ -124,7 +124,8 @@ static int get_relfile(struct pxe_context *ctx, const char *file_path,
strcat(relfile, file_path);
- printf("Retrieving file: %s\n", relfile);
+ if (!ctx->quiet)
+ printf("Retrieving file: %s\n", relfile);
ret = ctx->getfile(ctx, relfile, addrp, align, type, &size);
if (ret < 0)
@@ -120,6 +120,7 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path,
* @use_fallback: TRUE : use "fallback" option as default, FALSE : use
* "default" option as default
* @no_boot: Stop show of actually booting and just return
+ * @quiet: Suppress "Retrieving file" messages when loading files
* @bflow: Bootflow being booted, or NULL if none (must be valid if @no_boot)
* @cfg: PXE menu (NULL if not yet probed)
*
@@ -157,6 +158,7 @@ struct pxe_context {
bool use_ipv6;
bool use_fallback;
bool no_boot;
+ bool quiet;
struct bootflow *bflow;
struct pxe_menu *cfg;
@@ -160,7 +160,8 @@ static int pxe_test_parse_norun(struct unit_test_state *uts)
ut_assertok(pxe_setup_ctx(&ctx, pxe_test_getfile, &info, true, cfg_path,
false, false, NULL));
- /* Read the config file into memory */
+ /* Read the config file into memory (quiet since we're just parsing) */
+ ctx.quiet = true;
ret = get_pxe_file(&ctx, cfg_path, addr);
ut_asserteq(1, ret); /* get_pxe_file returns 1 on success */
@@ -168,12 +169,11 @@ static int pxe_test_parse_norun(struct unit_test_state *uts)
cfg = parse_pxefile(&ctx, addr);
ut_assertnonnull(cfg);
- /* Verify 'say' keyword printed its message during parsing */
- ut_assert_nextline("Retrieving file: %s", cfg_path);
+ /*
+ * Verify 'say' keyword printed its message during parsing (quiet
+ * suppresses file messages)
+ */
ut_assert_nextline("Booting default Linux kernel");
- ut_assert_nextline("Retrieving file: /extlinux/extra.conf");
- for (i = 3; i <= 16; i++)
- ut_assert_nextline("Retrieving file: /extlinux/nest%d.conf", i);
ut_assert_console_end();
/* Verify menu properties */