Skip to content

hyperlight: integrate host-proxied networking via NetworkPolicy#315

Merged
huzaifa-d merged 5 commits into
microsoft:mainfrom
danbugs:hyperlight-networking
May 14, 2026
Merged

hyperlight: integrate host-proxied networking via NetworkPolicy#315
huzaifa-d merged 5 commits into
microsoft:mainfrom
danbugs:hyperlight-networking

Conversation

@danbugs

@danbugs danbugs commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Integrate hyperlight-unikraft's newly merged networking support (host-proxied TCP/UDP sockets) into the MXC hyperlight backend
  • Map MXC's network policy fields to pyhl's NetworkPolicy enum: Block → disabled, allowedHosts → per-host allowlist, Allow → allow-all
  • Add hyperlight_networking.json test config and e2e test case (HTTP GET to example.com with allowlist)
  • Bump hyperlight-unikraft-host to 5f424bb (includes socket2 dependency for networking)
Microsoft Reviewers: Open in CodeFlow

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Copilot AI review requested due to automatic review settings May 14, 2026 18:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Integrates host-proxied networking from hyperlight-unikraft into the MXC hyperlight backend by mapping MXC's NetworkPolicy fields onto pyhl's NetworkPolicy enum, replacing the previous unconditional rejection of network rules.

Changes:

  • Add network_policy_from_request translation and thread NetworkPolicy through ensure_runtime / Runtime::new / pyhl::install.
  • Track active network hosts for runtime-reuse cache invalidation; remove ERR_NETWORK_POLICY and update preflight tests.
  • Add hyperlight_networking.json config and a corresponding e2e test case asserting an HTTP 200 via allowlist.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
test_configs/hyperlight_networking.json New config exercising allowedHosts with an HTTP GET.
src/wxc_e2e_tests/tests/e2e_windows.rs Adds a hyperlight e2e case for the new networking config.
src/wxc_common/src/hyperlight_runner.rs Translates network policy, plumbs it through install/runtime, updates cache key, and rewrites unit tests.

Comment thread src/wxc_common/src/hyperlight_runner.rs Outdated
Comment thread src/wxc_common/src/hyperlight_runner.rs Outdated
Comment thread src/wxc_common/src/hyperlight_runner.rs
…nd normalize host order

Signed-off-by: danbugs <danilochiarlone@gmail.com>
/// Filesystem mounts and network policies ARE supported.
fn validate_policies(request: &CodexRequest) -> Result<(), PyhlError> {
if !request.policy.allowed_hosts.is_empty()
|| !request.policy.blocked_hosts.is_empty()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should still be there because now
Allow + Blocked_host = Allow All

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added BlockList support upstream in hyperlight-dev/hyperlight-unikraft#25. blocked_hosts now maps to NetworkPolicy::BlockList–deny the listed hosts, allow everything else. Also added validation that rejects configs with both allowedHosts and blockedHosts set (mutually exclusive). See commits 46da46a and fa390df.

@@ -0,0 +1,10 @@
{
"process": {
"commandLine": "import urllib.request; r = urllib.request.urlopen('http://example.com/'); print(r.status)",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion : Should add another test with a different url to test the blocking with allowedHosts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added hyperlight_networking_blocked.json–it tries to reach httpbin.org when only example.com is in allowedHosts and expects the request to be blocked. Corresponding e2e test case added. See commit cdedd5d.

danbugs added 2 commits May 14, 2026 21:29
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>

@huzaifa-d huzaifa-d left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@huzaifa-d
huzaifa-d merged commit 974ca9d into microsoft:main May 14, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants