Skip to content

pvgrub_image: add package #25724

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

Merged
merged 1 commit into from
Jul 5, 2017
Merged

pvgrub_image: add package #25724

merged 1 commit into from
Jul 5, 2017

Conversation

michalpalka
Copy link

Add a package containing a pvgrub image for xen generated from grub2

Motivation for this change

This package provides a pvgrub image for booting PV guests in xen. Currently, xen in NixOS also provides pygrub, but it can be used only to boot guests that use older grub utilising menu.lst, and fails with new NixOS guests, for example.

I would appreciate if someone takes a look at this before merging.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

@mention-bot
Copy link

@michalpalka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @wkennington, @dezgeg and @edolstra to be potential reviewers.

@pSub pSub added the 8.has: package (new) This PR adds a new package label May 14, 2017
@michalpalka michalpalka mentioned this pull request Jul 1, 2017
7 tasks
# if we include it.
grub-mkimage -O ${efiSystemsBuild.${stdenv.system}.target}-xen -c grub-bootstrap.cfg \
-m memdisk.tar -o grub-${efiSystemsBuild.${stdenv.system}.target}-xen.bin \
`ls ${grub2_xen}/lib/grub/${efiSystemsBuild.${stdenv.system}.target}-xen/ |grep 'mod''$'|grep -v '^all_video\.mod''$'`
Copy link
Contributor

Choose a reason for hiding this comment

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

Use find, not ls.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also don't use back ticks, but $().

Copy link
Contributor

Choose a reason for hiding this comment

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

And add ""s pretty much everywhere.

Copy link
Author

Choose a reason for hiding this comment

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

I have put quotes around all file names with variables in them, and addressed the other changes. Please let me know if this is what you wanted.

Copy link
Author

Choose a reason for hiding this comment

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

Actually, I had to revert back to using ls instead of find, as find produces full paths instead of just file names. If there is some specific reason not to use ls, please let me know. Otherwise I would prefer to stay with ls, as using find will require adding one more processing step to the pipeline.

-m memdisk.tar -o grub-${efiSystemsBuild.${stdenv.system}.target}-xen.bin \
`ls ${grub2_xen}/lib/grub/${efiSystemsBuild.${stdenv.system}.target}-xen/ |grep 'mod''$'|grep -v '^all_video\.mod''$'`
mkdir -p $out/lib/grub-xen
cp grub-${efiSystemsBuild.${stdenv.system}.target}-xen.bin $out/lib/grub-xen/
Copy link
Contributor

Choose a reason for hiding this comment

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

The braces look unbalanced.

Copy link
Contributor

Choose a reason for hiding this comment

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

The variables also need to be quoted.

Copy link
Author

Choose a reason for hiding this comment

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

Could you point at which braces are unbalanced here? I can't see any.

Copy link
Author

Choose a reason for hiding this comment

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

I have put quotes around file names here too.

@@ -0,0 +1,9 @@
if search -s -f /boot/grub/grub.cfg ; then
echo "Reading (${root})/boot/grub/grub.cfg"
Copy link
Contributor

Choose a reason for hiding this comment

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

The parentheses and ${root} might make sense in a larger context, but they don't to me in this small context.

Copy link
Author

Choose a reason for hiding this comment

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

The parentheses are here to match Grub's config file syntax. In fact, the file has been taken from here. If you think that there is a good reason to remove them, then of course I can do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why are there two paths to read grub.cfg from? One is /boot/grub/grub.cfg. If we only use one, eliminate one please.

Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding the parentheses, adding the comment
The parentheses around ${root} here to match Grub's config file syntax to the source code would work wonders.

Copy link
Author

@michalpalka michalpalka Jul 5, 2017

Choose a reason for hiding this comment

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

My understanding is that it is a convenience feature, which allows you to have a separate /boot partition and still use the same pre-built pvgrub image, as explained on the Xen project wiki:

Bootstrapping into this more complex grub.cfg allows us to cope with guests which have a separate /boot partition by searching for a file named /boot/grub/grub.cfg or /grub/grub.cfg on any partition. Note that ${root} is set by the search command and should be entered literally, not substituted while creating this file.

Since the Xen project wiki is advocating for this solution, I would recommend keeping it.

Copy link
Author

Choose a reason for hiding this comment

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

I have added the comment about parentheses.

description = "PvGrub image for use for booting PV Xen guests";

longDescription =
'' This package provides a PvGrub image for booting PV Xen guests
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a long description, so just state Paravirtualization (PV).

@michalpalka
Copy link
Author

Thanks for the comments! I have amended the commit to address them.

buildCommand = ''
cp "${configs}"/* .
tar -cf memdisk.tar grub.cfg
# We include all modules except all_video.mod as otherwise grub will fail printing "no symbol table"
Copy link
Contributor

Choose a reason for hiding this comment

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

https://wiki.xenproject.org/wiki/Xen_EFI lists all_video.mod in one particular configuration, so your statement doesn't seem precise enough.

Copy link
Author

Choose a reason for hiding this comment

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

The comment is based on my observation that pvgrub fails when we include that module. The website that you linked to concerns booting Xen itself using EFI, which requires compiling grub as an EFI loader. The all_video.mod module is probably working in that setup, which does not contradict what I wrote. Please let me know if I should include any clarification in the comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

@michalpalka I like content without words like "I believe" or "probably" better than content that just guesses something.

While I understand it's hard to know everything, striving to documenting the reasons for failures makes it possible to improve things later on.

It has already been merged, which is good for continuity, but if you do have a superior understand of exactly why things happen the way they do with all_video.mod, please document it.

Add a package containing a pvgrub image for xen generated from grub2
@7c6f434c 7c6f434c merged commit d38d3d1 into NixOS:master Jul 5, 2017
@michalpalka
Copy link
Author

Thanks a lot @0xABAB and @7c6f434c !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: package (new) This PR adds a new package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants