Skip to content

Feature/hostname resolution scaffolding win#4992

Draft
xmkg wants to merge 10 commits into
mainfrom
feature/hostname-resolution-scaffolding-win
Draft

Feature/hostname resolution scaffolding win#4992
xmkg wants to merge 10 commits into
mainfrom
feature/hostname-resolution-scaffolding-win

Conversation

@xmkg

@xmkg xmkg commented Jun 25, 2026

Copy link
Copy Markdown
Member

TBD

xmkg added 10 commits June 25, 2026 12:06
Let the host resolve "<instance>.multipass" to a guest's current IP,
without changing the global ICSDomain or running a resolver process.

The guest advertises a dotted DHCP hostname so the ICS proxy stores it as
"<instance>.multipass.mshome.net". The host appends "mshome.net" to the
typed name and a narrow NRPT rule sends ".multipass.mshome.net" queries to
the gateway proxy.

Add an NrptRule RAII type that writes the rule to the NRPT registry and
removes it on destruction, wire it into the build, and add an integration
test that boots Alpine and checks resolution end to end.

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

Adds Windows/Hyper-V DNS resolution scaffolding by introducing explicit HCN DNS configuration support (creation + query parsing) and an NRPT rule RAII helper, along with cloud-init fixtures and end-to-end/component integration tests that exercise hostname/FQDN resolution paths through ICS.

Changes:

  • Add HcnDns model + formatting, allow optional "Dns" block in HCN network creation JSON, and parse flattened DNS fields on HCN query (networks + endpoints).
  • Add NrptRule RAII helper for writing/removing local NRPT rules via the registry (and link required Windows libs).
  • Add new cloud-init fixtures and expand Hyper-V “big bang” integration tests to validate DNS suffix + NRPT-based name resolution behavior.

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/unit/test_data/cloud-init-fqdn-multipass/README.md Documents runtime-generated NoCloud seed approach for dotted DHCP hostname tests.
tests/unit/test_data/cloud-init-fqdn-multipass/make_seed_iso.py Generates NoCloud seed ISO at runtime for unique dotted DHCP hostname (pycdlib-based).
tests/unit/test_data/cloud-init-dhcp-hostname/user-data Cloud-init config to re-run udhcpc with option-12 hostname advertising.
tests/unit/test_data/cloud-init-dhcp-hostname/README.md Documents committed ISO fixture purpose and regeneration steps.
tests/unit/test_data/cloud-init-dhcp-hostname/meta-data Sets guest local-hostname for DHCP-hostname integration test.
tests/unit/hyperv_api/test_ut_hyperv_hcn_dns.cpp Unit tests for HcnDns JSON formatting (narrow/wide/empty lists).
tests/unit/hyperv_api/test_ut_hyperv_hcn_api.cpp Adds unit test verifying "Dns" object is emitted in created network config JSON.
tests/unit/hyperv_api/test_it_hyperv_hcn_api.cpp Integration coverage for network/endpoint DNS query results and inheritance.
tests/unit/hyperv_api/test_bb_cit_hyperv.cpp Adds end-to-end tests for ICS/NRPT/hostname resolution and runtime ISO generation.
tests/unit/hyperv_api/mock_hyperv_hcn_api.h Extends mock API with HcnQueryEndpointProperties.
tests/unit/hyperv_api/CMakeLists.txt Adds new test_ut_hyperv_hcn_dns.cpp to Windows unit tests build.
src/platform/backends/hyperv_api/hcn/hyperv_hcn_wrapper.h Adds endpoint query API and includes endpoint info type.
src/platform/backends/hyperv_api/hcn/hyperv_hcn_wrapper.cpp Implements endpoint query + flattened DNS parsing; adds DNS parsing to network query.
src/platform/backends/hyperv_api/hcn/hyperv_hcn_network_info.h Extends network info with optional DNS settings.
src/platform/backends/hyperv_api/hcn/hyperv_hcn_endpoint_info.h New endpoint info struct including inherited DNS settings.
src/platform/backends/hyperv_api/hcn/hyperv_hcn_dns.h New HcnDns type + fmt formatter declaration.
src/platform/backends/hyperv_api/hcn/hyperv_hcn_dns.cpp Implements fmt formatting for HcnDns.
src/platform/backends/hyperv_api/hcn/hyperv_hcn_create_network_params.h Adds optional dns field to network creation parameters.
src/platform/backends/hyperv_api/hcn/hyperv_hcn_create_network_params.cpp Emits "Dns" fragment only when params.dns is set.
src/platform/backends/hyperv_api/hcn/hyperv_hcn_api.h Adds HcnQueryEndpointProperties API surface.
src/platform/backends/hyperv_api/hcn/hyperv_hcn_api.cpp Wires HcnQueryEndpointProperties to the underlying Win32 API call.
src/platform/backends/hyperv_api/dns/nrpt_rule.h New RAII type for local NRPT registry rules.
src/platform/backends/hyperv_api/dns/nrpt_rule.cpp Implements NRPT registry write/remove logic + GUID generation.
src/platform/backends/hyperv_api/CMakeLists.txt Adds new source files and links advapi32/rpcrt4.

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

Comment on lines +32 to +36
#include <algorithm>
#include <chrono>
#include <cstdio>
#include <filesystem>
#include <fstream>
Comment on lines +66 to +71
std::ofstream out(output, std::ios::binary);
for (const auto& part : parts)
{
std::ifstream in(part, std::ios::binary);
out << in.rdbuf();
}
Comment on lines +791 to +794
(void)run_powershell(fmt::format(
"Set-DnsClientGlobalSetting -SuffixSearchList @('{}'); "
"Set-ItemProperty -Path '{}' -Name AppendToMultiLabelName -Value 1 -Type DWord",
append_suffix, dnscache_key));
Comment on lines +813 to +816
else
(void)run_powershell(fmt::format(
"Set-ItemProperty -Path '{}' -Name AppendToMultiLabelName -Value {} -Type DWord",
suffix_key, saved_amln));
Comment on lines +922 to +926
return run_powershell(fmt::format(
"(Resolve-DnsName -Name {} -Type A -QuickTimeout "
"-ErrorAction SilentlyContinue | Where-Object {{ $_.Type -eq 'A' }}).IPAddress "
"-join ','",
name));
Comment on lines +860 to +869
const auto script =
fmt::format("{}/cloud-init-fqdn-multipass/make_seed_iso.py", test_data_path);
const std::filesystem::path& iso_ref = cloud_init_iso_path;
const auto build_out = run_powershell(
fmt::format("python '{}' --hostname '{}' --output '{}' 2>&1",
script,
guest_hostname,
iso_ref.string()));
ASSERT_TRUE(std::filesystem::exists(iso_ref)) << "seed ISO build failed: " << build_out;
}
Comment on lines +221 to +225
if (suffix)
dns.search = multipass::utils::split(suffix->as_string().c_str(), ",");
if (servers)
dns.server_list = multipass::utils::split(servers->as_string().c_str(), ",");
return dns;
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.60%. Comparing base (e9770ac) to head (4c3d671).
⚠️ Report is 25 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4992      +/-   ##
==========================================
- Coverage   87.77%   87.60%   -0.16%     
==========================================
  Files         273      274       +1     
  Lines       14685    14649      -36     
==========================================
- Hits        12888    12832      -56     
- Misses       1797     1817      +20     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants