-
Notifications
You must be signed in to change notification settings - Fork 12
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
Drop in Interactive shell #58
Conversation
This is currently a PoC, but it does seem functional without being too intrusive. It does help to be able to get a shell in the VM when tests are failure and further troubleshooting is needed. |
The error seems unrelated. I believe I had it happening on my computer sporadically too.
|
ed04e85
to
bdad8d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, seems quite reasonable. maybe add some kind of pexpect style integration test as well?
@@ -35,6 +35,7 @@ const COMMAND_TEMPLATE: &str = include_str!("init/command.template"); | |||
const ROOTFS_9P_FS_MOUNT_TAG: &str = "/dev/root"; | |||
const SHARED_9P_FS_MOUNT_TAG: &str = "vmtest-shared"; | |||
const COMMAND_OUTPUT_PORT_NAME: &str = "org.qemu.virtio_serial.0"; | |||
const MAGIC_INTERACTIVE_COMMAND: &str = "-"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unixy :)
yeah, good idea. |
We used to let init block on `qemu-qa`, run commands, and then terminate the VM through QMP. By blocking on a bash process, we obtain the same outcome, but then we can also re-use the same init script to get an interactive prompt in the VM, which in turn can help with danobi#54. Signed-off-by: Manu Bretelle <[email protected]>
When the magic command `-` is passed, and we are running in kernel mode, get a shell prompt in the VM. To do this, we can re-use the existing `run` framework with some changes: - standard streams to the qemu command are not changed and instead are inherited - child std is not streamed to the UI anymore. - the command is not sent over qga anymore, we just wait for the qemu command to return (e.g when user exit its bash prompt) and exit Fixes danobi#54 Tested by running ``` RUST_LOG=debug cargo run -- -k kernels/bzImage-x86_64 - ``` and confirming no existing tests are broken. Also could get it to work cross-platform: ``` cargo run -- -k ./kernels/Image-arm64 -r ./rootfs/ubuntu-lunar-arm64 -a aarch64 - ``` Signed-off-by: Manu Bretelle <[email protected]>
Add a test that will boot vmtest with a kernel in interactive shell mode. We need to sleep a bit in order to have vmtest mount shared folder with QGA. Signed-off-by: Manu Bretelle <[email protected]>
Signed-off-by: Manu Bretelle <[email protected]>
bdad8d3
to
e2fed0b
Compare
ok, added a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really nice!
btw, could we update the help message with something like [-]
to indicate there's special handling? I think that's a pretty standard hint for coreutils style tools
The current diff prints:
I could make it something like:
instead. |
Ah, missed that in the final commit. LGTM as is |
/// Interactive mode means we are not running a command and we are not | ||
/// running in image mode. | ||
fn interactive(&self) -> bool { | ||
self.command == MAGIC_INTERACTIVE_COMMAND && !self.image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chantra why !self.image
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, but I have not played with images much, the image does not depend on a init file, which is what provides the root prompt here. I don't think it is just a matter of removing the check on whether or not this is running in an image to have it magically work, but I may be wrong.
When the magic command
-
is passed, and we are running in kernel mode, get ashell prompt in the VM.
To do this, we can re-use the existing
run
framework with some changes:return (e.g when user exit its bash prompt) and exit
Fixes #54
Tested by running
and confirming no existing tests are broken.
Also could get it to work cross-platform: