[PATCH v2 4/5] pc-bios/s390-ccw: Add a boot menu for booting via pxelinux.cfg

Thomas Huth posted 5 patches 4 months, 1 week ago
Maintainers: Thomas Huth <thuth@redhat.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Jared Rossi <jrossi@linux.ibm.com>, Zhuoying Cai <zycai@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>
[PATCH v2 4/5] pc-bios/s390-ccw: Add a boot menu for booting via pxelinux.cfg
Posted by Thomas Huth 4 months, 1 week ago
From: Thomas Huth <thuth@redhat.com>

Show a simple boot menu for pxelinux.cfg, too, if the user requested it.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 pc-bios/s390-ccw/netmain.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
index 6f64323cd84..a9521dff416 100644
--- a/pc-bios/s390-ccw/netmain.c
+++ b/pc-bios/s390-ccw/netmain.c
@@ -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);
+    }
+
     IPL_assert(loadparm <= num_ent,
                "loadparm is set to an entry that is not available in the "
                "pxelinux.cfg file!");
-- 
2.50.0
Re: [PATCH v2 4/5] pc-bios/s390-ccw: Add a boot menu for booting via pxelinux.cfg
Posted by Jared Rossi 4 months, 1 week ago
Reviewed-by: Jared Rossi <jrossi@linux.ibm.com>

On 7/9/25 4:34 AM, Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
>
> Show a simple boot menu for pxelinux.cfg, too, if the user requested it.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   pc-bios/s390-ccw/netmain.c | 26 ++++++++++++++++++++++++++
>   1 file changed, 26 insertions(+)
>
> diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
> index 6f64323cd84..a9521dff416 100644
> --- a/pc-bios/s390-ccw/netmain.c
> +++ b/pc-bios/s390-ccw/netmain.c
> @@ -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);
> +    }
> +
>       IPL_assert(loadparm <= num_ent,
>                  "loadparm is set to an entry that is not available in the "
>                  "pxelinux.cfg file!");