network isolation - #311
Draft
jeckersb wants to merge 7 commits into
Draft
Conversation
Add the --network-isolation flag to both the ephemeral (CommonVmOpts) and libvirt (LibvirtRunOpts) CLI option structs. The flag is accepted by the CLI parser but has no effect yet; the actual QEMU restrict=on wiring follows in subsequent commits. This allows the integration test to be written against the flag immediately, following TDD practice. Closes: bootc-dev#304 Assisted-by: AI Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Add two tests for --network-isolation support: - test_run_ephemeral_network_reachable: positive control that boots a normal VM and verifies it can ping 8.8.8.8 from inside the guest. This proves run-ssh, guest networking, and external reachability all work. Without this, the isolation test could pass vacuously when SSH or networking is broken for unrelated reasons. - test_run_ephemeral_network_isolation: boots a VM with --network-isolation and verifies that pinging 8.8.8.8 from inside the guest fails. Includes the same positive control as a first step to guard against false passes. The fact that run-ssh itself succeeds proves SSH (host-to-guest via hostfwd) is preserved. Both tests skip gracefully with a loud warning when the host cannot reach 8.8.8.8 (e.g. offline environments). The isolation test is expected to fail against the current no-op flag (the positive control succeeds, then the isolation check fails because the guest can still reach the internet). This establishes the TDD baseline that the implementation commits will fix. Assisted-by: AI Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Add a `restrict` field to `NetworkMode::User` that maps to QEMU's slirp `restrict=on` option. When enabled, the guest cannot initiate outbound connections except through explicit hostfwd rules (e.g. SSH port forwarding). This is the mechanism that --network-isolation will use. - Add `restrict: bool` to `NetworkMode::User`, defaulting to false - Add `set_network_restrict()` builder method on QemuConfig - Update `enable_ssh_access()` to preserve the restrict setting - Emit `restrict=on` in the -netdev argument when enabled - Add unit tests for the new functionality Assisted-by: AI Signed-off-by: John Eckersberg <jeckersb@redhat.com>
When --network-isolation is passed to `bcvk ephemeral run` or `bcvk ephemeral run-ssh`, set restrict=on on the QEMU slirp netdev. This blocks all guest-initiated outbound connections while preserving SSH access via hostfwd. DNS server injection is also skipped under isolation since external DNS servers are unreachable and the entries would only cause timeouts. Assisted-by: AI Signed-off-by: John Eckersberg <jeckersb@redhat.com>
When --network-isolation is passed to `bcvk libvirt run`, add restrict=on to the QEMU user-mode netdev arguments injected via qemu:commandline. This blocks all guest-initiated outbound connections while preserving SSH access via hostfwd, matching the ephemeral path behavior. Assisted-by: AI Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Run `cargo xtask sync-manpages` to regenerate the OPTIONS sections, picking up the new --network-isolation flag in: - bcvk-ephemeral-run(8) - bcvk-ephemeral-run-ssh(8) - bcvk-libvirt-run(8) - bcvk-to-disk(8) Also picks up a previously missing --virtiofsd option in bcvk-libvirt-run(8). Assisted-by: AI Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Add hand-written documentation for --network-isolation to: Manpages (EXAMPLES sections, outside auto-generated markers): - bcvk-ephemeral-run(8): network isolation example with bind-storage-ro - bcvk-ephemeral-run-ssh(8): quick CI testing example - bcvk-libvirt-run(8): hermetic testing example mdBook conceptual docs: - ephemeral-run.md: new Network Isolation section with example - libvirt-advanced.md: network isolation subsection under Network Configuration All hand-written sections are outside the <!-- BEGIN/END GENERATED OPTIONS --> markers and will be preserved by future sync-manpages runs. Assisted-by: AI Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Collaborator
Author
|
Throwing this up as draft before I disappear for a week. Few quick thoughts:
|
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.
feat: Add --network-isolation CLI flag (no-op)
Add the --network-isolation flag to both the ephemeral (CommonVmOpts)
and libvirt (LibvirtRunOpts) CLI option structs. The flag is accepted
by the CLI parser but has no effect yet; the actual QEMU restrict=on
wiring follows in subsequent commits.
This allows the integration test to be written against the flag
immediately, following TDD practice.
Closes: Add network isolation support #304
Assisted-by: AI
Signed-off-by: John Eckersberg jeckersb@redhat.com
test: Add integration tests for network isolation
Add two tests for --network-isolation support:
test_run_ephemeral_network_reachable: positive control that boots a
normal VM and verifies it can ping 8.8.8.8 from inside the guest.
This proves run-ssh, guest networking, and external reachability
all work. Without this, the isolation test could pass vacuously
when SSH or networking is broken for unrelated reasons.
test_run_ephemeral_network_isolation: boots a VM with
--network-isolation and verifies that pinging 8.8.8.8 from inside
the guest fails. Includes the same positive control as a first step
to guard against false passes. The fact that run-ssh itself succeeds
proves SSH (host-to-guest via hostfwd) is preserved.
Both tests skip gracefully with a loud warning when the host cannot
reach 8.8.8.8 (e.g. offline environments).
The isolation test is expected to fail against the current no-op flag
(the positive control succeeds, then the isolation check fails because
the guest can still reach the internet). This establishes the TDD
baseline that the implementation commits will fix.
Assisted-by: AI
Signed-off-by: John Eckersberg jeckersb@redhat.com
feat(qemu): Add restrict support to NetworkMode::User
Add a
restrictfield toNetworkMode::Userthat maps to QEMU'sslirp
restrict=onoption. When enabled, the guest cannot initiateoutbound connections except through explicit hostfwd rules (e.g. SSH
port forwarding). This is the mechanism that --network-isolation will
use.
restrict: booltoNetworkMode::User, defaulting to falseset_network_restrict()builder method on QemuConfigenable_ssh_access()to preserve the restrict settingrestrict=onin the -netdev argument when enabledAssisted-by: AI
Signed-off-by: John Eckersberg jeckersb@redhat.com
feat: Wire --network-isolation to QEMU restrict for ephemeral VMs
When --network-isolation is passed to
bcvk ephemeral runorbcvk ephemeral run-ssh, set restrict=on on the QEMU slirp netdev.This blocks all guest-initiated outbound connections while preserving
SSH access via hostfwd.
DNS server injection is also skipped under isolation since external
DNS servers are unreachable and the entries would only cause timeouts.
Assisted-by: AI
Signed-off-by: John Eckersberg jeckersb@redhat.com
feat: Wire --network-isolation to QEMU restrict for libvirt VMs
When --network-isolation is passed to
bcvk libvirt run, addrestrict=on to the QEMU user-mode netdev arguments injected via
qemu:commandline. This blocks all guest-initiated outbound
connections while preserving SSH access via hostfwd, matching the
ephemeral path behavior.
Assisted-by: AI
Signed-off-by: John Eckersberg jeckersb@redhat.com
docs: Sync manpages with --network-isolation option
Run
cargo xtask sync-manpagesto regenerate the OPTIONS sections,picking up the new --network-isolation flag in:
Also picks up a previously missing --virtiofsd option in
bcvk-libvirt-run(8).
Assisted-by: AI
Signed-off-by: John Eckersberg jeckersb@redhat.com
docs: Add network isolation examples and prose
Add hand-written documentation for --network-isolation to:
Manpages (EXAMPLES sections, outside auto-generated markers):
mdBook conceptual docs:
Configuration
All hand-written sections are outside the markers and will be preserved by future sync-manpages
runs.
Assisted-by: AI
Signed-off-by: John Eckersberg jeckersb@redhat.com