Call for ideas vmlinuz and initrd for testing
I have a plan to add some test code. But I need to use vmlinuz and initrd to write e2e testing. So I call for ideas what files are should be used (alpine? busybox? etc).
What's want
- small distribution
- minimum requirement to check booting
If you have knowledge, please tell me your recommendations. Thanks 🙏
I also did a bit of research on this yesterday, and alpine may be the best option. A lot of the small distros I looked at were unmaintained/out of date/not having aarch64 builds/... An alternative could be Fedora CoreOS images which have a nice go API to automatically fetch them/..., but then the kernel/initrd need to be extracted from the image.
$ podman run quay.io/coreos/coreos-installer:release list-stream
https://github.com/containers/gvisor-tap-vsock/blob/main/test/fcos.go https://github.com/containers/gvisor-tap-vsock/blob/5b1aff8ba74374aeb62eaa06faa496faf2c56d74/test/fcos_amd64.go
@cfergeau Thanks. I'm researching other options.
I'm trying toybox but I can't boot (maybe this is successful but not shown on the console) on this library but I can be confirmed by qemu.
.PHONY: initrd
initrd:
curl http://landley.net/toybox/downloads/binaries/mkroot/0.8.8/aarch64.tgz -o aarch64.tgz
tar -xvzf aarch64.tgz
Use example linux code
$ VMLINUZ_PATH=../../aarch64/linux-kernel INITRD_PATH=../../aarch64/initramfs.cpio.gz ./virtualization
kernel command: "console=ttyAMA0"
I'm working on making too tiny Linux for testing them
https://github.com/Code-Hex/puipui-linux
I came across https://blog.xpnsec.com/bring-your-own-vm-mac-edition/ which might be similar to what you are looking for.
Maybe dropbear might be needed.
qemu-guest-agent could be an alternative to dropbear, it can run commands, read/write files, ... It runs unauthenticated over a vsock connection. It can also run over virtio-serial, but I think https://developer.apple.com/documentation/virtualization/vzvirtioconsoleportconfiguration?language=objc would be needed for that.
List of qemu-ga features: https://www.qemu.org/docs/master/interop/qemu-ga-ref.html
I'm trying qemu-guest-agent to run any command but I don't know how to do it. In my understanding, through ssh if use dropbear but through vsock if qemu-guest-agent. Right?
but through vsock if qemu-guest-agent. Right?
Yes, that would happen over vsock. qemu-guest-agent needs to be started with --method=vsock-listen --path=3:1234.
Then on the host you use ConnectToPort(1234). You can send qemu-ga commands over the VirtioSocketConnection returned by ConnectToPort. For example
{"execute": "guest-set-time", "arguments":{"time": 1665992533}}"
guest-exec should be able to run commands (but I never tried it)
I'm trying toybox but I can't boot (maybe this is successful but not shown on the console) on this library
If you add this:
diff --git a/example/linux/main.go b/example/linux/main.go
index 4f335bc..2d63449 100644
--- a/example/linux/main.go
+++ b/example/linux/main.go
@@ -185,6 +185,10 @@ func main() {
log.Println("stopped successfully")
return
}
+ if newState == vz.VirtualMachineStateError {
+ log.Println("VM is in error state")
+ return
+ }
case err := <-errCh:
log.Println("in start:", err)
}
then trying to start the toybox kernel from http://landley.net/toybox/downloads/binaries/mkroot/0.8.8/aarch64.tgz fails with VM is in error state.