Skip to content

Add --vmnet-disable-dhcp to disable the vmnet DHCP server (macOS 26+)#165

Open
fpolica91 wants to merge 1 commit into
lima-vm:masterfrom
fpolica91:@chore/support-apple-26
Open

Add --vmnet-disable-dhcp to disable the vmnet DHCP server (macOS 26+)#165
fpolica91 wants to merge 1 commit into
lima-vm:masterfrom
fpolica91:@chore/support-apple-26

Conversation

@fpolica91

@fpolica91 fpolica91 commented Jun 24, 2026

Copy link
Copy Markdown

What

Adds a --vmnet-disable-dhcp flag that starts the vmnet interface with the built-in DHCP server disabled while keeping shared-mode NAT, so an external DHCP/PXE server can own the subnet.

The existing --vmnet-network-identifier mechanism (#139) disables DHCP only for isolated host-mode networks, which also gives up NAT/internet access. This flag covers the shared-mode case.

How

  • With the flag, the interface is started through the macOS 26 vmnet_network_configuration API: vmnet_network_configuration_createset_ipv4_subnet / set_ipv6_prefix / set_external_interface (driven by the existing options) → vmnet_network_configuration_disable_dhcpvmnet_network_createvmnet_interface_start_with_network.
  • Without the flag, behavior is unchanged: the legacy vmnet_start_interface XPC path is used as before.
  • The new path is guarded at compile time (requires the macOS 26 SDK) and at runtime (__builtin_available(macOS 26.0, *)), with explicit errors on older SDKs/hosts.
  • The subnet address is derived by masking --vmnet-gateway with --vmnet-mask, since set_ipv4_subnet takes the network address (the API reserves the second address of the range for the host).
  • Options that have no effect on this path (--vmnet-dhcp-end, --vmnet-interface-id, --vmnet-network-identifier) emit a warning instead of being silently ignored. The checks run in cli_options_parse before defaults are filled in, so only explicitly passed options warn. (Verified on macOS 26.4 that vmnet_interface_start_with_network assigns its own interface id even when vmnet_interface_id_key is supplied in interface_desc.)

Testing

  • Builds warning-free with -Wall -Wextra -pedantic against the macOS 26 SDK.
  • New e2e test test/test-disable-dhcp.sh, wired into the qemu workflow: boots iPXE through the daemon started with --vmnet-disable-dhcp and asserts that no DHCP lease is offered; the daemon is cleaned up via --pidfile.
  • Manually verified on macOS 26.4 (arm64) that the interface starts successfully on a DHCP-disabled shared network.

Usage

sudo socket_vmnet --vmnet-gateway=192.168.105.1 --vmnet-disable-dhcp /var/run/socket_vmnet

@fpolica91
fpolica91 force-pushed the @chore/support-apple-26 branch from b6652cf to 8ca37c4 Compare June 24, 2026 19:11
@AkihiroSuda

Copy link
Copy Markdown
Member

No description provided.

What's this?

@fpolica91

Copy link
Copy Markdown
Author

No description provided.

What's this?

macOS 26 introduced the vmnet_network_configuration_* API, including vmnet_network_configuration_disable_dhcp(), which disables the DHCP server while keeping shared-mode NAT. (Noted in #139 but intentionally not used there to avoid a 26-only dependency.)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds support for disabling vmnet.framework’s built-in DHCP server on macOS 26+ via a new --vmnet-disable-dhcp CLI flag, and introduces an integration test (plus CI coverage) to validate that guests do not obtain a DHCP lease when DHCP is disabled.

Changes:

  • Add --vmnet-disable-dhcp option to the CLI (parse + help text).
  • Implement a macOS 26+ vmnet start path using the vmnet_network_configuration API with DHCP disabled.
  • Add iPXE/QEMU-based integration test and run it in the GitHub Actions QEMU workflow (skipping on < macOS 26).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
main.c Adds a macOS 26+ vmnet initialization path that disables DHCP using the network configuration API.
cli.h Extends CLI options struct with a vmnet_disable_dhcp flag.
cli.c Adds flag parsing and help text for --vmnet-disable-dhcp.
test/test-disable-dhcp.sh New integration test script that starts socket_vmnet with DHCP disabled and runs QEMU+iPXE to verify no lease is obtained.
test/test-disable-dhcp.ipxe New iPXE script used by the integration test to attempt DHCP and print the resulting IP.
.github/workflows/qemu.yaml Runs the new disable-DHCP integration test in CI (with a macOS 26 runner in the matrix).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main.c
Comment thread main.c Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread main.c
Comment thread test/test-disable-dhcp.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread main.c
Comment thread main.c

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread main.c
Comment thread main.c Outdated
Comment thread test/test-disable-dhcp.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread main.c Outdated
@fpolica91
fpolica91 force-pushed the @chore/support-apple-26 branch 2 times, most recently from 2d13d9f to 83704d9 Compare June 29, 2026 18:22
@fpolica91
fpolica91 requested a review from Copilot June 29, 2026 18:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@fpolica91
fpolica91 force-pushed the @chore/support-apple-26 branch from 83704d9 to a359ea6 Compare June 30, 2026 17:46
@kent-hydra

This comment was marked as low quality.

@AkihiroSuda

Copy link
Copy Markdown
Member

Please squash the commits and fulfill the PR description

Comment thread cli.c Outdated
Comment thread cli.c Outdated
…S 26+)

Add a --vmnet-disable-dhcp flag that starts the interface through the
macOS 26 vmnet_network_configuration API (vmnet_network_create +
vmnet_interface_start_with_network) with the built-in DHCP server
disabled, while keeping shared-mode NAT. This lets an external DHCP/PXE
server own the subnet.

- Guard the new code path at compile time (requires the macOS 26 SDK)
  and at runtime (__builtin_available), erroring out clearly on older
  hosts and SDKs. Invocations without the flag keep using the legacy
  vmnet_start_interface path unchanged.
- Derive the subnet address for
  vmnet_network_configuration_set_ipv4_subnet by masking --vmnet-gateway
  with --vmnet-mask, and validate both values separately (inet_aton does
  not set errno on failure).
- Apply --vmnet-nat66-prefix via
  vmnet_network_configuration_set_ipv6_prefix.
- Warn that --vmnet-dhcp-end, --vmnet-interface-id and
  --vmnet-network-identifier are ignored on this path: no DHCP server is
  started, and the new API has no equivalent for the other two. The
  checks run in cli_options_parse before defaults are filled in, so only
  explicitly passed options warn.
- Name the selected start API in the failure log to ease debugging.
- Add an iPXE-based e2e test (test/test-disable-dhcp.sh) asserting that
  no DHCP lease is offered, wired into the qemu workflow.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: fpolica91 <fabriciopolicarpo0@gmail.com>
@fpolica91
fpolica91 force-pushed the @chore/support-apple-26 branch from a359ea6 to 48ae903 Compare July 15, 2026 17:54
@fpolica91 fpolica91 changed the title support for apple 26 no dhcp Add --vmnet-disable-dhcp to disable the vmnet DHCP server (macOS 26+) Jul 15, 2026
@fpolica91

Copy link
Copy Markdown
Author

Squashed into a single signed-off commit and filled in the PR description. The *_specified fields are removed — the ignored-option warnings now run in cli_options_parse before defaults are filled in (details in the inline replies).

@fpolica91

Copy link
Copy Markdown
Author

@AkihiroSuda I have addressed the comments on this PR. Thank you for taking the time to review, if there is anything else needed please don't hesitate to let me know.

@fpolica91
fpolica91 requested a review from AkihiroSuda July 15, 2026 17:57
@mmiondev

This comment was marked as low quality.

@tjuranek

This comment was marked as low quality.

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.

6 participants