pc-bios/s390-ccw: Add "loadparm" and menu for pxelinux.cfg network booting
Re: [PATCH 1/5] pc-bios/s390-ccw: Allow to select a different pxelinux.cfg entry via loadparm
In reply to Thomas HuthQuoted 24 lines · Thomas Huth
From: Thomas Huth <[email protected]>
Since we're linking the network booting code into the main firmware binary nowadays, we can support the "loadparm" parameter now quite easily for pxelinux.cfg config files that contain multiple entries.
Signed-off-by Thomas Huth <[email protected]>--- pc-bios/s390-ccw/netmain.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-)pc-bios/s390-ccw/netmain.c +5
-0@@ -332,6 +332,28 @@ static int load_kernel_with_initrd(filename_ip_t *fn_ip,return rc; } +static int net_select_and_load_kernel (filename_ip_t *fn_ip, +int num_ent,int selected, +struct pl_cfg_entry *entries) +{ +unsigned int loadparm =get_loadparm_index ();
pc-bios/s390-ccw/netmain.c static int load_kernel_with_initrd(filename_ip_t *fn_ip, · line 349
Quoted 10 lines
pc-bios/s390-ccw/netmain.c +10
-0+ +if (num_ent <=0 ) { +return -1 ; + } + +if (loadparm > num_ent) { +printf ("Error: loadparm is set to entry #%d, but there are only " +"%d entries in the pxelinux.cfg file!\n" +"Using default entry now instead.\n" , + loadparm, num_ent);
Commit 64fa0de established that the IPL should abort on any loadparm misconfiguration, therefore I think this should result in a fatal error rather than using the default.
Quoted 36 lines
pc-bios/s390-ccw/netmain.c +10
-8+ }else if (loadparm >0 ) { + selected = loadparm -1 ; + } + +return load_kernel_with_initrd (fn_ip, &entries[selected]); +} +#define MAX_PXELINUX_ENTRIES 16static int net_try_pxelinux_cfg (filename_ip_t *fn_ip)@@ -343,11 +365,8 @@ static int net_try_pxelinux_cfg(filename_ip_t *fn_ip)DEFAULT_TFTP_RETRIES , cfgbuf,sizeof (cfgbuf), entries, MAX_PXELINUX_ENTRIES, &def_ent); -if (num_ent >0 ) { -return load_kernel_with_initrd (fn_ip, &entries[def_ent]); - } -return -1 ; +return net_select_and_load_kernel (fn_ip, num_ent, def_ent, entries); }/** @@ -433,10 +452,8 @@ static int net_try_direct_tftp_load(filename_ip_t *fn_ip) num_ent =pxelinux_parse_cfg (cfgbuf,sizeof (cfgbuf), entries,MAX_PXELINUX_ENTRIES , &def_ent); -if (num_ent <=0 ) { -return -1 ; - } -return load_kernel_with_initrd (fn_ip, &entries[def_ent]); +return net_select_and_load_kernel (fn_ip, num_ent, def_ent, + entries); } }
PATCH 3/5 pc-bios/s390-ccw: Make get_boot_index() from menu.c global
In reply to Thomas HuthFrom: Thomas Huth <[email protected]>
We are going to reuse this function for selecting an entry from the pxelinux.cfg menu, so rename this function with a "menu_" prefix and make it available globally.
--- pc-bios/s390-ccw/s390-ccw.h | 1 + pc-bios/s390-ccw/menu.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-)
pc-bios/s390-ccw/s390-ccw.h +1 -0
@@ -87,6 +87,7 @@ int menu_get_zipl_boot_index(const char *menu_data);bool menu_is_enabled_zipl (void );int menu_get_enum_boot_index (bool *valid_entries);bool menu_is_enabled_enum (void ); +int menu_get_boot_index (bool *valid_entries);#define MAX_BOOT_ENTRIES 31
pc-bios/s390-ccw/menu.c +3 -3
@@ -159,7 +159,7 @@ static void boot_menu_prompt(bool retry) } } -static int get_boot_index (bool *valid_entries) +int menu_get_boot_index (bool *valid_entries) {int boot_index;bool retry = false;
@@ -224,7 +224,7 @@ int menu_get_zipl_boot_index(const char *menu_data) }printf ("\n" ); -return get_boot_index (valid_entries); +return menu_get_boot_index (valid_entries); }int menu_get_enum_boot_index (bool *valid_entries)
@@ -247,7 +247,7 @@ int menu_get_enum_boot_index(bool *valid_entries) }printf ("\n" ); -return get_boot_index (valid_entries); +return menu_get_boot_index (valid_entries); }void menu_set_parms (uint8_t boot_menu_flag,uint32_t boot_menu_timeout)
Signature · 1 line
2.50.0
PATCH 1/5 pc-bios/s390-ccw: Allow to select a different pxelinux.cfg entry via loadparm
In reply to Thomas HuthFrom: Thomas Huth <[email protected]>
Since we're linking the network booting code into the main firmware binary nowadays, we can support the "loadparm" parameter now quite easily for pxelinux.cfg config files that contain multiple entries.
--- pc-bios/s390-ccw/netmain.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-)
pc-bios/s390-ccw/netmain.c +25 -8
@@ -332,6 +332,28 @@ static int load_kernel_with_initrd(filename_ip_t *fn_ip,return rc; } +static int net_select_and_load_kernel (filename_ip_t *fn_ip, +int num_ent,int selected, +struct pl_cfg_entry *entries) +{ +unsigned int loadparm =get_loadparm_index (); + +if (num_ent <=0 ) { +return -1 ; + } + +if (loadparm > num_ent) { +printf ("Error: loadparm is set to entry #%d, but there are only " +"%d entries in the pxelinux.cfg file!\n" +"Using default entry now instead.\n" , + loadparm, num_ent); + }else if (loadparm >0 ) { + selected = loadparm -1 ; + } + +return load_kernel_with_initrd (fn_ip, &entries[selected]); +} +#define MAX_PXELINUX_ENTRIES 16static int net_try_pxelinux_cfg (filename_ip_t *fn_ip)
@@ -343,11 +365,8 @@ static int net_try_pxelinux_cfg(filename_ip_t *fn_ip)DEFAULT_TFTP_RETRIES , cfgbuf,sizeof (cfgbuf), entries, MAX_PXELINUX_ENTRIES, &def_ent); -if (num_ent >0 ) { -return load_kernel_with_initrd (fn_ip, &entries[def_ent]); - } -return -1 ; +return net_select_and_load_kernel (fn_ip, num_ent, def_ent, entries); }/**
@@ -433,10 +452,8 @@ static int net_try_direct_tftp_load(filename_ip_t *fn_ip) num_ent =pxelinux_parse_cfg (cfgbuf,sizeof (cfgbuf), entries,MAX_PXELINUX_ENTRIES , &def_ent); -if (num_ent <=0 ) { -return -1 ; - } -return load_kernel_with_initrd (fn_ip, &entries[def_ent]); +return net_select_and_load_kernel (fn_ip, num_ent, def_ent, + entries); } }
Signature · 1 line
2.50.0
PATCH 2/5 pc-bios/s390-ccw: Allow up to 31 entries for pxelinux.cfg
In reply to Thomas HuthFrom: Thomas Huth <[email protected]>
We're going to support a menu for the pxelinux.cfg code, and to be able to reuse some functionality from menu.c, we should align the maximum amount of possible entries with the MAX_BOOT_ENTRIES constant that is used there. Thus replace MAX_PXELINUX_ENTRIES with MAX_BOOT_ENTRIES.
--- pc-bios/s390-ccw/netmain.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
pc-bios/s390-ccw/netmain.c +4 -6
@@ -354,17 +354,15 @@ static int net_select_and_load_kernel(filename_ip_t *fn_ip,return load_kernel_with_initrd (fn_ip, &entries[selected]); } -#define MAX_PXELINUX_ENTRIES 16 -static int net_try_pxelinux_cfg (filename_ip_t *fn_ip) { -struct pl_cfg_entry entries[MAX_PXELINUX_ENTRIES ]; +struct pl_cfg_entry entries[MAX_BOOT_ENTRIES ];int num_ent, def_ent =0 ; num_ent =pxelinux_load_parse_cfg (fn_ip, mac,get_uuid (),DEFAULT_TFTP_RETRIES , cfgbuf,sizeof (cfgbuf), - entries,MAX_PXELINUX_ENTRIES , &def_ent); + entries,MAX_BOOT_ENTRIES , &def_ent);return net_select_and_load_kernel (fn_ip, num_ent, def_ent, entries); }
@@ -447,11 +445,11 @@ static int net_try_direct_tftp_load(filename_ip_t *fn_ip)* a magic comment string. */ if (!strncasecmp ("# pxelinux" , cfgbuf,10 )) { -struct pl_cfg_entry entries[MAX_PXELINUX_ENTRIES ]; +struct pl_cfg_entry entries[MAX_BOOT_ENTRIES ];int num_ent, def_ent =0 ; num_ent =pxelinux_parse_cfg (cfgbuf,sizeof (cfgbuf), entries, -MAX_PXELINUX_ENTRIES , &def_ent); +MAX_BOOT_ENTRIES , &def_ent);return net_select_and_load_kernel (fn_ip, num_ent, def_ent, entries); }
Signature · 1 line
2.50.0
PATCH 5/5 tests/functional: Add a test for s390x pxelinux.cfg network booting
In reply to Thomas HuthFrom: Thomas Huth <[email protected]>
Check the various ways of booting a kernel via pxelinux.cfg file, e.g. by specifying the config file name via the MAC address or the UUID of the guest. Also check whether we can successfully load an alternate kernel via the "loadparm" parameter here and whether the boot menu shows up with "-boot menu=on".
--- MAINTAINERS | 1 + tests/functional/meson.build | 1 + tests/functional/test_s390x_pxelinux.py | 119 ++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100755 tests/functional/test_s390x_pxelinux.py
MAINTAINERS +1 -0
@@ -1805,6 +1805,7 @@ F: hw/s390x/ipl.* F: pc-bios/s390-ccw/ F: pc-bios/s390-ccw.img F: docs/devel/s390-dasd-ipl.rst +F: tests/functional/test_s390x_pxelinux.py T: git https://github.com/borntraeger/qemu.git s390-next L: [email protected]
tests/functional/meson.build +1 -0
@@ -281,6 +281,7 @@ tests_rx_system_thorough = [ tests_s390x_system_thorough = [ 's390x_ccw_virtio', + 's390x_pxelinux', 's390x_replay', 's390x_topology', 's390x_tuxrun',
tests/functional/test_s390x_pxelinux.py new file +119 -0
119 lines not on this page · raw message
Signature · 1 line
2.50.0
Re: [PATCH 1/5] pc-bios/s390-ccw: Allow to select a different pxelinux.cfg entry via loadparm
In reply to Jared RossiQuoted 29 lines · Jared Rossi
Quoted 26 lines · Thomas Huth
From: Thomas Huth <[email protected]>
Since we're linking the network booting code into the main firmware binary nowadays, we can support the "loadparm" parameter now quite easily for pxelinux.cfg config files that contain multiple entries.
Signed-off-by Thomas Huth <[email protected]>---
pc-bios/s390-ccw/netmain.c| 33 +++++++++++++++++++++++++--------1 file changed, 25 insertions(+), 8 deletions(-)pc-bios/s390-ccw/netmain.c +8
-0@@ -332,6 +332,28 @@ static int load_kernel_with_initrd(filename_ip_t *fn_ip, return rc; } +static int net_select_and_load_kernel (filename_ip_t *fn_ip, + int num_ent, int selected, + struct pl_cfg_entry *entries) +{ + unsigned int loadparm = get_loadparm_index(); + + if (num_ent <= 0) { + return -1;
Quoted 8 lines
pc-bios/s390-ccw/netmain.c static int load_kernel_with_initrd(filename_ip_t *fn_ip, · line 349
Quoted 7 lines
pc-bios/s390-ccw/netmain.c +7
-0+ } + + if (loadparm > num_ent) { + printf("Error: loadparm is set to entry #%d, but there are only " + "%d entries in the pxelinux.cfg file!\n" + "Using default entry now instead.\n", + loadparm, num_ent);Commit 64fa0de established that the IPL should abort on any loadparm misconfiguration, therefore I think this should result in a fatal error rather than using the default.
Ah, right, I already forgot that, thanks for the reminder! I'll change it in v2 accordingly.
Thomas
cover pc-bios/s390-ccw: Add "loadparm" and menu for pxelinux.cfg network booting
Since we're linking the network booting code into the main s390-ccw.img firmware binary nowadays, we can support the "loadparm" parameter now quite easily for pxelinux.cfg config files that contain multiple entries, and also add support for a simple boot menu here.
Thomas Huth (5):
pc-bios/s390-ccw: Allow to select a different pxelinux.cfg entry via
loadparm
pc-bios/s390-ccw: Allow up to 31 entries for pxelinux.cfg pc-bios/s390-ccw: Make get_boot_index() from menu.c global pc-bios/s390-ccw: Add a boot menu for booting via pxelinux.cfg tests/functional: Add a test for s390x pxelinux.cfg network booting
MAINTAINERS | 1 + pc-bios/s390-ccw/s390-ccw.h | 1 + pc-bios/s390-ccw/menu.c | 6 +- pc-bios/s390-ccw/netmain.c | 67 ++++++++++--- tests/functional/meson.build | 1 + tests/functional/test_s390x_pxelinux.py | 119 ++++++++++++++++++++++++ 6 files changed, 179 insertions(+), 16 deletions(-) create mode 100755 tests/functional/test_s390x_pxelinux.py
Signature · 1 line
2.50.0
PATCH 4/5 pc-bios/s390-ccw: Add a boot menu for booting via pxelinux.cfg
From: Thomas Huth <[email protected]>
Show a simple boot menu for pxelinux.cfg, too, if the user requested it.
--- pc-bios/s390-ccw/netmain.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
pc-bios/s390-ccw/netmain.c +26 -0
@@ -332,6 +332,28 @@ static int load_kernel_with_initrd(filename_ip_t *fn_ip,return rc; } +static int net_boot_menu (int num_ent,int def_ent, +struct pl_cfg_entry *entries) +{ +bool valid_entries[MAX_BOOT_ENTRIES ] = { false }; +int idx; + +puts ("\ns390-ccw pxelinux.cfg boot menu:\n" ); +printf (" [0] default (%d)\n" , def_ent +1 ); + valid_entries[0 ] = true; + +for (idx =1 ; idx <= num_ent; idx++) { +printf (" [%d] %s\n" , idx, entries[idx -1 ].label); + valid_entries[idx] = true; + } +putchar ('\n' ); + + idx =menu_get_boot_index (valid_entries); +putchar ('\n' ); + +return idx; +} +static int net_select_and_load_kernel (filename_ip_t *fn_ip,int num_ent,int selected,struct pl_cfg_entry *entries)
@@ -342,6 +364,10 @@ static int net_select_and_load_kernel(filename_ip_t *fn_ip,return -1 ; } +if (menu_is_enabled_enum () && num_ent >1 ) { + loadparm =net_boot_menu (num_ent, selected, entries); + } +if (loadparm > num_ent) {printf ("Error: loadparm is set to entry #%d, but there are only " "%d entries in the pxelinux.cfg file!\n"
Signature · 1 line
2.50.0