Merged
Conversation
be5d129 to
e2e5296
Compare
Member
Author
|
IT does assume you have the right qemu installed. The size of the kernels and initramfs is small, but qemu is a monster. |
rminnich
commented
Sep 6, 2025
Member
Author
|
The name is probably wrong. It's not just an initramfs package. What do we call it? |
Member
Author
|
Currently assumes u-root is installed, which I'll need to add to the yaml for the actions. Oops. |
1dbfa2a to
a2718ba
Compare
Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
…d CombinedOutput
cpu clients are implemented in the client package. The cpu
command uses this package. As in os/exec, code can call
client.Command(); followed by Client.Start() and client.Wait(),
or use client.Run(), which combines Start and Wait.
The client struct has io.WriteCloser for its Stdout and Stderr.
The question of how these gets closed is important.
Normally, when a cpu process runs, kernel process exit handling performs
a close on stdout and stderr. User code need not call close.
When the client package is used as part of a program that does not exit, as
in a test, code might set the client struct
Stderr and Stdout to a pipe, to avoid littering test output with cpu command
output. In this case, the pipe reader will hang until the Stderr and Stdout
are closed, as no process exits.
It is not safe to just blindly close these files; users might unintentionally
close Stdout, leading to confusing results.
The actual IO is handled by two io.Copy goroutines started in cpu.Start, one for
Stdout, one for Stderr. These two goroutines
exit when the remote process closes the ssh Session Std{err,out}.
At that point, code could decide whether to close the Std{err,out}.
An ideal time to do this check is when the io.Copy exits.
This change tests the type of client.Std{err,out}; IF they are an *os.File,
AND if their Fd() matches the Fd() of os.Std{err,out}, respectively, then they are
left alone; otherwise, they are closed.
This seems a safe test. It has been tested both in a test and interactively
and the behavior is sensible.
With the fix to Stdout/Stderr handling, we can now implement CombinedOutput()
Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
The initramfs package contains a map[string][]byte.
It includes compressed kernel and initramfs for several kernel and
architecture combinations, as well as qemu command line.
It is created by go generate.
The package uses embed to incorporate those files. They are reasonably
small.
To see a possible usage, read vm_test.go
set up vm_test to direct all output to a pipe
Sadly, the original sin of os.Std{in,out,err} requires
an os.File, else we could use an in-memory pipe.
Use CombinedOutput in vm_test.
Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
This IMHO is superior to what we're doing today. Skip the test if we do not have a u-root command Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
It is actually about running a cpud vm. Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
a2718ba to
966ac7f
Compare
Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
163e6ae to
fe1fcae
Compare
Member
Author
|
ok, it's Called vm now, and it's ready for review I think. Next step is to try to replace a u-root generic test with this package. |
AjanZhong
reviewed
Sep 10, 2025
AjanZhong
reviewed
Sep 10, 2025
AjanZhong
reviewed
Sep 10, 2025
AjanZhong
reviewed
Sep 10, 2025
AjanZhong
reviewed
Sep 10, 2025
AjanZhong
reviewed
Sep 10, 2025
AjanZhong
reviewed
Sep 10, 2025
Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
brho
reviewed
Sep 16, 2025
| r.Name = "bbin/cibb" | ||
| case "bbin/init", "bbin/dhclient", "bbin/cpud": | ||
| fixed++ | ||
| r.ReaderAt = bytes.NewReader([]byte("cibb")) |
Collaborator
There was a problem hiding this comment.
are all 3 of these symlinks? and the ReaderAt changes them to link to cibb?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
it's now very easy to run a vm, and the package includes kernels and initramfs across 4 architectures.
This includes a test which demonstrates an integration test. No shell script needed in the guest. No shell needed in the guest, actually.