-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add openvmm as vmm backend option for wslc vms #40629
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
Daman Mulye (damanm24)
wants to merge
10
commits into
master
Choose a base branch
from
user/damanmulye/rfc-wslc-openvmm
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4d3fa5c
Add openvmm as vmm option for wslc vms
damanm24 b2bad50
Get rid of TCP relay sockets
damanm24 6a9a01f
logging fix
damanm24 0f89042
bump nuget package
damanm24 74b18c9
implement add share and improve local development story
damanm24 73eab49
test fixes
damanm24 4b40714
Make testing easier with openvmm
damanm24 c66c9ad
Use dll from hvlite to interface with openvmm
damanm24 0e92b20
Avoid using COM
damanm24 360b435
Remove unnecessary changes
damanm24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -670,6 +670,94 @@ void HandleMessageImpl( | |
| Transaction.SendResultMessage(result < 0 ? errno : 0); | ||
| } | ||
|
|
||
| void HandleMessageImpl( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we probably want to use the existing GNS implementation to do network configuration. it should support all of this stuff. |
||
| wsl::shared::SocketChannel& Channel, | ||
| wsl::shared::Transaction& Transaction, | ||
| const WSLC_CONFIGURE_NETWORKING& Message, | ||
| const gsl::span<gsl::byte>& Buffer) | ||
| { | ||
| int result = -EINVAL; | ||
| auto sendResult = wil::scope_exit([&]() { Transaction.SendResultMessage<int32_t>(result); }); | ||
|
|
||
| const auto* iface = wsl::shared::string::FromSpan(Buffer, Message.InterfaceOffset); | ||
| const auto* address = wsl::shared::string::FromSpan(Buffer, Message.AddressOffset); | ||
| const auto* gateway = wsl::shared::string::FromSpan(Buffer, Message.GatewayOffset); | ||
| const auto* dnsServer = wsl::shared::string::FromSpan(Buffer, Message.DnsServerOffset); | ||
|
|
||
| THROW_ERRNO_IF(EINVAL, iface == nullptr || address == nullptr || gateway == nullptr || dnsServer == nullptr); | ||
|
|
||
| // Bring up the interface and configure the static address, route, and DNS. | ||
| auto configCmd = std::format( | ||
| "ip link set {} up && ip addr add {} dev {} && ip route add default via {}", | ||
| iface, address, iface, gateway); | ||
|
|
||
| // Use a pipe to detect child completion. The child inherits the write end; | ||
| // when it exits (via execl or _exit), the write end is closed and read() | ||
| // returns 0. This avoids racing with the WSLC_WATCH_PROCESSES handler's | ||
| // waitpid(-1) which may reap the child before we can. | ||
| int pipeFds[2]{}; | ||
| THROW_LAST_ERROR_IF(pipe2(pipeFds, O_CLOEXEC) < 0); | ||
| wil::unique_fd pipeRead{pipeFds[0]}; | ||
| wil::unique_fd pipeWrite{pipeFds[1]}; | ||
|
|
||
| int childPid = UtilCreateChildProcess("ConfigureNetworking", [&configCmd, &pipeWrite]() { | ||
| // Clear CLOEXEC on the write end so it stays open across execl. | ||
| // When the shell exits, the fd is closed and the parent's read returns. | ||
| fcntl(pipeWrite.get(), F_SETFD, 0); | ||
| execl("/bin/sh", "/bin/sh", "-c", configCmd.c_str(), nullptr); | ||
| LOG_ERROR("execl(/bin/sh) failed, {}", errno); | ||
| }); | ||
|
|
||
| // Close the write end in the parent — only the child holds it now. | ||
| pipeWrite.reset(); | ||
|
|
||
| if (childPid < 0) | ||
| { | ||
| result = -errno; | ||
| return; | ||
| } | ||
|
|
||
| // Wait for the child to exit by reading from the pipe. When the child | ||
| // (and the shell it exec'd) exits, all write ends are closed and read | ||
| // returns 0. | ||
| char dummy{}; | ||
| TEMP_FAILURE_RETRY(read(pipeRead.get(), &dummy, sizeof(dummy))); | ||
|
|
||
| // Try to reap the child. If WSLC_WATCH_PROCESSES already reaped it, we | ||
| // get ECHILD which is fine — the pipe close confirms the child exited. | ||
| int status = -1; | ||
| if (TEMP_FAILURE_RETRY(waitpid(childPid, &status, 0)) < 0) | ||
| { | ||
| if (errno == ECHILD) | ||
| { | ||
| // Child was already reaped by the WatchProcesses handler. | ||
| // The pipe confirmed it exited, so treat as success. | ||
| status = 0; | ||
| } | ||
| else | ||
|
Comment on lines
+726
to
+737
|
||
| { | ||
| result = -errno; | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| result = UtilProcessChildExitCode(status, "ConfigureNetworking"); | ||
| if (result != 0) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // Write DNS configuration. | ||
| auto resolv = std::format("nameserver {}\n", dnsServer); | ||
| if (WriteToFile("/etc/resolv.conf", resolv.c_str()) < 0) | ||
| { | ||
| result = -errno; | ||
| return; | ||
| } | ||
|
|
||
| result = 0; | ||
| } | ||
|
|
||
| void HandleMessageImpl(wsl::shared::SocketChannel& Channel, wsl::shared::Transaction& Transaction, const WSLC_UNMOUNT&, const gsl::span<gsl::byte>& Buffer) | ||
| { | ||
| auto* path = wsl::shared::string::FromMessageBuffer<WSLC_UNMOUNT>(Buffer); | ||
|
|
@@ -831,7 +919,7 @@ void ProcessMessage(wsl::shared::SocketChannel& Channel, wsl::shared::Transactio | |
| { | ||
| try | ||
| { | ||
| HandleMessage<WSLC_GET_DISK, WSLC_MOUNT, WSLC_EXEC, WSLC_FORK, WSLC_CONNECT, WSLC_SIGNAL, WSLC_TTY_RELAY, WSLC_PORT_RELAY, WSLC_UNMOUNT, WSLC_DETACH, WSLC_ACCEPT, WSLC_WATCH_PROCESSES, WSLC_UNIX_CONNECT>( | ||
| HandleMessage<WSLC_GET_DISK, WSLC_MOUNT, WSLC_EXEC, WSLC_FORK, WSLC_CONNECT, WSLC_SIGNAL, WSLC_TTY_RELAY, WSLC_PORT_RELAY, WSLC_UNMOUNT, WSLC_DETACH, WSLC_ACCEPT, WSLC_WATCH_PROCESSES, WSLC_UNIX_CONNECT, WSLC_CONFIGURE_NETWORKING>( | ||
| Channel, Transaction, Type, Buffer); | ||
| } | ||
| catch (...) | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wsldevicehost.dll should be included all the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe that's an existing issue?