manifest icon indicating copy to clipboard operation
manifest copied to clipboard

How to boot ordinary linux distributions in VMs?

Open Trolldemorted opened this issue 3 years ago • 7 comments
trafficstars

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?

Trolldemorted avatar Sep 02 '22 11:09 Trolldemorted

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

alacko avatar Sep 02 '22 17:09 alacko

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 avatar Sep 03 '22 22:09 Trolldemorted

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.

Trolldemorted avatar Sep 04 '22 16:09 Trolldemorted

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...(?)

alacko avatar Sep 04 '22 18:09 alacko

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.

Trolldemorted avatar Sep 05 '22 06:09 Trolldemorted

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

alacko avatar Sep 06 '22 12:09 alacko

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?

Trolldemorted avatar Sep 06 '22 15:09 Trolldemorted