Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing new kernel breaks custom kernel= line in xen.cfg #5716

Closed
dmoerner opened this issue Mar 9, 2020 · 6 comments · Fixed by QubesOS/qubes-core-admin-linux#60
Closed
Labels
C: core P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. r4.0-dom0-stable r4.1-dom0-cur-test

Comments

@dmoerner
Copy link

dmoerner commented Mar 9, 2020

Fully updated R4.0, with both kernel and kernel-latest installed.

My machine requires the kernel= line in /boot/efi/EFI/qubes/xen.cfg to include the entry "mem_sleep_default=deep".

When I upgrade dom0 and get a new kernel, seemingly from either kernel or kernel-latest, this line is broken. It gets replaced by mem_sleep_default=[latest kernel installed].

For example, this is what my xen.cfg looked like after updating kernel-latest yesterday:

[global]
default=5.5.7-1.qubes.x86_64

[5.4.10-1.qubes.x86_64]
options=loglvl=all dom0_mem=min:1024M dom0_mem=max:4096M iommu=no-igfx ucode=scan smt=off
kernel=vmlinuz-5.4.10-1.qubes.x86_64 root=/dev/mapper/qubes_dom0-root rd.luks.uuid=luks-123o8cv-e3ea-4968-8f6b-ce692fde64c2 rd.lvm.lv=qubes_dom0/root rd.lvm.lv=qubes_dom0/swap i915.alpha_support=1 rhgb quiet rd.qubes.hide_all_usb plymouth.ignore-serial-consoles mem_sleep_default=5.5.7-1.qubes.x86_64
ramdisk=initramfs-5.4.10-1.qubes.x86_64.img
[4.19.94-1.pvops.qubes.x86_64]
options=loglvl=all dom0_mem=min:1024M dom0_mem=max:4096M iommu=no-igfx ucode=scan smt=off
kernel=vmlinuz-4.19.94-1.pvops.qubes.x86_64 root=/dev/mapper/qubes_dom0-root rd.luks.uuid=luks-123o8cv-e3ea-4968-8f6b-ce692fde64c2 rd.lvm.lv=qubes_dom0/root rd.lvm.lv=qubes_dom0/swap i915.alpha_support=1 rhgb quiet rd.qubes.hide_all_usb plymouth.ignore-serial-consoles mem_sleep_default=5.5.7-1.qubes.x86_64
ramdisk=initramfs-4.19.94-1.pvops.qubes.x86_64.img
[5.4.16-1.qubes.x86_64]
options=loglvl=all dom0_mem=min:1024M dom0_mem=max:4096M iommu=no-igfx ucode=scan smt=off
kernel=vmlinuz-5.4.16-1.qubes.x86_64 root=/dev/mapper/qubes_dom0-root rd.luks.uuid=luks-123o8cv-e3ea-4968-8f6b-ce692fde64c2 rd.lvm.lv=qubes_dom0/root rd.lvm.lv=qubes_dom0/swap i915.alpha_support=1 rhgb quiet rd.qubes.hide_all_usb plymouth.ignore-serial-consoles mem_sleep_default=5.5.7-1.qubes.x86_64
ramdisk=initramfs-5.4.16-1.qubes.x86_64.img
[4.19.100-1.pvops.qubes.x86_64]
options=loglvl=all dom0_mem=min:1024M dom0_mem=max:4096M iommu=no-igfx ucode=scan smt=off
kernel=vmlinuz-4.19.100-1.pvops.qubes.x86_64 root=/dev/mapper/qubes_dom0-root rd.luks.uuid=luks-123o8cv-e3ea-4968-8f6b-ce692fde64c2 rd.lvm.lv=qubes_dom0/root rd.lvm.lv=qubes_dom0/swap i915.alpha_support=1 rhgb quiet rd.qubes.hide_all_usb plymouth.ignore-serial-consoles mem_sleep_default=5.5.7-1.qubes.x86_64
ramdisk=initramfs-4.19.100-1.pvops.qubes.x86_64.img
[4.19.107-1.pvops.qubes.x86_64]
options=loglvl=all dom0_mem=min:1024M dom0_mem=max:4096M iommu=no-igfx ucode=scan smt=off
kernel=vmlinuz-4.19.107-1.pvops.qubes.x86_64 root=/dev/mapper/qubes_dom0-root rd.luks.uuid=luks-123o8cv-e3ea-4968-8f6b-ce692fde64c2 rd.lvm.lv=qubes_dom0/root rd.lvm.lv=qubes_dom0/swap i915.alpha_support=1 rhgb quiet rd.qubes.hide_all_usb plymouth.ignore-serial-consoles mem_sleep_default=5.5.7-1.qubes.x86_64
ramdisk=initramfs-4.19.107-1.pvops.qubes.x86_64.img
[5.5.7-1.qubes.x86_64]
options=loglvl=all dom0_mem=min:1024M dom0_mem=max:4096M iommu=no-igfx ucode=scan smt=off
kernel=vmlinuz-5.5.7-1.qubes.x86_64 root=/dev/mapper/qubes_dom0-root rd.luks.uuid=luks-123o8cv-e3ea-4968-8f6b-ce692fde64c2 rd.lvm.lv=qubes_dom0/root rd.lvm.lv=qubes_dom0/swap i915.alpha_support=1 rhgb quiet rd.qubes.hide_all_usb plymouth.ignore-serial-consoles mem_sleep_default=5.5.7-1.qubes.x86_64
ramdisk=initramfs-5.5.7-1.qubes.x86_64.img

This is probably a fairly simple parsing bug somewhere, but I'm sorry, I don't have the time myself to try to track it down right now.

@dmoerner dmoerner added P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. T: bug labels Mar 9, 2020
@becomer00t
Copy link

becomer00t commented Mar 10, 2020

The issue appears to come from the sed command involved in switching out the default boot option. It is a bit 'greedy' in it's matches, and matches the default= at the end of mem_sleep_default.

Below is the culprit code

# then change the default
sed -e "s/default=.*/default=$KVER/" -i $EFI_DIR/xen.cfg

https://github.com/QubesOS/qubes-core-admin-linux/blob/master/system-config/kernel-xen-efi.install#L76

Working on a possible solution now by replacing the sed with an awk similar to the block above.

@becomer00t
Copy link

Replacing the sed line with the following fixes the issue - however it unfortunately involves writing the file to a temporary file in the process, otherwise the file is created anew before awk starts reading from it.

	    # then change the default
	    awk -F = --assign "kver=${KVER}" '
	    /^\[/ {
                # section header - previous section (if any) ended
                in_global=0;
            }
	    /\[global\]/ {
                # we are now in the global block - set flag
                in_global=1;
    	    }
            /^default=/ {
                # only pay attention to default= if we are in the global block
	        if (in_global) {
		    sub("=[^ ]*", "=" kver);
		}
    	    }
            {
                print;
	    }
	    ' $EFI_DIR/xen.cfg > $EFI_DIR/xen.cfg.tmp
	    
	    mv $EFI_DIR/xen.cfg.tmp $EFI_DIR/xen.cfg

Maybe someone more familiar with bash / awk could suggest a solution that doesn't require a temporary file, however this seems to work wonders on my test machine.

@marmarek
Copy link
Member

Just adding ^ should be enough:

# then change the default
sed -e "s/^default=.*/default=$KVER/" -i $EFI_DIR/xen.cfg

@qubesos-bot
Copy link

Automated announcement from builder-github

The package qubes-core-dom0-linux-4.0.25-1.fc25 has been pushed to the r4.0 testing repository for dom0.
To test this update, please install it with the following command:

sudo qubes-dom0-update --enablerepo=qubes-dom0-current-testing

Changes included in this update

@qubesos-bot
Copy link

Automated announcement from builder-github

The package qubes-core-dom0-linux-4.1.6-1.fc32 has been pushed to the r4.1 testing repository for dom0.
To test this update, please install it with the following command:

sudo qubes-dom0-update --enablerepo=qubes-dom0-current-testing

Changes included in this update

@qubesos-bot
Copy link

Automated announcement from builder-github

The package qubes-core-dom0-linux-4.0.26-1.fc25 has been pushed to the r4.0 stable repository for dom0.
To install this update, please use the standard update command:

sudo qubes-dom0-update

Or update dom0 via Qubes Manager.

Changes included in this update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: core P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. r4.0-dom0-stable r4.1-dom0-cur-test
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants