Skip to content

Conversation

@stephenchengCloud
Copy link
Contributor

Function readGrub2 parses the arguments for each entries in grub.cfg, Missing arguments would result in an error in the original code. So added logic to handle the case of an entry with no arguments (e.g. memtest86+x64.efi).

…uments

Function readGrub2 parses the arguments for each entries in grub.cfg,
Missing arguments would result in an error in the original code.
So added logic to handle the case of an entry with no arguments (e.g. memtest86+x64.efi).

Signed-off-by: Stephen Cheng <stephen.cheng@cloud.com>
@stephenchengCloud
Copy link
Contributor Author

stephenchengCloud commented Feb 28, 2025

  • A simple unit test of parse_boot_entry:
def parse_boot_entry(line):
    parts = line.split(None, 2)  # Split into at most 3 parts
    entry = parts[1] if len(parts) > 1 else ""
    args = parts[2] if len(parts) > 2 else ""        
    print(line)
    print(entry)
    print(args)
    return entry, args

fh = open("grub.cfg", "r")

for line in fh:
    l = line.strip()
    if l.startswith("linux"):
        kernel, kernel_args = parse_boot_entry(l)
    elif l.startswith("multiboot2"):
        if "tboot" in l:
            tboot, tboot_args = parse_boot_entry(l)
        else:
            hypervisor, hypervisor_args = parse_boot_entry(l)

Output:

$ python3 test_split.py
multiboot2 /boot/xen.gz dom0_mem=4304M,max:4304M watchdog ucode=scan dom0_max_vcpus=1-8 crashkernel=256M,below=4G console=vga vga=mode-0x0311
/boot/xen.gz
dom0_mem=4304M,max:4304M watchdog ucode=scan dom0_max_vcpus=1-8 crashkernel=256M,below=4G console=vga vga=mode-0x0311
multiboot2 /boot/xen.gz com2=115200,8n1 console=com2,vga dom0_mem=4304M,max:4304M watchdog ucode=scan dom0_max_vcpus=1-8 crashkernel=256M,below=4G
/boot/xen.gz
com2=115200,8n1 console=com2,vga dom0_mem=4304M,max:4304M watchdog ucode=scan dom0_max_vcpus=1-8 crashkernel=256M,below=4G
multiboot2 /boot/xen.gz nosmp noreboot noirqbalance no-mce no-bootscrub no-numa no-hap no-mmcfg max_cstate=0 nmi=ignore allow_unsafe dom0_mem=4304M,max:4304M com2=115200,8n1 console=com2,vga
/boot/xen.gz
nosmp noreboot noirqbalance no-mce no-bootscrub no-numa no-hap no-mmcfg max_cstate=0 nmi=ignore allow_unsafe dom0_mem=4304M,max:4304M com2=115200,8n1 console=com2,vga
linux /boot/memtest86+x64.efi
/boot/memtest86+x64.efi

multiboot2 /boot/xen-fallback.gz dom0_mem=4304M,max:4304M watchdog ucode=scan dom0_max_vcpus=1-8 crashkernel=256M,below=4G
/boot/xen-fallback.gz
dom0_mem=4304M,max:4304M watchdog ucode=scan dom0_max_vcpus=1-8 crashkernel=256M,below=4G
multiboot2 /boot/xen-fallback.gz com2=115200,8n1 console=com2,vga dom0_mem=4304M,max:4304M watchdog ucode=scan dom0_max_vcpus=1-8 crashkernel=256M,below=4G
/boot/xen-fallback.gz
com2=115200,8n1 console=com2,vga dom0_mem=4304M,max:4304M watchdog ucode=scan dom0_max_vcpus=1-8 crashkernel=256M,below=4G
  • xenrt test 4239395
[04:29:05 28/02] xe host-call-plugin host-uuid=984f5238-6335-470b-a245-32594f0c2214 plugin=prepare_host_upgrade.py fn=main -s 10.62.161.84 -u root -pw '************' args:url=http://10.62.160.11/export/4239395-xenrtlysn9xw8/ (10.62.161.84 = xrtmia-11-84~>xrtmia-11-84, 984f5238 = xrtmia-11-84~>xrtmia-11-84)
true

The original issue was fixed, but there's another issue need to address later.

@stephenchengCloud
Copy link
Contributor Author

stephenchengCloud commented Feb 28, 2025

The CI failure seems not related to this PR.

@stephenchengCloud
Copy link
Contributor Author

@bernhardkaindl @liulinC @rosslagerwall @GeraldEV
Could you review this?

@liulinC liulinC merged commit 74e4c84 into xenserver:master Mar 3, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants