Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 31, 2025

Summary of the Pull Request

Refactors VHD boot disk device path storage from std::pair<std::optional<ULONG>, std::optional<std::string>> to std::variant<ULONG, std::string> for improved type safety and clarity.

PR Checklist

  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

The rootVhd and modulesVhd variables store either a SCSI LUN (ULONG) or PMEM device path (string), but never both. The previous implementation used std::pair<std::optional<ULONG>, std::optional<std::string>> with runtime assertions to enforce mutual exclusivity.

Changes:

  • Replace pair type with std::variant<ULONG, std::string>
  • Remove runtime assertion - type system now guarantees correctness
  • Implement visitor pattern with explicit overloads for device path resolution:
auto getVhdDevicePath = [&](const std::variant<ULONG, std::string>& vhd) {
    struct Visitor {
        WSLAVirtualMachine* vm;
        
        std::string operator()(ULONG lun) const {
            return vm->GetVhdDevicePath(lun);
        }
        
        std::string operator()(const std::string& path) const {
            return path;
        }
    };
    
    return std::visit(Visitor{this}, vhd);
};

Validation Steps Performed

Code formatted with clang-format and reviewed for correctness. Full Windows build validation deferred to CI.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits December 31, 2025 18:59
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback on VHD boot disk and PMEM implementation Use std::variant for VHD device path storage instead of std::pair with optionals Dec 31, 2025
Copilot AI requested a review from benhillis December 31, 2025 19:04
@benhillis benhillis closed this Dec 31, 2025
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