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

How to boot ordinary linux distributions in VMs? #18

Open
Trolldemorted opened this issue Sep 2, 2022 · 7 comments
Open

How to boot ordinary linux distributions in VMs? #18

Trolldemorted opened this issue Sep 2, 2022 · 7 comments

Comments

@Trolldemorted
Copy link

Hey, your tutorial on booting linux guests goes into detail how to explicitly supply the kernel image and initrd to uvmm, and the uvmm documentation has some more details.

How do you get from official distribution isos to a functional guest in uvmm? Should I just extract vmlinux and initrd and plug it in?

@alacko
Copy link

alacko commented Sep 2, 2022

Yes, that's the way of doing it currently.

@Trolldemorted
Copy link
Author

Trolldemorted commented Sep 3, 2022

I more or less managed to build everything for x86_64 (without proper devices trees and whatnot) and have it include the vmlinuz and initrd of Ubuntu 22, but it fails to start the guest in qemu:

Ned says: Hi World!
Ned: loading file: 'rom/uvmm-basic.ned'
terminate called after throwing an instance of 'N2L413Runtime_errorE'
  what: Invalid request: Unsupported HW virtualization type.

I guess I am crashing out here:

Vcpu_ptr::Vm_state_t
Vcpu_ptr::determine_vmm_type()
{
  if (!l4util_cpu_has_cpuid())
    throw L4::Runtime_error(-L4_ENOSYS,
                            "Platform does not support CPUID. Aborting!\n");

  l4_umword_t ax, bx, cx, dx;
  l4util_cpu_cpuid(0, &ax, &bx, &cx, &dx);

  if (bx == 0x756e6547 && cx == 0x6c65746e && dx == 0x49656e69)
    return Vm_state_t::Vmx;
  else if (bx == 0x68747541 && cx == 0x444d4163 && dx == 0x69746e65)
    return Vm_state_t::Svm;
  else
    throw L4::Runtime_error(-L4_ENOSYS, "Platform not supported. Aborting!\n");
}

Since I am currently working in a Linux VM w/o nested virt, I assume that uvmm requires the virtualization extensions and cannot do emulation. Therefore I tried to build an iso image which I could throw into my local Hyper-V (for nested virt) or boot on real hardware, but it says Cannot find a stage2_eltorito file:

root@19389e76cc11:/l4re/build-x86_64# make E=uvmm-basic grub1iso
make[1]: Entering directory '/l4re/l4'
Cannot find a stage2_eltorito file... at tool/lib/L4/Grub.pm line 55.
Makefile:631: recipe for target 'grub1iso' failed
make[1]: *** [grub1iso] Error 2
make[1]: Leaving directory '/l4re/l4'
Makefile:6: recipe for target 'do-all-make-goals' failed
make: *** [do-all-make-goals] Error 2

Am I missing some dependencies required for make grub1iso?

@Trolldemorted
Copy link
Author

Trolldemorted commented Sep 4, 2022

I have built an iso image with make E=uvmm-basic grub2iso, but I can't get it to boot on other Hyper-V (gen1 and gen2 VMs) and on a ThinkPad T520. Is there something obvious I might be missing? Despite playing around with the grub timeout I don't get a grub screen.

@alacko
Copy link

alacko commented Sep 4, 2022

Could be difference with UEFI vs. PC-BIOS. Does the type of GRUB (system GRUB) used to generate the ISO match the ones used on the target boxes? A T520 probably does not use EFI...(?)

@Trolldemorted
Copy link
Author

Trolldemorted commented Sep 5, 2022

I have now plugged the stick into an Asus PRIME X570-P, explicitly selected it in the boot device menu, but it don't get to see anything of grub, and after a few seconds my windows starts coming up (probably because it is next in line).

The iso should work out-of-the-box, right? I just threw it into Rufus and flashed the first USB device I could find.

@alacko
Copy link

alacko commented Sep 6, 2022

I would hope so. At least the following works for me in QEMU.

$ wget http://l4re.org/download/snapshots/pre-built-images/amd64/hello.pc.iso
$ qemu-system-x86_64 -m 512 -cdrom hello.pc.iso

Or

$ wget http://l4re.org/download/snapshots/pre-built-images/amd64/hello.efi.iso
$ qemu-system-x86_64 -m 512 -bios /usr/share/qemu/OVMF.fd -serial stdio -cdrom hello.efi.iso

@Trolldemorted
Copy link
Author

After examining your isos and prowling through your perl scripts I have noticed a few things:

  • make E=uvmm-basic grub1iso was failing because my container didn't have grub installed, you might want to add it to your prerequisities
  • after apt-get install grub I can use grub1iso to produce an iso which is bootable in Hyper-V gen1 VMs 🎉
  • your efi iso is significantly bigger than mine, these are all files which mine has:
|   bootstrap
|   fiasco
|   initrd
|   l4re
|   moe
|   ned
|   sigma0
|   uvmm
|   uvmm-basic.ned
|   virt-pc.dtb
|   vmlinuz
|
\---boot
    \---grub
        |   grub.cfg
        |
        \---roms

Any idea why the bootloader is missing in my efi images? Do you have CI scripts that build certain L4Re variations which I could have a look at?

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

No branches or pull requests

2 participants