Skip to contentSkip to conversation

x86-64/EFI: allow chaining of config files

PATCH In review Jan Beulich 2 participants 2 messages Sep 11, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86-64/EFI: allow chaining of config files

Namely when making use the CONFIG_XEN_COMPAT_* options in the legacy Linux kernels, newer kernels may not be compatible with older hypervisors, so trying to boot such a combination makes little sense. Booting older kernels on newer hypervisors, however, has to always work.

With the way xen.efi looks for its configuration file, allowing individual configuration files to refer only to compatible kernels, and referring from an older- to a newer-hypervisor one (the kernels of which will, as said, necessarily be compatible with the older hypervisor) allows to greatly reduce redundancy at least in development environments where one frequently wants multiple hypervisors and kernles to be installed in parallel.

docs/misc/efi.markdown +7 -0
@@ -75,6 +75,13 @@ Specifies an XSM module to load.
 
 Specifies a CPU microcode blob to load.
 
+###`chain=<filename>`
+
+Specifies an alternate configuration file to use in case the specified section
+(and in particular its `kernel=` setting) can't be found in the default (or
+specified) configuration file. This is only meaningful in the [global] section
+and really not meant to be used together with the `-cfg=` command line option.
+
 Filenames must be specified relative to the location of the EFI binary.
 
 Extra options to be passed to Xen can also be specified on the command line,
xen/arch/x86/efi/boot.c +20 -1
@@ -809,7 +809,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY
     else
         section.s = get_value(&cfg, "global", "default");
 
-    name.s = get_value(&cfg, section.s, "kernel");
+    for ( ; ; )
+    {
+        name.s = get_value(&cfg, section.s, "kernel");
+        if ( name.s )
+            break;
+        name.s = get_value(&cfg, "global", "chain");
+        if ( !name.s )
+            break;
+        efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size));
+        cfg.addr = 0;
+        if ( !read_file(dir_handle, s2w(&name), &cfg) )
+        {
+            PrintStr(L"Chained configuration file '");
+            PrintStr(name.w);
+            efi_bs->FreePool(name.w);
+            blexit(L"'not found\r\n");
+        }
+        pre_parse(&cfg);
+        efi_bs->FreePool(name.w);
+    }
     if ( !name.s )
         blexit(L"No Dom0 kernel image specified\r\n");
     split_value(name.s);

x86-64/EFI: allow chaining of config files

Namely when making use the CONFIG_XEN_COMPAT_* options in the legacy Linux kernels, newer kernels may not be compatible with older hypervisors, so trying to boot such a combination makes little sense. Booting older kernels on newer hypervisors, however, has to always work.

With the way xen.efi looks for its configuration file, allowing individual configuration files to refer only to compatible kernels, and referring from an older- to a newer-hypervisor one (the kernels of which will, as said, necessarily be compatible with the older hypervisor) allows to greatly reduce redundancy at least in development environments where one frequently wants multiple hypervisors and kernles to be installed in parallel.

docs/misc/efi.markdown +7 -0
@@ -75,6 +75,13 @@ Specifies an XSM module to load.
 
 Specifies a CPU microcode blob to load.
 
+###`chain=<filename>`
+
+Specifies an alternate configuration file to use in case the specified section
+(and in particular its `kernel=` setting) can't be found in the default (or
+specified) configuration file. This is only meaningful in the [global] section
+and really not meant to be used together with the `-cfg=` command line option.
+
 Filenames must be specified relative to the location of the EFI binary.
 
 Extra options to be passed to Xen can also be specified on the command line,
xen/arch/x86/efi/boot.c +20 -1
@@ -809,7 +809,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY
     else
         section.s = get_value(&cfg, "global", "default");
 
-    name.s = get_value(&cfg, section.s, "kernel");
+    for ( ; ; )
+    {
+        name.s = get_value(&cfg, section.s, "kernel");
+        if ( name.s )
+            break;
+        name.s = get_value(&cfg, "global", "chain");
+        if ( !name.s )
+            break;
+        efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size));
+        cfg.addr = 0;
+        if ( !read_file(dir_handle, s2w(&name), &cfg) )
+        {
+            PrintStr(L"Chained configuration file '");
+            PrintStr(name.w);
+            efi_bs->FreePool(name.w);
+            blexit(L"'not found\r\n");
+        }
+        pre_parse(&cfg);
+        efi_bs->FreePool(name.w);
+    }
     if ( !name.s )
         blexit(L"No Dom0 kernel image specified\r\n");
     split_value(name.s);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Jan Beulich

Namely when making use the CONFIG_XEN_COMPAT_* options in the legacy Linux kernels, newer kernels may not be compatible with older hypervisors, so trying to boot such a combination makes little sense. Booting older kernels on newer hypervisors, however, has to always work.

With the way xen.efi looks for its configuration file, allowing individual configuration files to refer only to compatible kernels, and referring from an older- to a newer-hypervisor one (the kernels of which will, as said, necessarily be compatible with the older hypervisor) allows to greatly reduce redundancy at least in development environments where one frequently wants multiple hypervisors and kernles to be installed in parallel.

Quoted 1 line
Quoted 56 lines
docs/misc/efi.markdown +3 -0
@@ -75,6 +75,13 @@ Specifies an XSM module to load.
 
 Specifies a CPU microcode blob to load.
 
+###`chain=<filename>`
+
+Specifies an alternate configuration file to use in case the specified

section

docs/misc/efi.markdown +2 -0
+(and in particular its `kernel=` setting) can't be found in the default (or
+specified) configuration file. This is only meaningful in the [global]

section
+and really not meant to be used together with the -cfg= command line option.

docs/misc/efi.markdown +1 -0
+
 Filenames must be specified relative to the location of the EFI binary.
 
 Extra options to be passed to Xen can also be specified on the command line,
xen/arch/x86/efi/boot.c +20 -1
@@ -809,7 +809,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY
     else
         section.s = get_value(&cfg, "global", "default");
 
-    name.s = get_value(&cfg, section.s, "kernel");
+    for ( ; ; )
+    {
+        name.s = get_value(&cfg, section.s, "kernel");
+        if ( name.s )
+            break;
+        name.s = get_value(&cfg, "global", "chain");
+        if ( !name.s )
+            break;
+        efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size));
+        cfg.addr = 0;
+        if ( !read_file(dir_handle, s2w(&name), &cfg) )
+        {
+            PrintStr(L"Chained configuration file '");
+            PrintStr(name.w);
+            efi_bs->FreePool(name.w);
+            blexit(L"'not found\r\n");
+        }
+        pre_parse(&cfg);
+        efi_bs->FreePool(name.w);
+    }
     if ( !name.s )
         blexit(L"No Dom0 kernel image specified\r\n");
     split_value(name.s);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel