Skip to content

feature/hyperv-api-backend: VM & VM Factory Implementation #4080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 76 commits into
base: feature/hyperv-api-backend-hcs-hcn
Choose a base branch
from

Conversation

xmkg
Copy link
Member

@xmkg xmkg commented May 8, 2025

No description provided.

xmkg added 30 commits May 8, 2025 22:52
…nt settings

It's a remnant from the original WSL2 traces. It works just as fine without the IpConfigurations settings.
- [vm] take network guid as a constructor argument
- [vm] add ability to resolve hostname to retrieve IP address
- [vm-start] distinguish between paused and stopped state and act accordingly
- [vm-stop] take ShutdownPolicy into consideration
- [vm-ssh-hostname] return the automatic ".mshome.net" hostname
- [vm-ipv4-ipv6] return the resolved ip's for .mshome.net hostname

Signed-off-by: Mustafa Kemal Gilor <[email protected]>
resolve_ip_addresses: simplify the wsa_init_wrapper
Hyper-V API has been the umbrella term to call the technology behind
this feature, but it might be misleading because there's actually a
real Hyper-V API and the feature does not use that. Instead, the feature
utilizes Host Compute System and Host Compute Network API's.

It's better to call this backend as what it actually is.
- api wrappers are now constructed at factory
- factory and vm now use the interface types instead of concrete wrappers
- switched to <> style includes
- moved exception types to hcs_virtual_machine_exception.h
Implement the host-side of the Plan9 shares. It needs an agent to be
running on the guest system, which will be implemented later.

Add support for the graceful shutdown using guest hv_utils linux kernel
driver, if present.
There are nothing to remove since everything is neatly packed into
the instance folder. Removal of the instance folder is already taken
care of by the base class, so only thing left is to ensure that the
compute system is terminated.

Set log level of open_compute_system failure and operation_failure
to debug() instead of error() since these functions may fail in normal
operation workflow (i.e. check if a VM exists).
simple implementation, vhdx clone only.

- [hcs_api_wrapper] normalize file paths for api calls
- [virtdisk_wrapper] enable clone functionality for CreateVirtualDisk
Re-implement the get_network_interfaces_info using native API in order
to avoid relying on Powershell.
MSVC has started to complain, which is fixed by passing the /bigobj flag.

C:\multipass-private\build\gen\multipass\rpc\multipass.grpc.pb.cc :
fatal error C1128: number of sections exceeded object file format limit:
compile with /bigobj
the create_network implementation was only good for spawning ICS networks
which is not sufficient for other needs, such as creating a transparent
network.

the following changes has been made in order to properly handle creation
of different kind of networks:

- Added the following types, representing HCN network object structure:
  - HcnNetworkType
  - HcnIpam
  - HcnIpamType
  - HcnNetworkPolicy
  - HcnSubnet
  - HcnNetworkFlags
  - HcnNetworkPolicyNetAdapterName
  - HcnNetworkPolicyType
  - HcnRoute
- The code now uses "ipams" style network declarations
- Added proper formatter/renderers for the new types
- Updated the test code
- Switched to named format arguments
xmkg added 11 commits May 8, 2025 22:52
- move GUID formatter to the platform_win.h header
- update unit test usages
- Introduce two new types, HcsScsiDevice & HcsScsiDeviceType
- Provide proper formatting for the HcsScsiDevice
- Remove vhdx_path & cloudinit_iso_path variables from create params
- Introduce scsi_devices paraneter to create params
- Update the code that refers to the vhdx_path & cloudinit_iso_path
- replace "endpoints" with "network_adapters" in create params
- Introduce new HcsNetworkAdapter type
- Implement proper JSON formatter for HcsNetworkAdapter
- Update relevant references in code
- add_endpoint function now takes compute system name as the rest of
  the API does
- Updated code references
Copy link

codecov bot commented May 8, 2025

Codecov Report

Attention: Patch coverage is 42.85714% with 8 lines in your changes missing coverage. Please review.

Project coverage is 89.45%. Comparing base (02c7448) to head (2de0b22).

Files with missing lines Patch % Lines
src/utils/file_ops.cpp 20.00% 8 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                           @@
##           feature/hyperv-api-backend-hcs-hcn    #4080      +/-   ##
======================================================================
- Coverage                               89.50%   89.45%   -0.05%     
======================================================================
  Files                                     259      259              
  Lines                                   14740    14749       +9     
======================================================================
+ Hits                                    13193    13194       +1     
- Misses                                   1547     1555       +8     

☔ View full report in Codecov by Sentry.
📢 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.

xmkg added 4 commits May 9, 2025 12:25
to simplify the interaction between the smart pointers and the C API
a lean out_ptr type is implemented based on P1132R6 paper, which is
already accepted into the C++23 standard.

- open_host_compute_system and create_host_compute system now uses the
  out_ptr to avoid creating a temporary raw pointer for the API calls.
- update one more location that has been missed
@xmkg xmkg force-pushed the feature/hyperv-api-backend-virtual-machine branch from 4bf7b08 to 4c503b2 Compare May 9, 2025 13:59
@xmkg xmkg force-pushed the feature/hyperv-api-backend-virtual-machine branch from 7170db6 to 5707e3a Compare May 15, 2025 14:50
@xmkg xmkg force-pushed the feature/hyperv-api-backend-virtual-machine branch from 1235fb8 to 28ea377 Compare May 15, 2025 15:01
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.

1 participant