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

fix the vmWithBootloader attribute of nixos #65133

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cleverca22
Copy link
Contributor

you can test it with:

nix-build ./nixos/ -A vmWithBootLoader --arg configuration '{ virtualisation.qemu.diskInterface = "virtio"; }' && ./result/bin/run-nixos-vm

Motivation for this change

boot order was broken in f148c5c and the vmWithBootloader ceased to boot

Things done

tested vmWithBootloader on virtio, scsi and ide diskInterface values

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

you can test it with:

nix-build ./nixos/ -A vmWithBootLoader --arg configuration '{ virtualisation.qemu.diskInterface = "virtio"; }' && ./result/bin/run-nixos-vm
@worldofpeace
Copy link
Contributor

Is this suitable for a backport since it used to work?

Copy link
Member

@samueldr samueldr left a comment

Choose a reason for hiding this comment

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

Minor changes, though it looks fine otherwise.

@@ -172,6 +175,7 @@ let
# This is needed for GRUB 0.97, which doesn't know about virtio devices.
mkdir /boot/grub
echo '(hd0) /dev/vda' > /boot/grub/device.map
ln -sv /dev/vda /dev/sda
Copy link
Member

Choose a reason for hiding this comment

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

Could we add a comment explaining why this is required?

Additionally, are there situations where VMs would need /dev/sd[^a] to be available?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when using the ide backend it configures the grub device to /dev/sda
but the initial vm when installing the bootloader is still using virtio (an existing bug that i'm not fixing), so it only has vda and grub-install fails

args = "-drive ${commonArgs},if=none -device lsi53c895a -device ${devArgs}";
in if isSCSI then args else "-drive ${commonArgs},if=${diskInterface}";
devArgs = [ "drive=${drvId}" ] ++ deviceArgs;
cfgMap = {
Copy link
Member

Choose a reason for hiding this comment

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

👍

${mkDiskIfaceDriveFlag "0" "file=$NIX_DISK_IMAGE,cache=writeback,werror=report"} \
${mkDiskIfaceDriveFlag "1" "file=$TMPDIR/disk.img,media=disk"} \
${mkDiskIfaceDriveFlag "0" "file=$NIX_DISK_IMAGE,cache=writeback,werror=report" []} \
${mkDiskIfaceDriveFlag "1" "file=$TMPDIR/disk.img,media=disk" [ "bootindex=1" ]} \
Copy link
Member

Choose a reason for hiding this comment

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

(note) if you wondered what this meant:

https://github.com/qemu/qemu/blob/master/docs/bootindex.txt

No need to add a comment. Just helping other reviewers.

If the bootindex property is not set for a device, it gets lowest boot priority. There is no particular order in which devices with unset bootindex property will be considered for booting, but they will still be bootable.

@@ -142,7 +145,7 @@ let
buildInputs = [ pkgs.utillinux ];
QEMU_OPTS = if cfg.useEFIBoot
then "-pflash $out/bios.bin -nographic -serial pty"
else "-nographic -serial pty";
else "-nographic -serial mon:stdio";
Copy link
Member

Choose a reason for hiding this comment

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

Why is only this side of the branch needing mon:stdio?

And what's up with pty, does it fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pty silently fails, making debug much more difficult
and yeah, i should probably fix the other branch also

@worldofpeace
Copy link
Contributor

ping @cleverca22. This is a pretty good contender to have in the release.

@worldofpeace worldofpeace added this to the 20.03 milestone Feb 2, 2020
@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/nixos-20-03-feature-freeze/5655/13

@bjornfor
Copy link
Contributor

bjornfor commented Feb 4, 2020

you can test it with:
$ nix-build ./nixos/ -A vmWithBootLoader --arg configuration '{ virtualisation.qemu.diskInterface = "virtio"; }' && ./result/bin/run-nixos-vm
[...] tested vmWithBootloader on virtio, scsi and ide diskInterface values

Interface "virtio" (the default) and "ide" works fine here (master @ 2020-02-24, 804fbc9). "scsi" still fails though.

However, the reason I'm here is that vmWithBootLoader is broken for boot.loader.systemd-boot.enable = true; for any diskInterface value:

$ rm -f nixos.qcow2 && time nix-build ./nixos/ -A vmWithBootLoader --arg configuration '{ virtualisation.qemu.diskInterface = "virtio"; boot.loader.systemd-boot.enable = true; }' && ./result/bin/run-nixos-vm
these derivations will be built:
  /nix/store/ik97gp03f0m89294gdah9mab4qfqhq52-nixos-boot-disk.drv
  /nix/store/l6gvb1l3dccwnc0jr5amp31x7d7kp55a-run-nixos-vm.drv
  /nix/store/zb1dj4x9gmb6nj8zcb46ccql14kw6wmi-nixos-vm.drv
building '/nix/store/ik97gp03f0m89294gdah9mab4qfqhq52-nixos-boot-disk.drv'...
Formatting '/nix/store/xcgvhwd4vvaphg7919iznjrr16hy4b3s-nixos-boot-disk/disk.img', fmt=qcow2 size=41943040 cluster_size=65536 lazy_refcounts=off refcount_bits=16
QEMU 4.2.0 monitor - type 'help' for more information
(qemu) char device redirected to /dev/pts/0 (label serial0)
builder for '/nix/store/ik97gp03f0m89294gdah9mab4qfqhq52-nixos-boot-disk.drv' failed with exit code 1
cannot build derivation '/nix/store/l6gvb1l3dccwnc0jr5amp31x7d7kp55a-run-nixos-vm.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/zb1dj4x9gmb6nj8zcb46ccql14kw6wmi-nixos-vm.drv': 1 dependencies couldn't be built
error: build of '/nix/store/zb1dj4x9gmb6nj8zcb46ccql14kw6wmi-nixos-vm.drv' failed

The failure mode for systemd-boot and the issue in the original post (reproducible now with ...diskInterface = "scsi") seems to be the same:

(qemu) char device redirected to /dev/pts/0 (label serial0)
builder for '/nix/store/ik97gp03f0m89294gdah9mab4qfqhq52-nixos-boot-disk.drv' failed with exit code 1

What's going on there?

UPDATE: So my build problems above were fixed by upgrading from NixOS 19.09 to 20.03 (51d115a).

@disassembler disassembler modified the milestones: 20.03, 20.09 Feb 5, 2020
@stale
Copy link

stale bot commented Aug 4, 2020

Hello, I'm a bot and I thank you in the name of the community for your contributions.

Nixpkgs is a busy repository, and unfortunately sometimes PRs get left behind for too long. Nevertheless, we'd like to help committers reach the PRs that are still important. This PR has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

If this is still important to you and you'd like to remove the stale label, we ask that you leave a comment. Your comment can be as simple as "still important to me". But there's a bit more you can do:

If you received an approval by an unprivileged maintainer and you are just waiting for a merge, you can @ mention someone with merge permissions and ask them to help. You might be able to find someone relevant by using Git blame on the relevant files, or via GitHub's web interface. You can see if someone's a member of the nixpkgs-committers team, by hovering with the mouse over their username on the web interface, or by searching them directly on the list.

If your PR wasn't reviewed at all, it might help to find someone who's perhaps a user of the package or module you are changing, or alternatively, ask once more for a review by the maintainer of the package/module this is about. If you don't know any, you can use Git blame on the relevant files, or GitHub's web interface to find someone who touched the relevant files in the past.

If your PR has had reviews and nevertheless got stale, make sure you've responded to all of the reviewer's requests / questions. Usually when PR authors show responsibility and dedication, reviewers (privileged or not) show dedication as well. If you've pushed a change, it's possible the reviewer wasn't notified about your push via email, so you can always officially request them for a review, or just @ mention them and say you've addressed their comments.

Lastly, you can always ask for help at our Discourse Forum, or more specifically, at this thread or at #nixos' IRC channel.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 4, 2020
@bjornfor
Copy link
Contributor

Still important to me.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 17, 2020
@FRidh FRidh modified the milestones: 20.09, 21.03 Dec 20, 2020
@stale
Copy link

stale bot commented Jun 18, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 18, 2021
@Artturin Artturin modified the milestones: 21.05, 23.05 Dec 31, 2022
@stale stale bot removed 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md labels Dec 31, 2022
@RaitoBezarius RaitoBezarius modified the milestones: 23.05, 23.11 May 31, 2023
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 19, 2024
@wegank wegank marked this pull request as draft March 20, 2024 15:12
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet