| 1 | /*++ |
| 2 | |
| 3 | Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | |
| 5 | Module Name: |
| 6 | |
| 7 | WSLCCompat.idl |
| 8 | |
| 9 | Abstract: |
| 10 | |
| 11 | This file contains the WSLC SDK-facing COM object definitions. |
| 12 | Changes in this file must maintain backwards compatibility |
| 13 | |
| 14 | --*/ |
| 15 | |
| 16 | import "unknwn.idl"; |
| 17 | import "wtypes.idl"; |
| 18 | |
| 19 | // Enums and flags shared with the service API (wslc.idl). |
| 20 | import "WSLCShared.idl"; |
| 21 | |
| 22 | cpp_quote("#ifdef __cplusplus") |
| 23 | cpp_quote("class DECLSPEC_UUID(\"a9b7a1b9-0671-405c-95f1-e0612cb4ce8f\") WSLCCompatSessionManager;") |
| 24 | cpp_quote("class DECLSPEC_UUID(\"9fcd2067-9fc6-4efa-9eb0-698169ebf7d3\") WSLCCompatSessionManagerFactory;") |
| 25 | cpp_quote("#endif") |
| 26 | |
| 27 | #define WSLCCompat_MAX_IMAGE_NAME_LENGTH 255 |
| 28 | #define WSLCCompat_MAX_VOLUME_NAME_LENGTH 255 |
| 29 | #define WSLCCompat_MAX_VOLUME_DRIVER_LENGTH 255 |
| 30 | #define WSLCCompat_CONTAINER_ID_LENGTH 64 |
| 31 | #define WSLCCompat_MAX_BINDING_ADDRESS_LENGTH 45 |
| 32 | |
| 33 | typedef |
| 34 | struct _WSLCCompatVersion { |
| 35 | ULONG Major; |
| 36 | ULONG Minor; |
| 37 | ULONG Revision; |
| 38 | } WSLCCompatVersion; |
| 39 | |
| 40 | [ |
| 41 | uuid(EAA15E20-7FCC-485B-B798-ED4095DBACA5), |
| 42 | pointer_default(unique), |
| 43 | object |
| 44 | ] |
| 45 | interface IWSLCCompatCrashDumpCallback : IUnknown |
| 46 | { |
| 47 | HRESULT OnCrashDump( |
| 48 | [in, string] LPCWSTR DumpPath, |
| 49 | [in, unique, string] LPCSTR ProcessName, |
| 50 | [in] ULONG Pid, |
| 51 | [in] ULONG Signal, |
| 52 | [in] ULONGLONG Timestamp); |
| 53 | }; |
| 54 | |
| 55 | [ |
| 56 | uuid(06154F2A-ACA7-461E-94FC-92781BA1F6F6), |
| 57 | pointer_default(unique), |
| 58 | object |
| 59 | ] |
| 60 | interface IWSLCCompatProgressCallback : IUnknown |
| 61 | { |
| 62 | HRESULT OnProgress(LPCSTR Status, LPCSTR Id, ULONGLONG Current, ULONGLONG Total); |
| 63 | }; |
| 64 | |
| 65 | [ |
| 66 | uuid(290C58A1-328C-4E90-B09B-0A9D32C40074), |
| 67 | pointer_default(unique), |
| 68 | object |
| 69 | ] |
| 70 | interface IWSLCCompatWarningCallback : IUnknown |
| 71 | { |
| 72 | HRESULT OnWarning([in, string] LPCWSTR Message); |
| 73 | }; |
| 74 | |
| 75 | typedef struct _WSLCCompatImageInformation |
| 76 | { |
| 77 | char Image[WSLCCompat_MAX_IMAGE_NAME_LENGTH + 1]; |
| 78 | char Hash[256]; |
| 79 | char Digest[256]; |
| 80 | LONGLONG Size; // Matches Docker's int64 image size |
| 81 | LONGLONG Created; // Unix timestamp |
| 82 | char ParentId[256]; |
| 83 | } WSLCCompatImageInformation; |
| 84 | |
| 85 | typedef struct _WSLCCompatKeyValuePair |
| 86 | { |
| 87 | [string] LPCSTR Key; |
| 88 | [string] LPCSTR Value; |
| 89 | } WSLCCompatKeyValuePair; |
| 90 | |
| 91 | typedef WSLCCompatKeyValuePair WSLCCompatLabel; |
| 92 | typedef WSLCCompatKeyValuePair WSLCCompatDriverOption; |
| 93 | typedef WSLCCompatKeyValuePair WSLCCompatFilter; |
| 94 | |
| 95 | typedef struct _WSLCCompatListImagesOptions |
| 96 | { |
| 97 | DWORD Flags; // WSLCListImagesFlags (can combine with bitwise OR) |
| 98 | [unique, size_is(FiltersCount)] const WSLCCompatFilter* Filters; |
| 99 | ULONG FiltersCount; |
| 100 | } WSLCCompatListImagesOptions; |
| 101 | |
| 102 | typedef struct _WSLCCompatStringArray |
| 103 | { |
| 104 | [unique, size_is(Count)] LPCSTR const* Values; |
| 105 | ULONG Count; |
| 106 | } WSLCCompatStringArray; |
| 107 | |
| 108 | typedef struct _WSLCCompatProcessOptions |
| 109 | { |
| 110 | [unique] LPCSTR CurrentDirectory; |
| 111 | [unique] LPCSTR User; |
| 112 | WSLCCompatStringArray CommandLine; |
| 113 | WSLCCompatStringArray Environment; |
| 114 | WSLCProcessFlags Flags; |
| 115 | } WSLCCompatProcessOptions; |
| 116 | |
| 117 | typedef struct _WSLCCompatNamedVolume |
| 118 | { |
| 119 | LPCSTR Name; |
| 120 | LPCSTR ContainerPath; |
| 121 | BOOL ReadOnly; |
| 122 | } WSLCCompatNamedVolume; |
| 123 | |
| 124 | typedef struct _WSLCCompatVolume |
| 125 | { |
| 126 | LPCWSTR HostPath; |
| 127 | LPCSTR ContainerPath; |
| 128 | BOOL ReadOnly; |
| 129 | } WSLCCompatVolume; |
| 130 | |
| 131 | typedef struct _WSLCCompatPortMapping |
| 132 | { |
| 133 | USHORT HostPort; |
| 134 | USHORT ContainerPort; |
| 135 | int Family; |
| 136 | int Protocol; |
| 137 | char BindingAddress[WSLCCompat_MAX_BINDING_ADDRESS_LENGTH + 1]; |
| 138 | } WSLCCompatPortMapping; |
| 139 | |
| 140 | typedef struct _WSLCCompatTmpfsMount |
| 141 | { |
| 142 | LPCSTR Destination; |
| 143 | [unique] LPCSTR Options; |
| 144 | } WSLCCompatTmpfsMount; |
| 145 | |
| 146 | typedef struct _WSLCCompatUlimit |
| 147 | { |
| 148 | [string] LPCSTR Name; |
| 149 | LONGLONG Soft; |
| 150 | LONGLONG Hard; |
| 151 | } WSLCCompatUlimit; |
| 152 | |
| 153 | typedef struct _WSLCCompatNetworkConnection |
| 154 | { |
| 155 | [string] LPCSTR NetworkName; |
| 156 | [unique, size_is(SettingsCount)] const WSLCCompatKeyValuePair* Settings; |
| 157 | ULONG SettingsCount; |
| 158 | } WSLCCompatNetworkConnection; |
| 159 | |
| 160 | typedef struct _WSLCCompatContainerNetwork |
| 161 | { |
| 162 | [unique, string] LPCSTR NetworkMode; |
| 163 | |
| 164 | [unique, size_is(NetworksCount)] const WSLCCompatNetworkConnection* Networks; |
| 165 | ULONG NetworksCount; |
| 166 | } WSLCCompatContainerNetwork; |
| 167 | |
| 168 | typedef struct _WSLCCompatContainerOptions |
| 169 | { |
| 170 | LPCSTR Image; |
| 171 | [unique] LPCSTR Name; |
| 172 | WSLCCompatStringArray Entrypoint; |
| 173 | WSLCCompatProcessOptions InitProcessOptions; |
| 174 | [unique, size_is(VolumesCount)] WSLCCompatVolume* Volumes; |
| 175 | ULONG VolumesCount; |
| 176 | [unique, size_is(PortsCount)] WSLCCompatPortMapping* Ports; |
| 177 | ULONG PortsCount; |
| 178 | [unique, size_is(LabelsCount)] const WSLCCompatLabel* Labels; |
| 179 | ULONG LabelsCount; |
| 180 | WSLCContainerFlags Flags; |
| 181 | WSLCSignal StopSignal; |
| 182 | [unique] LPCSTR HostName; |
| 183 | [unique] LPCSTR DomainName; |
| 184 | |
| 185 | WSLCCompatStringArray DnsServers; |
| 186 | WSLCCompatStringArray DnsSearchDomains; |
| 187 | WSLCCompatStringArray DnsOptions; |
| 188 | |
| 189 | LONGLONG ShmSize; |
| 190 | WSLCCompatContainerNetwork ContainerNetwork; |
| 191 | [unique, size_is(TmpfsCount)] const WSLCCompatTmpfsMount* Tmpfs; |
| 192 | ULONG TmpfsCount; |
| 193 | |
| 194 | [unique, size_is(NamedVolumesCount)] WSLCCompatNamedVolume* NamedVolumes; |
| 195 | ULONG NamedVolumesCount; |
| 196 | |
| 197 | LONGLONG MemoryBytes; |
| 198 | LONGLONG NanoCpus; |
| 199 | [unique, size_is(UlimitsCount)] const WSLCCompatUlimit* Ulimits; |
| 200 | ULONG UlimitsCount; |
| 201 | } WSLCCompatContainerOptions; |
| 202 | |
| 203 | typedef char WSLCCompatContainerId[WSLCCompat_CONTAINER_ID_LENGTH + 1]; |
| 204 | |
| 205 | typedef [system_handle(sh_file)] HANDLE WSLCCompatFileHandle; |
| 206 | typedef [system_handle(sh_pipe)] HANDLE WSLCCompatPipeHandle; |
| 207 | typedef [system_handle(sh_socket)] HANDLE WSLCCompatSocketHandle; |
| 208 | |
| 209 | typedef struct _WSLCCompatHandle |
| 210 | { |
| 211 | WSLCHandleType Type; |
| 212 | |
| 213 | [switch_type(WSLCHandleType), switch_is(Type)] |
| 214 | union |
| 215 | { |
| 216 | [case(WSLCHandleTypeFile)] |
| 217 | WSLCCompatFileHandle File; |
| 218 | [case(WSLCHandleTypePipe)] |
| 219 | WSLCCompatPipeHandle Pipe; |
| 220 | [case(WSLCHandleTypeSocket)] |
| 221 | WSLCCompatSocketHandle Socket; |
| 222 | [default]; |
| 223 | } Handle; |
| 224 | } WSLCCompatHandle; |
| 225 | |
| 226 | [ |
| 227 | uuid(AC69DD0D-6616-4C4F-91F2-C39D6034EA82), |
| 228 | pointer_default(unique), |
| 229 | object |
| 230 | ] |
| 231 | interface IWSLCCompatProcess : IUnknown |
| 232 | { |
| 233 | HRESULT Signal([in] int Signal); |
| 234 | HRESULT GetExitEvent([out, system_handle(sh_event)] HANDLE* EventHandle); |
| 235 | HRESULT GetStdHandle([in] WSLCFD Fd, [out] WSLCCompatHandle* Handle); |
| 236 | HRESULT GetPid([out] int* Pid); |
| 237 | HRESULT GetState([out] WSLCProcessState* State, [out] int* Code); |
| 238 | } |
| 239 | |
| 240 | typedef struct _WSLCCompatSessionSettings { |
| 241 | LPCWSTR DisplayName; |
| 242 | LPCWSTR StoragePath; |
| 243 | ULONGLONG MaximumStorageSizeMb; |
| 244 | ULONG CpuCount; |
| 245 | ULONG MemoryMb; |
| 246 | ULONG BootTimeoutMs; |
| 247 | WSLCNetworkingMode NetworkingMode; |
| 248 | WSLCFeatureFlags FeatureFlags; |
| 249 | WSLCCompatHandle DmesgOutput; |
| 250 | WSLCSessionStorageFlags StorageFlags; |
| 251 | |
| 252 | // Below options are used for debugging purposes only. |
| 253 | [unique] LPCWSTR RootVhdOverride; |
| 254 | [unique] LPCSTR RootVhdTypeOverride; |
| 255 | } WSLCCompatSessionSettings; |
| 256 | |
| 257 | [ |
| 258 | uuid(8C3C91FA-D550-41B9-AD9D-23DCBF96F549), |
| 259 | pointer_default(unique), |
| 260 | object |
| 261 | ] |
| 262 | interface IWSLCCompatContainer : IUnknown |
| 263 | { |
| 264 | HRESULT Stop([in] WSLCSignal Signal, [in] LONG TimeoutSeconds); |
| 265 | HRESULT Start([in] WSLCContainerStartFlags Flags); |
| 266 | HRESULT Delete([in] WSLCDeleteFlags Flags); |
| 267 | HRESULT GetState([out] WSLCContainerState* State); |
| 268 | HRESULT GetInitProcess([out] IWSLCCompatProcess** Process); |
| 269 | HRESULT Exec([in, ref] const WSLCCompatProcessOptions* Options, [out] IWSLCCompatProcess** Process); |
| 270 | HRESULT Inspect([out] LPSTR* Output); |
| 271 | HRESULT GetId([out, string] WSLCCompatContainerId Id); |
| 272 | } |
| 273 | |
| 274 | typedef struct _WSLCCompatDeletedImageInformation |
| 275 | { |
| 276 | char Image[WSLCCompat_MAX_IMAGE_NAME_LENGTH + 1]; |
| 277 | WSLCDeletedImageType Type; |
| 278 | } WSLCCompatDeletedImageInformation; |
| 279 | |
| 280 | typedef struct _WSLCCompatDeleteImageOptions |
| 281 | { |
| 282 | LPCSTR Image; // Image can be ID or Repo:Tag. |
| 283 | DWORD Flags; // WSLCDeleteImageFlags |
| 284 | } WSLCCompatDeleteImageOptions; |
| 285 | |
| 286 | typedef struct _WSLCCompatTagImageOptions |
| 287 | { |
| 288 | LPCSTR Image; // Source image name or ID. |
| 289 | LPCSTR Repo; // Target repository name. |
| 290 | LPCSTR Tag; // Target tag name. |
| 291 | } WSLCCompatTagImageOptions; |
| 292 | |
| 293 | typedef struct _WSLCCompatVolumeOptions |
| 294 | { |
| 295 | [unique] LPCSTR Name; |
| 296 | [unique] LPCSTR Driver; |
| 297 | [unique, size_is(DriverOptsCount)] const WSLCCompatDriverOption* DriverOpts; |
| 298 | ULONG DriverOptsCount; |
| 299 | [unique, size_is(LabelsCount)] const WSLCCompatLabel* Labels; |
| 300 | ULONG LabelsCount; |
| 301 | } WSLCCompatVolumeOptions; |
| 302 | |
| 303 | typedef char WSLCCompatVolumeName[WSLCCompat_MAX_VOLUME_NAME_LENGTH + 1]; |
| 304 | |
| 305 | typedef struct _WSLCCompatVolumeInformation |
| 306 | { |
| 307 | WSLCCompatVolumeName Name; |
| 308 | char Driver[WSLCCompat_MAX_VOLUME_DRIVER_LENGTH + 1]; |
| 309 | } WSLCCompatVolumeInformation; |
| 310 | |
| 311 | [ |
| 312 | uuid(DD7B2EF9-AA01-4F21-8A3A-29D394CBB579), |
| 313 | pointer_default(unique), |
| 314 | object |
| 315 | ] |
| 316 | interface IWSLCCompatSession : IUnknown |
| 317 | { |
| 318 | // Image management. |
| 319 | HRESULT PullImage([in] LPCSTR Image, [in, unique] LPCSTR RegistryAuthenticationInformation, [in, unique] IWSLCCompatProgressCallback* ProgressCallback, [in, unique] IWSLCCompatWarningCallback* WarningCallback); |
| 320 | HRESULT LoadImage([in] WSLCCompatHandle ImageHandle, [in, unique] IWSLCCompatProgressCallback* ProgressCallback, [in] ULONGLONG ContentLength, [in, unique] IWSLCCompatWarningCallback* WarningCallback); |
| 321 | HRESULT ImportImage([in] WSLCCompatHandle ImageHandle, [in, unique] LPCSTR ImageName, [in, unique] IWSLCCompatProgressCallback* ProgressCallback, [in] ULONGLONG ContentLength, [in, unique] IWSLCCompatWarningCallback* WarningCallback, [out] LPSTR* ImageId); |
| 322 | HRESULT ListImages([in, unique] const WSLCCompatListImagesOptions* Options, [out, size_is(, *Count)] WSLCCompatImageInformation** Images, [out] ULONG* Count); |
| 323 | HRESULT DeleteImage([in] const WSLCCompatDeleteImageOptions* Options, [out, size_is(, *Count)] WSLCCompatDeletedImageInformation** DeletedImages, [out] ULONG* Count); |
| 324 | HRESULT TagImage([in] const WSLCCompatTagImageOptions* Options); |
| 325 | |
| 326 | // Container management. |
| 327 | HRESULT CreateContainer([in] const WSLCCompatContainerOptions* Options, [in, unique] IWSLCCompatWarningCallback* WarningCallback, [out] IWSLCCompatContainer** Container); |
| 328 | HRESULT OpenContainer([in] LPCSTR NameOrId, [out] IWSLCCompatContainer** Container); |
| 329 | |
| 330 | // Terminate the VM and containers. |
| 331 | HRESULT Terminate(); |
| 332 | |
| 333 | // Returns a one-off event that is signaled when the session terminates, whether due to an |
| 334 | // explicit Terminate() call or an unexpected VM exit. The returned handle is owned by the |
| 335 | // caller and remains valid (and observes the signaled state) even after the session is released. |
| 336 | HRESULT GetTerminationEvent([out, system_handle(sh_event)] HANDLE* Event); |
| 337 | |
| 338 | // Returns the cached termination reason and details. These are only available after the |
| 339 | // termination event has been signaled; before that the call fails. |
| 340 | HRESULT GetTerminationReason([out] WSLCVirtualMachineTerminationReason* Reason, [out] LPWSTR* Details); |
| 341 | |
| 342 | // Volume management. |
| 343 | HRESULT CreateVolume([in] const WSLCCompatVolumeOptions* Options, [out] WSLCCompatVolumeInformation* VolumeInfo); |
| 344 | HRESULT DeleteVolume([in] LPCSTR Name); |
| 345 | |
| 346 | HRESULT Authenticate([in] LPCSTR ServerAddress, [in] LPCSTR Username, [in] LPCSTR Password, [out] LPSTR* IdentityToken); |
| 347 | HRESULT PushImage([in] LPCSTR Image, [in] LPCSTR RegistryAuthenticationInformation, [in, unique] IWSLCCompatProgressCallback* ProgressCallback, [in, unique] IWSLCCompatWarningCallback* WarningCallback); |
| 348 | |
| 349 | HRESULT RegisterCrashDumpCallback([in] IWSLCCompatCrashDumpCallback* Callback, [out] IUnknown** Subscription); |
| 350 | } |
| 351 | |
| 352 | [ |
| 353 | uuid(279F2047-DA35-45A3-B671-AFD2302D5D16), |
| 354 | pointer_default(unique), |
| 355 | object |
| 356 | ] |
| 357 | interface IWSLCCompatSessionManager : IUnknown |
| 358 | { |
| 359 | HRESULT GetVersion([out] WSLCCompatVersion* Version); |
| 360 | HRESULT IsClientVersionSupported([in] const WSLCCompatVersion* ClientVersion, [out] BOOL* IsSupported); |
| 361 | |
| 362 | // Session management. |
| 363 | HRESULT CreateSession([in, unique] const WSLCCompatSessionSettings* Settings, WSLCSessionFlags Flags, [in, unique] IWSLCCompatWarningCallback* WarningCallback, [out] IWSLCCompatSession** Session); |
| 364 | } |