Skip to content

Add privileged container support for FUSE workloads - #41174

Open
Ivanbeethoven wants to merge 8 commits into
microsoft:masterfrom
Ivanbeethoven:codex/privileged-devices
Open

Add privileged container support for FUSE workloads#41174
Ivanbeethoven wants to merge 8 commits into
microsoft:masterfrom
Ivanbeethoven:codex/privileged-devices

Conversation

@Ivanbeethoven

@Ivanbeethoven Ivanbeethoven commented Jul 25, 2026

Copy link
Copy Markdown

Summary

Adds first-class privileged-container support to the WSL Containers command line and SDK path, including the runtime settings needed for FUSE workloads.

Changes

  • Adds the --privileged container option through the command, service, SDK, and session layers.
  • Sends Docker HostConfig.Privileged=true and SecurityOpt=[seccomp=unconfined] for privileged containers.
  • Grants the FUSE device cgroup rule c 10:229 rwm for privileged containers.

Validation

Built the modified WSL components locally and loaded the resulting wslcsdk.dll with a real Windows WSL service. A privileged container reported full capabilities, Seccomp=0, and successfully opened /dev/fuse read/write. BrewFS then established a real FUSE mount backed by Redis and completed fio read/write smoke jobs.

The local Rust SDK integration test was rerun against the final SDK ABI. It passed with Seccomp: 0, /dev/fuse major/minor 10:229, and FUSE_OPEN_OK.

Related downstream work

Add WSLCContainerFlagsPrivileged flag end-to-end:
- docker_schema.h: add Privileged field to HostConfig
- WSLCShared.idl: add WSLCContainerFlagsPrivileged = 128
- wslcsdk.cpp: wire WSLC_CONTAINER_FLAG_PRIVILEGED to runtime
- ContainerModel.h: add Privileged option
- ArgumentDefinitions.h: add --privileged CLI flag
- ContainerCreateCommand.cpp: register --privileged arg
- ContainerTasks.cpp: parse --privileged arg
- ContainerService.cpp: pass privileged to launcher
- WSLCContainerLauncher: add SetPrivileged(bool)
- WSLCContainer.cpp: set Privileged=true on Docker HostConfig

This enables privileged mode containers (required for /dev/fuse, etc.)
via wslc run --privileged or wslc create --privileged.
Copilot AI review requested due to automatic review settings July 25, 2026 11:10
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@Ivanbeethoven
Ivanbeethoven marked this pull request as ready for review July 25, 2026 11:13
@Ivanbeethoven
Ivanbeethoven requested review from a team as code owners July 25, 2026 11:13
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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 privileged-container support to the WSL Containers stack (CLI → service/launcher → session/Docker request), enabling workloads that require elevated capabilities and access to /dev/fuse.

Changes:

  • Introduces a --privileged CLI option and corresponding flags/plumbing through launcher/session layers.
  • Extends the Docker HostConfig schema and request generation to set Privileged=true and SecurityOpt=["seccomp=unconfined"], plus explicit /dev/fuse device mapping.
  • Adds initial scaffolding for a --device CLI option (currently not wired through to the runtime).

Reviewed changes

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

Show a summary per file
File Description
src/windows/wslcsession/WSLCContainer.cpp Sets Docker HostConfig privileged/security options and adds /dev/fuse device mapping when privileged is requested.
src/windows/WslcSDK/wslcsdk.h Updates public SDK container flags to include privileged.
src/windows/WslcSDK/wslcsdk.cpp Extends SDK flag conversion/mask/asserts to include privileged.
src/windows/wslc/tasks/ContainerTasks.cpp Parses --privileged (and --device) into container options.
src/windows/wslc/services/ContainerService.cpp Wires Privileged into the container launcher; notes TODO for devices.
src/windows/wslc/services/ContainerModel.h Adds Privileged and Devices fields to the CLI service model.
src/windows/wslc/commands/ContainerRunCommand.cpp Exposes --privileged / --device on run.
src/windows/wslc/commands/ContainerCreateCommand.cpp Exposes --privileged / --device on create.
src/windows/wslc/arguments/ArgumentDefinitions.h Adds argument definitions for privileged and device.
src/windows/service/inc/WSLCShared.idl Adds internal WSLCContainerFlagsPrivileged and updates valid mask.
src/windows/inc/docker_schema.h Adds HostConfig Privileged/SecurityOpt fields and refactors auth response type definition.
src/windows/common/WSLCContainerLauncher.h Adds launcher API/state for privileged containers.
src/windows/common/WSLCContainerLauncher.cpp Sets the privileged flag into WSLCContainerOptions.Flags.

Comment on lines 35 to 38
_(Device, "device", NO_ALIAS, Kind::Value, L"Add a host device to the container") \
_(Privileged, "privileged", NO_ALIAS, Kind::Flag, L"Run container in privileged mode") \
#define WSLC_ARGUMENTS(_) \
_(All, "all", L"a", Kind::Flag, Localization::WSLCCLI_AllArgDescription()) \
Comment on lines +916 to +920
for (const auto& device : context.Args.GetAll<ArgType::Device>())
{
auto parsed = validation::ParseLabel(WideToMultiByte(device));
options.Devices.emplace_back(parsed.first, parsed.second);
}
Comment on lines +243 to +250
if (options.Privileged)
{
containerLauncher.SetPrivileged(true);
}

// TODO: Wire devices through to SDK when MDL struct is added.
// for (const auto& [hostPath, containerPath] : options.Devices) { ... }

}

// All strings built successfully allocate output array and transfer ownership.
// All strings built successfully �?allocate output array and transfer ownership.
Comment thread src/windows/inc/docker_schema.h Outdated
Comment on lines +297 to +298
// Docker wire type is int64. 0 means "use daemon default" �?same as omitting
// the field �?so we don't bother with std::optional here.
Comment on lines 208 to 215
typedef enum WslcContainerFlags
{
WSLC_CONTAINER_FLAG_NONE = 0x00000000,
WSLC_CONTAINER_FLAG_AUTO_REMOVE = 0x00000001,
WSLC_CONTAINER_FLAG_ENABLE_GPU = 0x00000002,
WSLC_CONTAINER_FLAG_PRIVILEGED = 0x00000004,
WSLC_CONTAINER_FLAG_PRIVILEGED = 0x00000080,

} WslcContainerFlags;
Copilot AI review requested due to automatic review settings July 25, 2026 11:14
@Ivanbeethoven

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@microsoft-github-policy-service agree

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

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

Comments suppressed due to low confidence (3)

src/windows/wslc/arguments/ArgumentDefinitions.h:37

  • WSLC_ARGUMENTS X-macro entries for Device/Privileged are placed before the #define WSLC_ARGUMENTS(_) line, which will expand _( at file scope and break compilation depending on how this header is included.
_(Device,         "device",              NO_ALIAS,          Kind::Value,       L"Add a host device to the container") \
_(Privileged,     "privileged",          NO_ALIAS,          Kind::Flag,        L"Run container in privileged mode") \
#define WSLC_ARGUMENTS(_) \

src/windows/wslcsession/WSLCContainer.cpp:2767

  • The comment text contains mojibake ("�?") which indicates a source-encoding corruption; this should be restored to a normal dash so the comment is readable.
    // All strings built successfully �?allocate output array and transfer ownership.

src/windows/inc/docker_schema.h:298

  • These comments contain mojibake ("�?") instead of a dash, which indicates an encoding/copy-paste issue and reduces readability.
    // Docker wire type is int64. 0 means "use daemon default" �same as omitting
    // the field �so we don't bother with std::optional here.

Comment on lines +35 to +36
_(Device, "device", NO_ALIAS, Kind::Value, L"Add a host device to the container") \
_(Privileged, "privileged", NO_ALIAS, Kind::Flag, L"Run container in privileged mode") \
Comment on lines +914 to +921
if (context.Args.Contains(ArgType::Device))
{
for (const auto& device : context.Args.GetAll<ArgType::Device>())
{
auto parsed = validation::ParseLabel(WideToMultiByte(device));
options.Devices.emplace_back(parsed.first, parsed.second);
}
}
Copilot AI review requested due to automatic review settings July 25, 2026 11:24

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

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

Comments suppressed due to low confidence (1)

src/windows/wslc/arguments/ArgumentDefinitions.h:108

  • The new --privileged argument description is a user-facing string but is not localized (it uses a raw L"..." literal). Most other arguments in this list use Localization::WSLCCLI_*ArgDescription() strings, and the repo’s localization guidance expects new user-visible strings to be added to Resources.resw and surfaced via Localization helpers.
_(Privileged,     "privileged",          NO_ALIAS,          Kind::Flag,        L"Run container in privileged mode") \

Comment on lines +909 to +912
if (context.Args.Contains(ArgType::Privileged))
{
options.Privileged = true;
}
Copilot AI review requested due to automatic review settings July 25, 2026 11:32

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

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

Comments suppressed due to low confidence (1)

src/windows/wslc/arguments/ArgumentDefinitions.h:108

  • The new --privileged argument description is a hard-coded English string, while most other CLI argument descriptions in this file use Localization::WSLCCLI_*ArgDescription() for localizable/help output. This introduces a new user-facing string that won't be localized.
_(Privileged,     "privileged",          NO_ALIAS,          Kind::Flag,        L"Run container in privileged mode") \

Comment thread src/windows/WslcSDK/wslcsdk.cpp Outdated
Comment on lines +85 to +87
constexpr auto s_publicMask = WSLC_CONTAINER_FLAG_AUTO_REMOVE | WSLC_CONTAINER_FLAG_ENABLE_GPU;
auto result = static_cast<WSLCContainerFlags>(flags & s_publicMask);
if (WI_IsFlagSet(flags, WSLC_CONTAINER_FLAG_PRIVILEGED))
Copilot AI review requested due to automatic review settings July 25, 2026 12:18

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

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

Comments suppressed due to low confidence (1)

src/windows/wslc/arguments/ArgumentDefinitions.h:108

  • The new --privileged argument description is a hard-coded English string. Most other arguments use Localization::... descriptions; adding another literal here makes the CLI help non-localizable and inconsistent.
_(Privileged,     "privileged",          NO_ALIAS,          Kind::Flag,        L"Run container in privileged mode") \

Comment thread test/windows/wslc/WSLCCLIExecutionUnitTests.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 26, 2026 12:08

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

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

Comments suppressed due to low confidence (1)

src/windows/wslc/arguments/ArgumentDefinitions.h:109

  • The new --privileged argument description is a hard-coded string literal instead of using the existing Localization::WSLCCLI_*ArgDescription() pattern used by other CLI arguments. This introduces a new user-facing string without a localization resource entry.
_(Publish,        "publish",             L"p",              Kind::Value,       Localization::WSLCCLI_PublishArgDescription()) \
_(PublishAll,     "publish-all",         L"P",              Kind::Flag,        Localization::WSLCCLI_PublishAllArgDescription()) \
_(Privileged,     "privileged",          NO_ALIAS,          Kind::Flag,        L"Run container in privileged mode") \
/*_(Pull,           "pull",                NO_ALIAS,          Kind::Value,       Localization::WSLCCLI_PullArgDescription())*/ \

Comment on lines 338 to 342
options.StopSignal = m_stopSignal;
options.Flags = m_containerFlags;
if (m_privileged) { WI_SetFlag(options.Flags, WSLCContainerFlagsPrivileged); }
if (m_stopTimeout.has_value())
{
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