Skip to content

Commit 3d53df3

Browse files
committed
fix unity build
1 parent 5a6f3e1 commit 3d53df3

4 files changed

Lines changed: 30 additions & 35 deletions

File tree

‎src/windows/common/HcsVirtualMachineBackend.cpp‎

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,22 @@ Module Name:
1313
--*/
1414

1515
#include "precomp.h"
16-
#include "ExecutionContext.h"
1716
#include "HcsVirtualMachineBackend.h"
1817
#include "WslCoreNetworkEndpointSettings.h"
1918
#include "hvsocket.hpp"
2019

2120
using wsl::windows::common::Context;
22-
using wsl::windows::common::ExecutionContext;
21+
using wsl::windows::common::vm::c_maximumDisks;
22+
using wsl::windows::common::vm::c_mib;
23+
using wsl::windows::common::vm::c_notSupported;
24+
using wsl::windows::common::vm::CreateExecutionContext;
2325

2426
namespace validation = wsl::windows::common::vm::validation;
2527

2628
namespace {
2729

2830
namespace schema = wsl::windows::common::hcs;
2931

30-
constexpr UINT64 c_mib = 1024 * 1024;
31-
constexpr UINT32 c_maximumDisks = 254;
32-
constexpr HRESULT c_notSupported = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
33-
34-
std::unique_ptr<ExecutionContext> CreateExecutionContext(Context Context)
35-
{
36-
const auto* current = ExecutionContext::Current();
37-
if (current != nullptr && current->CurrentContext() >= static_cast<ULONGLONG>(Context))
38-
{
39-
return {};
40-
}
41-
42-
return std::make_unique<ExecutionContext>(Context);
43-
}
44-
4532
template <typename... Visitors>
4633
struct Overloaded : Visitors...
4734
{

‎src/windows/common/IVirtualMachineBackend.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,19 @@ Module Name:
3333
#include <variant>
3434
#include <vector>
3535
#include "defs.h"
36+
#include "ExecutionContext.h"
3637
#include "stringshared.h"
3738

39+
namespace wsl::windows::common::vm {
40+
41+
inline constexpr UINT64 c_mib = 1024 * 1024;
42+
inline constexpr UINT32 c_maximumDisks = 254;
43+
inline constexpr HRESULT c_notSupported = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
44+
45+
std::unique_ptr<ExecutionContext> CreateExecutionContext(Context Context);
46+
47+
} // namespace wsl::windows::common::vm
48+
3849
enum class BackendKind
3950
{
4051
Hcs,

‎src/windows/common/OpenVmmVirtualMachineBackend.cpp‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,21 @@ Module Name:
2222

2323
using wsl::windows::common::Context;
2424
using wsl::windows::common::ExecutionContext;
25+
using wsl::windows::common::vm::c_maximumDisks;
26+
using wsl::windows::common::vm::c_mib;
27+
using wsl::windows::common::vm::c_notSupported;
28+
using wsl::windows::common::vm::CreateExecutionContext;
2529

2630
namespace validation = wsl::windows::common::vm::validation;
2731

2832
namespace {
2933

30-
constexpr UINT64 c_mib = 1024 * 1024;
31-
constexpr UINT32 c_maximumDisks = 254;
3234
constexpr UINT32 c_rpcTimeoutMs = 30000;
33-
constexpr HRESULT c_notSupported = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
3435
// Hybrid vsock embeds the AF_VSOCK port in the first field of this AF_HYPERV service ID.
3536
constexpr std::wstring_view c_vsockServiceIdSuffix = L"-facb-11e6-bd58-64006a7986d3";
3637

3738
using validation::ValidateResourceId;
3839

39-
std::unique_ptr<ExecutionContext> CreateExecutionContext(Context Context)
40-
{
41-
const auto* current = ExecutionContext::Current();
42-
if (current != nullptr && current->CurrentContext() >= static_cast<ULONGLONG>(Context))
43-
{
44-
return {};
45-
}
46-
47-
return std::make_unique<ExecutionContext>(Context);
48-
}
49-
5040
void DestroyConfig(WslOpenVmmConfig* Config) noexcept
5141
{
5242
WslOpenVmmDestroyConfig(&Config);

‎src/windows/common/VirtualMachineBackend.cpp‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ Module Name:
1919
#include "IVirtualMachineBackend.h"
2020
#include "OpenVmmVirtualMachineBackend.h"
2121

22-
namespace {
22+
using wsl::windows::common::Context;
23+
using wsl::windows::common::ExecutionContext;
2324

24-
constexpr HRESULT c_notSupported = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
25-
constexpr UINT32 c_maximumDisks = 254;
25+
std::unique_ptr<ExecutionContext> wsl::windows::common::vm::CreateExecutionContext(Context Context)
26+
{
27+
const auto* current = ExecutionContext::Current();
28+
if (current != nullptr && current->CurrentContext() >= static_cast<ULONGLONG>(Context))
29+
{
30+
return {};
31+
}
2632

27-
} // namespace
33+
return std::make_unique<ExecutionContext>(Context);
34+
}
2835

2936
wsl::shared::string::MacAddress VmUserModeNatNetwork::ClientMacAddress() const
3037
{

0 commit comments

Comments
 (0)