You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[antlir2_vm] dump eth0 traffic when running in test mode
Summary:
This diff provides a mechanism to dump eth0 traffic when running an
antlir VM.
Essentially, this adds a new option to `antlir2_vm run` called `--eth0-output-file`.
When it is set, qemu will be configured to dump the traffic of `net0` interface to
that file. By default, nothing is dumped.
To plug this into the testing framework, when `antlir2_vm` test is called, it
creates the blob artifacts that will be uploaded to TPX and passes the resulting
file to `antlir2_vm run` via `--eth0-output-file`.
Test Plan:
```
$ buck2 run fbcode//antlir/antlir2/antlir2_vm:antlir2_vm -- run -h
Buck UI: https://www.internalfb.com/buck2/64d2ce42-afe3-42cf-9970-76387fcbb5a8
Network: Up: 0B Down: 0B
Jobs completed: 6. Time elapsed: 0.0s.
BUILD SUCCEEDED
Run the VM. Must be executed inside container
Usage: antlir2_vm run [OPTIONS] --machine-spec <MACHINE_SPEC> [COMMAND]...
Arguments:
[COMMAND]... Execute command through ssh inside VM
Options:
--machine-spec <MACHINE_SPEC> Json-encoded file for VM machine configuration
--expect-failure Expects the VM to timeout or terminate early
--postmortem The command should be run after VM termination. Console log will be available at env $CONSOLE_OUTPUT
--timeout-secs <TIMEOUT_SECS> Timeout in seconds before VM will be terminated. None disables the timeout, which should only be used for interactive shells for development
--console-output-file <CONSOLE_OUTPUT_FILE> Redirect console output to file. By default it's suppressed
--output-dirs <OUTPUT_DIRS> Output directories that need to be available inside VM
--command-envs <COMMAND_ENVS> Environment variables for the command
--first-boot-command <FIRST_BOOT_COMMAND> Command requires first boot
--eth0-output-file <ETH0_OUTPUT_FILE> Dump network traffic on eth0 to output to file. By default it is not dumped
--console Drop into console prompt. This also enables console output on screen, unless `--console-output-file` is specified
--container Drop into container shell outside VM
-h, --help Print help
```
and ran:
```
buck2 test $(kerctl vmtest-config -e everstore:GICWmAACj33BEzsFAElJ4glD5YhXbuYfAAAf) fbcode//kernel/vmtest/uname_test:uname_test-6.9-local
```
https://www.internalfb.com/intern/testinfra/testconsole/testrun/6755399674977058/
leads to
https://www.internalfb.com/intern/testinfra/diagnostics/6755399674977058.562950104331417.1727383743/
which has an "Artifacts" section with eth0.pcap
Reviewed By: wujj123456
Differential Revision: D63487026
fbshipit-source-id: f6e63d2202a08d7b324364f7b492818de3224230
Copy file name to clipboardExpand all lines: antlir/antlir2/antlir2_vm/src/main.rs
+24-8Lines changed: 24 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ use crate::share::VirtiofsShare;
44
44
usecrate::types::MachineOpts;
45
45
usecrate::types::MountPlatformDecision;
46
46
usecrate::types::VMArgs;
47
+
usecrate::utils::create_tpx_blobs;
47
48
usecrate::utils::create_tpx_logs;
48
49
usecrate::utils::env_names_to_kvpairs;
49
50
usecrate::utils::log_command;
@@ -97,6 +98,9 @@ struct IsolateCmdArgs {
97
98
/// Extra RW bind-mount into the VM for debugging purpose
98
99
#[arg(long)]
99
100
scratch_dir:Option<PathBuf>,
101
+
/// Whether or not to dump the VM's eth0 traffic to a file. When running the test command, this will set eth0_output_file to a file that will be uploaded to tpx.
0 commit comments