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

Call for ideas vmlinuz and initrd for testing #51

Closed
Code-Hex opened this issue Sep 20, 2022 · 11 comments · Fixed by #85
Closed

Call for ideas vmlinuz and initrd for testing #51

Code-Hex opened this issue Sep 20, 2022 · 11 comments · Fixed by #85
Labels
help wanted Extra attention is needed

Comments

@Code-Hex
Copy link
Owner

Code-Hex commented Sep 20, 2022

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 🙏

@Code-Hex Code-Hex added the help wanted Extra attention is needed label Sep 20, 2022
@cfergeau
Copy link
Contributor

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

@Code-Hex
Copy link
Owner Author

@cfergeau Thanks. I'm researching other options.

@Code-Hex
Copy link
Owner Author

Code-Hex commented Sep 26, 2022

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"

@Code-Hex
Copy link
Owner Author

Code-Hex commented Oct 5, 2022

I'm working on making too tiny Linux for testing them

https://github.com/Code-Hex/puipui-linux

@Code-Hex Code-Hex mentioned this issue Oct 8, 2022
5 tasks
@cfergeau
Copy link
Contributor

I came across https://blog.xpnsec.com/bring-your-own-vm-mac-edition/ which might be similar to what you are looking for.

@Code-Hex
Copy link
Owner Author

Maybe dropbear might be needed.

@cfergeau
Copy link
Contributor

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.

@cfergeau
Copy link
Contributor

List of qemu-ga features: https://www.qemu.org/docs/master/interop/qemu-ga-ref.html

@Code-Hex
Copy link
Owner Author

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?

@cfergeau
Copy link
Contributor

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)

@cfergeau
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants