kernkonzept / manifest

The main L4Re manifest to checkout the L4Re operating system.
GNU General Public License v2.0
19 stars 5 forks source link

How to boot ordinary linux distributions in VMs? #18

Open Trolldemorted opened 2 years ago

Trolldemorted commented 2 years ago

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 commented 2 years ago

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

Trolldemorted commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

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?