2024-10-18 15:48:08 +02:00
|
|
|
Index: xen-4.19.0-testing/tools/pygrub/src/pygrub
|
2024-05-04 02:04:11 +02:00
|
|
|
===================================================================
|
2024-10-18 15:48:08 +02:00
|
|
|
--- xen-4.19.0-testing.orig/tools/pygrub/src/pygrub
|
|
|
|
+++ xen-4.19.0-testing/tools/pygrub/src/pygrub
|
|
|
|
@@ -593,7 +593,7 @@ class Grub:
|
2024-05-04 02:04:11 +02:00
|
|
|
self.cf.filename = f
|
|
|
|
break
|
|
|
|
if self.__dict__.get('cf', None) is None:
|
|
|
|
- raise RuntimeError("couldn't find bootloader config file in the image provided.")
|
|
|
|
+ return
|
|
|
|
f = fs.open_file(self.cf.filename)
|
|
|
|
# limit read size to avoid pathological cases
|
|
|
|
buf = f.read(FS_READ_MAX)
|
2024-10-18 15:48:08 +02:00
|
|
|
@@ -768,6 +768,20 @@ def run_grub(file, entry, fs, cfg_args):
|
2024-05-04 02:04:11 +02:00
|
|
|
|
|
|
|
g = Grub(file, fs)
|
|
|
|
|
|
|
|
+ # If missing config or grub has no menu entries to select, look for
|
|
|
|
+ # vmlinuz-xen and initrd-xen in /boot
|
|
|
|
+ if g.__dict__.get('cf', None) is None or len(g.cf.images) == 0 or re.search(r"xen(-pae)?\.gz",g.cf.images[0].kernel[1]):
|
|
|
|
+ if not list_entries:
|
|
|
|
+ chosencfg = { "kernel": None, "ramdisk": None, "args": "" }
|
|
|
|
+ chosencfg = sniff_xen_kernel(fs, incfg)
|
|
|
|
+ if chosencfg["kernel"] and chosencfg["ramdisk"]:
|
|
|
|
+ chosencfg["args"] = cfg_args
|
|
|
|
+ return chosencfg
|
|
|
|
+ if g.__dict__.get('cf', None) is None:
|
|
|
|
+ raise RuntimeError("couldn't find bootloader config file in the image provided.")
|
|
|
|
+ else:
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
if list_entries:
|
|
|
|
for i in range(len(g.cf.images)):
|
|
|
|
img = g.cf.images[i]
|
2024-10-18 15:48:08 +02:00
|
|
|
@@ -854,6 +868,19 @@ def sniff_netware(fs, cfg):
|
2024-05-04 02:04:11 +02:00
|
|
|
|
|
|
|
return cfg
|
|
|
|
|
|
|
|
+def sniff_xen_kernel(fs, cfg):
|
|
|
|
+ if not cfg["kernel"]:
|
|
|
|
+ if fs.file_exists('/boot/vmlinuz-xen'):
|
|
|
|
+ cfg["kernel"] = '/boot/vmlinuz-xen'
|
|
|
|
+ elif fs.file_exists('/boot/vmlinuz-xenpae'):
|
|
|
|
+ cfg["kernel"] = '/boot/vmlinuz-xenpae'
|
|
|
|
+ if cfg["kernel"] and not cfg["ramdisk"]:
|
|
|
|
+ if fs.file_exists('/boot/initrd-xen'):
|
|
|
|
+ cfg["ramdisk"] = '/boot/initrd-xen'
|
|
|
|
+ elif fs.file_exists('/boot/initrd-xenpae'):
|
|
|
|
+ cfg["ramdisk"] = '/boot/initrd-xenpae'
|
|
|
|
+ return cfg
|
|
|
|
+
|
|
|
|
def format_sxp(kernel, ramdisk, args):
|
|
|
|
s = "linux (kernel %s)" % repr(kernel)
|
|
|
|
if ramdisk:
|
2024-10-18 15:48:08 +02:00
|
|
|
@@ -932,7 +959,7 @@ if __name__ == "__main__":
|
2024-05-04 02:04:11 +02:00
|
|
|
debug = False
|
|
|
|
not_really = False
|
|
|
|
output_format = "sxp"
|
|
|
|
- output_directory = "/var/run/xen/pygrub/"
|
|
|
|
+ output_directory = "/var/run/xen"
|
|
|
|
uid = None
|
|
|
|
|
|
|
|
# what was passed in
|