amluto / virtme

An easy way to virtualize the running system
GNU General Public License v2.0
330 stars 66 forks source link

Kernel Fails to Execute init process #35

Closed nathanjsweet closed 5 years ago

nathanjsweet commented 5 years ago

I'm running the following virtme-run command:

virtme-run --kimg "${tmp_dir}/${kernel}" --memory 2G --pwd --rwdir=/run/output="${output}" --script-sh "$(realpath "$0") --in-vm /run/output" --show-command --show-boot-console

and the following qemu command is output:

/usr/bin/qemu-system-x86_64
-fsdev local,id=virtfs1,path=/,security_model=none,readonly
-device virtio-9p-pci,fsdev=virtfs1,mount_tag=/dev/root
-fsdev local,id=virtfs5,path=/usr/local/lib/python3.6/dist-packages/virtme/guest,security_model=none,readonly
-device virtio-9p-pci,fsdev=virtfs5,mount_tag=virtme.guesttools
-fsdev local,id=virtfs9,path=/tmp/tmp.3cv8xBF24y,security_model=none
-device virtio-9p-pci,fsdev=virtfs9,mount_tag=virtme.initmount0
-machine accel=kvm:tcg
-watchdog i6300esb
-cpu host
-parallel none
-net none
-m 2G
-vga none
-display none
-serial none
-chardev file,id=console,path=/proc/self/fd/2
-serial chardev:console
-chardev stdio,id=stdio,signal=on,mux=off
-device virtio-serial-pci
-device virtserialport,name=virtme.scriptio,chardev=stdio
-no-reboot
-kernel /tmp/tmp.5xuUlk8erz/linux-5.0.13.bz
-append 'virtme_initmount0=/run/output virtme_chdir=root/go/src/github.com/newtools/ebpf init=/bin/sh -- -c "mkdir -p /run/virtme/guesttools;/bin/mount -n -t 9p -o ro,version=9p2000.L,trans=virtio,access=any virtme.guesttools /run/virtme/guesttools;exec /run/virtme/guesttools/virtme-init"'
-initrd /proc/self/fd/3

Looking through the boot console nothing seems to be out of the ordinary until I hit init spin up:

[    1.220049] Run /init as init process
[    1.221046] Failed to execute /init (error -2)
[    1.222113] Run /bin/sh as init process
[    1.223094] Kernel panic - not syncing: Requested init /bin/sh failed (error -2).
[    1.224829] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.0.13 #1
[    1.226258] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
[    1.228401] Call Trace:
[    1.229025]  dump_stack+0x46/0x60
[    1.229826]  ? rest_init+0x80/0x9a
[    1.230632]  panic+0xf6/0x287
[    1.231352]  ? __do_execve_file.isra.49+0xb3/0xa10
[    1.232305]  ? rest_init+0x9a/0x9a
[    1.232946]  kernel_init+0xa1/0xf6
[    1.233860]  ret_from_fork+0x35/0x40
[    1.235036] Kernel Offset: 0x30a00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
[    1.237786] ---[ end Kernel panic - not syncing: Requested init /bin/sh failed (error -2). ]---

Any thoughts or recommendations?

amluto commented 5 years ago

Most likely your kernel is missing some required configuration. Either use --installed-kernel or try virtme-configkernel.

marcosps commented 5 years ago

@nathanjsweet did you managed to get a kernel configured for using with virtme, as @amluto suggested?

marcosps commented 5 years ago

@amluto can we close this issue?

amluto commented 5 years ago

Sure.

h3llix commented 2 years ago

Hi @nathanjsweet @amluto . I am hitting the same issue. What was the solution to this ?

marcosps commented 2 years ago

@h3llix did you run virtme-configkernel to make sure that all kernel options are in place? As virtme uses your /bin/sh from hostsystem maybe the 9p configs are not enabled? virtme-configkernel sets some 9P options builtin (=Y).

h3llix commented 2 years ago

Hey @marcosps! Yes all the k configs were present. I compiled static busybox and used it with virtme. It was working fine then.

marcosps commented 2 years ago

@h3llix did you change anything? For me, it works fine in openSUSE with static busybox. Are you using other fancy features? initrd? Please add more details about your problem so we can help you :)