Skip to content

nixos/qemu-vm: refactor bootDisk using make-disk-image#207039

Merged
RaitoBezarius merged 5 commits intomasterfrom
qemu-boot-disk-using-make-disk-image
Apr 21, 2023
Merged

nixos/qemu-vm: refactor bootDisk using make-disk-image#207039
RaitoBezarius merged 5 commits intomasterfrom
qemu-boot-disk-using-make-disk-image

Conversation

@RaitoBezarius
Copy link
Member

@RaitoBezarius RaitoBezarius commented Dec 20, 2022

Description of changes

Depends on #207038.

A small cover letter on the changes:

We remove the bootDisk ad-hoc generation and rewire it up with make-disk-image, this unlocks various features:

Testing is done on https://hydra.nixos.org/jobset/nixos/python-test-refactoring on a recent enough: nixos-unstable-small and treewide cleanups are done.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` labels Dec 20, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 8.has: clean-up This PR removes packages or removes other cruft labels Dec 20, 2022
@RaitoBezarius RaitoBezarius force-pushed the qemu-boot-disk-using-make-disk-image branch from 0102cdc to 486bf1e Compare December 20, 2022 21:11
@RaitoBezarius RaitoBezarius force-pushed the qemu-boot-disk-using-make-disk-image branch from 486bf1e to b2ac559 Compare December 26, 2022 11:08
@RaitoBezarius RaitoBezarius marked this pull request as ready for review December 26, 2022 11:08
@github-actions github-actions bot removed the 8.has: documentation This PR adds or changes documentation label Dec 26, 2022
@Mic92 Mic92 requested a review from Lassulus December 26, 2022 11:21
@blitz
Copy link
Contributor

blitz commented Jan 10, 2023

@RaitoBezarius The comments sound like you still want to work on this. What's the status here?

@RaitoBezarius
Copy link
Member Author

@RaitoBezarius The comments sound like you still want to work on this. What's the status here?

Didn't have time to fix my own comments yet, but it's open to additional comments.

@RaitoBezarius RaitoBezarius force-pushed the qemu-boot-disk-using-make-disk-image branch from b2ac559 to b82c8f9 Compare March 16, 2023 20:05
@github-actions github-actions bot added the 8.has: documentation This PR adds or changes documentation label Mar 16, 2023
@RaitoBezarius RaitoBezarius force-pushed the qemu-boot-disk-using-make-disk-image branch from b82c8f9 to 5b082f5 Compare March 16, 2023 20:10
@github-actions github-actions bot removed the 8.has: documentation This PR adds or changes documentation label Mar 16, 2023
@RaitoBezarius RaitoBezarius force-pushed the qemu-boot-disk-using-make-disk-image branch 2 times, most recently from 3fde81c to 371d377 Compare March 16, 2023 23:32
@RaitoBezarius
Copy link
Member Author

Latest evaluation: https://hydra.nixos.org/eval/1793584?compare=-172800&full=0#tabs-now-fail
From there, it seems like there are only few problematic jobs remaining.

@RaitoBezarius RaitoBezarius force-pushed the qemu-boot-disk-using-make-disk-image branch 2 times, most recently from fd8d369 to 5724827 Compare April 15, 2023 17:46
Copy link
Member

@lilyinstarlight lilyinstarlight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not the most knowledgeable about the qemu-vm test stuff, but this change feels sane to me

Since it changes some semantics it could have some fallout for downstream users, but I don't imagine there are many and it should hopefully be easy for them to understand and update

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/2090

@RaitoBezarius RaitoBezarius force-pushed the qemu-boot-disk-using-make-disk-image branch from 5724827 to 792fd0a Compare April 16, 2023 20:47
@lilyinstarlight
Copy link
Member

It looks like nixosTests.bootspec.grub is failing with this PR with this log snippet:

nixos-disk-image> installing the GRUB 2 boot loader on /dev/vda...
nixos-disk-image> Installing for i386-pc platform.
nixos-disk-image> /nix/store/07bws5lfvgz0a6psxbyhzzz0sbrnqdab-grub-2.06/sbin/grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
nixos-disk-image> /nix/store/07bws5lfvgz0a6psxbyhzzz0sbrnqdab-grub-2.06/sbin/grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
nixos-disk-image> /nix/store/07bws5lfvgz0a6psxbyhzzz0sbrnqdab-grub-2.06/sbin/grub-install: error: will not proceed with blocklists.
nixos-disk-image> /nix/store/nj03jkzbac12apslfmhhmss8qrlvx7wg-install-grub.pl: installation of GRUB on /dev/vda failed: No such file or directory

@RaitoBezarius
Copy link
Member Author

It looks like nixosTests.bootspec.grub is failing with this PR with this log snippet:

nixos-disk-image> installing the GRUB 2 boot loader on /dev/vda...
nixos-disk-image> Installing for i386-pc platform.
nixos-disk-image> /nix/store/07bws5lfvgz0a6psxbyhzzz0sbrnqdab-grub-2.06/sbin/grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
nixos-disk-image> /nix/store/07bws5lfvgz0a6psxbyhzzz0sbrnqdab-grub-2.06/sbin/grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
nixos-disk-image> /nix/store/07bws5lfvgz0a6psxbyhzzz0sbrnqdab-grub-2.06/sbin/grub-install: error: will not proceed with blocklists.
nixos-disk-image> /nix/store/nj03jkzbac12apslfmhhmss8qrlvx7wg-install-grub.pl: installation of GRUB on /dev/vda failed: No such file or directory

If I remember well, the failure is alas unrelated. It's because GRUB tries to install legacy for a UEFI only target.
I implemented the fix somewhere and lost it :D.

@lilyinstarlight
Copy link
Member

If I remember well, the failure is alas unrelated. It's because GRUB tries to install legacy for a UEFI only target.

Yeah the error message sounded like that was the issue

It looks like the NixOS GRUB module assumes that it needs to install legacy unless boot.loader.grub.device = "nodev" is set (in which case if I'm following this Perl right (ugh) then it will assume it needs to do an EFI-only install)

@RaitoBezarius
Copy link
Member Author

If I remember well, the failure is alas unrelated. It's because GRUB tries to install legacy for a UEFI only target.

Yeah the error message sounded like that was the issue

It looks like the NixOS GRUB module assumes that it needs to install legacy unless boot.loader.grub.device = "nodev" is set (in which case if I'm following this Perl right (ugh) then it will assume it needs to do an EFI-only install)

Thank you for going in the rabbit hole, I rediscover this each time. :)

@lilyinstarlight
Copy link
Member

Thank you for going in the rabbit hole, I rediscover this each time. :)

So I don't know if this is "correct" necessarily, but this diff on top of this PR does allow a number of grub tests to pass again (those which currently pass on master and fail on this PR):

diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix
index f85567c42f2..fa928a1ba2f 100644
--- a/nixos/modules/virtualisation/qemu-vm.nix
+++ b/nixos/modules/virtualisation/qemu-vm.nix
@@ -849,7 +849,7 @@ in
             ${opt.writableStore} = false;
         '';
 
-    boot.loader.grub.device = mkVMOverride cfg.bootLoaderDevice;
+    boot.loader.grub.device = mkVMOverride (if cfg.useEFIBoot then "nodev" else cfg.bootLoaderDevice);
     boot.loader.grub.gfxmodeBios = with cfg.resolution; "${toString x}x${toString y}";
     virtualisation.rootDevice = mkDefault suggestedRootDevice;
 

@RaitoBezarius RaitoBezarius force-pushed the qemu-boot-disk-using-make-disk-image branch from 792fd0a to 07f5a70 Compare April 17, 2023 09:52
@RaitoBezarius
Copy link
Member Author

@lilyinstarlight Adressed and latest evaluation shows that it fixes the GRUB tests: https://hydra.nixos.org/eval/1793709

Copy link
Contributor

@nikstur nikstur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool change. The comments and descriptions could use some more editing. Most of my comments are either nitpicks or revolve around naming. Although I think naming is very important, I think it is more important to get this PR across the finish line. We can still improve the naming later.

@RaitoBezarius RaitoBezarius force-pushed the qemu-boot-disk-using-make-disk-image branch 2 times, most recently from 318c68b to 58f7c4e Compare April 19, 2023 23:49
@RaitoBezarius
Copy link
Member Author

@RaitoBezarius RaitoBezarius force-pushed the qemu-boot-disk-using-make-disk-image branch from 58f7c4e to e81f8d2 Compare April 20, 2023 00:02
This option has been introduced in 678eed3 without realizing there was this
PR inflight, unfortunately, it collide with what this PR does and make
it irrelevant.

Therefore, I remove it here.
I do a lot of work on QEMU VM and make-disk-image and I was bitten by an
unnotified change recently, so I want to chime in the future changes of
this file.
@RaitoBezarius RaitoBezarius force-pushed the qemu-boot-disk-using-make-disk-image branch from e81f8d2 to 76f1b63 Compare April 21, 2023 11:00
@RaitoBezarius
Copy link
Member Author

Finally, this will be merged once ofborg CI passes.

@RaitoBezarius RaitoBezarius merged commit 4b4e4c3 into master Apr 21, 2023
@RaitoBezarius
Copy link
Member Author

Thanks to everyone involved in this journey. :)

@alyssais alyssais deleted the qemu-boot-disk-using-make-disk-image branch April 28, 2023 13:27
@alyssais
Copy link
Member

This PR broke nixosTests.kexec. It seems like the final Hydra eval had that test as broken, so maybe it's worth a look to see if any other tests were found to be broken during that eval and overlooked?

@RaitoBezarius
Copy link
Member Author

RaitoBezarius commented May 20, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: policy discussion Discuss policies to work in and around Nixpkgs 8.has: clean-up This PR removes packages or removes other cruft 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

Development

Successfully merging this pull request may close these issues.

7 participants