@@ -324,7 +324,7 @@ void OpenVmmVirtualMachineBackend::Initialize(const VmCreateRequest& Request)
324324 const auto & configuration = std::get<VmUserModeNatNetwork>(attachment.EffectiveConfiguration );
325325 const auto macAddress = wsl::shared::string::FormatMacAddress (configuration.ClientMacAddress (), L' -' );
326326 THROW_IF_FAILED (WslOpenVmmConfigSetConsommeNic (config.get (), nicId.c_str (), macAddress.c_str ()));
327- m_networkAdapters.emplace (attachment.Id .Value , NetworkAdapter{attachment, nicId});
327+ m_networkAdapters.emplace (attachment.Id .Value , NetworkAdapter{attachment, { nicId} });
328328 m_nextDeviceId = attachment.Id .Value + 1 ;
329329 }
330330 for (const auto & disk : Request.BootDisks )
@@ -757,6 +757,7 @@ VmGpuAttachment OpenVmmVirtualMachineBackend::AddGpu(const VmGpuRequest&)
757757
758758VmFileSystemDevice OpenVmmVirtualMachineBackend::CreateFileSystemDevice (const VmFileSystemDeviceRequest& Request)
759759{
760+ THROW_HR_IF_MSG (c_notSupported, Request.UserToken .has_value (), " OpenVMM does not support a per-device user token" );
760761 const auto * transport = std::get_if<VmVirtioFsDevice>(&Request.Transport );
761762 WSL_LOG (
762763 " OpenVmmCreateFileSystemDeviceBegin" ,
@@ -773,11 +774,13 @@ VmFileSystemDevice OpenVmmVirtualMachineBackend::CreateFileSystemDevice(const Vm
773774 THROW_HR_IF (E_BOUNDS , m_nextDeviceId == UINT64_MAX );
774775 for (const auto & entry : m_fileSystemDevices)
775776 {
776- THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_ALREADY_EXISTS ), wsl::shared::string::IsEqual (entry.second .Transport .Tag , transport->Tag , false ));
777+ THROW_HR_IF (
778+ HRESULT_FROM_WIN32 (ERROR_ALREADY_EXISTS ),
779+ wsl::shared::string::IsEqual (std::get<VmVirtioFsDevice>(entry.second .Transport ).Tag , transport->Tag , false ));
777780 }
778781
779- VmFileSystemDevice device{{m_description.Identity , m_nextDeviceId}, VmFileSystemDeviceState::Prepared};
780- const auto inserted = m_fileSystemDevices.emplace (device.Id .Value , FileSystemDevice{device, *transport, {}}).second ;
782+ VmFileSystemDevice device{{m_description.Identity , m_nextDeviceId}, VmFileSystemDeviceState::Prepared, {}, Request. Transport };
783+ const auto inserted = m_fileSystemDevices.emplace (device.Id .Value , FileSystemDevice{device, {}}).second ;
781784 WI_ASSERT (inserted);
782785 ++m_nextDeviceId;
783786 WSL_LOG (
@@ -795,7 +798,7 @@ VmFileSystemDevice OpenVmmVirtualMachineBackend::GetFileSystemDeviceStatus(VmDev
795798 THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_INVALID_STATE ), !m_vm);
796799 const auto device = m_fileSystemDevices.find (Device.Value );
797800 THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_NOT_FOUND ), device == m_fileSystemDevices.end ());
798- return device->second . Device ;
801+ return device->second ;
799802}
800803
801804VmFileSystemShare OpenVmmVirtualMachineBackend::AddFileSystemShare (VmDeviceId Device, const VmFileSystemShareRequest& Request)
@@ -821,23 +824,23 @@ VmFileSystemShare OpenVmmVirtualMachineBackend::AddFileSystemShare(VmDeviceId De
821824 THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_INVALID_STATE ), !m_vm);
822825 const auto device = m_fileSystemDevices.find (Device.Value );
823826 THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_NOT_FOUND ), device == m_fileSystemDevices.end ());
824- THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_ALREADY_EXISTS ), device->second .Share .has_value ());
827+ THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_ALREADY_EXISTS ), device->second .Backend . Share .has_value ());
825828 THROW_HR_IF (E_BOUNDS , m_nextShareId == UINT64_MAX );
826829
827830 VmFileSystemShare share{
828831 {m_description.Identity , m_nextShareId},
829832 Device,
830- VmVirtioFsShareAddress{device->second .Transport .Tag , {}},
833+ VmVirtioFsShareAddress{std::get<VmVirtioFsDevice>( device->second .Transport ) .Tag , {}},
831834 hostPath,
832835 Request.ReadOnly };
833836 const auto & guestAddress = std::get<VmVirtioFsShareAddress>(share.GuestAddress );
834- const auto [entry, inserted] = m_fileSystemShares.emplace (share.Id .Value , FileSystemShare{ share} );
837+ const auto [entry, inserted] = m_fileSystemShares.emplace (share.Id .Value , share);
835838 WI_ASSERT (inserted);
836- device->second .Share = share.Id .Value ;
837- device->second .Device . State = VmFileSystemDeviceState::Serving;
839+ device->second .Backend . Share = share.Id .Value ;
840+ device->second .State = VmFileSystemDeviceState::Serving;
838841 auto rollback = wil::scope_exit ([this , &device, &entry] {
839- device->second .Share .reset ();
840- device->second .Device . State = VmFileSystemDeviceState::Prepared;
842+ device->second .Backend . Share .reset ();
843+ device->second .State = VmFileSystemDeviceState::Prepared;
841844 m_fileSystemShares.erase (entry);
842845 });
843846 const auto result = WslOpenVmmVmAddShare (m_vm.get (), guestAddress.Tag .c_str (), hostPath.c_str (), Request.ReadOnly );
@@ -865,21 +868,21 @@ void OpenVmmVirtualMachineBackend::RemoveFileSystemShare(VmShareId Share)
865868 THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_INVALID_STATE ), !m_vm);
866869 const auto share = m_fileSystemShares.find (Share.Value );
867870 THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_NOT_FOUND ), share == m_fileSystemShares.end ());
868- const auto device = m_fileSystemDevices.find (share->second .Share . Device .Value );
869- THROW_HR_IF (E_UNEXPECTED , device == m_fileSystemDevices.end () || device->second .Share != Share.Value );
871+ const auto device = m_fileSystemDevices.find (share->second .Device .Value );
872+ THROW_HR_IF (E_UNEXPECTED , device == m_fileSystemDevices.end () || device->second .Backend . Share != Share.Value );
870873
871- const auto & guestAddress = std::get<VmVirtioFsShareAddress>(share->second .Share . GuestAddress );
874+ const auto & guestAddress = std::get<VmVirtioFsShareAddress>(share->second .GuestAddress );
872875 const auto result = WslOpenVmmVmRemoveShare (m_vm.get (), guestAddress.Tag .c_str ());
873876 WSL_LOG (
874877 " OpenVmmRemoveFileSystemShareEnd" ,
875878 TraceLoggingValue (m_description.Identity .VmId , " vmId" ),
876879 TraceLoggingValue (Share.Value , " shareId" ),
877- TraceLoggingValue (device->second .Device . Id .Value , " deviceId" ),
880+ TraceLoggingValue (device->second .Id .Value , " deviceId" ),
878881 TraceLoggingValue (guestAddress.Tag .c_str (), " tag" ),
879882 TraceLoggingHResult (result, " result" ));
880883 THROW_IF_FAILED (result);
881- device->second .Share .reset ();
882- device->second .Device . State = VmFileSystemDeviceState::Prepared;
884+ device->second .Backend . Share .reset ();
885+ device->second .State = VmFileSystemDeviceState::Prepared;
883886 m_fileSystemShares.erase (share);
884887}
885888
@@ -900,7 +903,7 @@ void OpenVmmVirtualMachineBackend::RemoveDevice(VmDeviceId Device)
900903 THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_INVALID_STATE ), !m_vm);
901904 const auto device = m_fileSystemDevices.find (Device.Value );
902905 THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_NOT_FOUND ), device == m_fileSystemDevices.end ());
903- THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_BUSY ), device->second .Share .has_value ());
906+ THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_BUSY ), device->second .Backend . Share .has_value ());
904907 m_fileSystemDevices.erase (device);
905908}
906909
@@ -967,11 +970,12 @@ VmPortBinding OpenVmmVirtualMachineBackend::BindPort(VmDeviceId Device, const Vm
967970 Request.ListenScopeId ,
968971 Request.HostPort ,
969972 Request.GuestPort };
970- const auto [entry, inserted] = m_portBindings.emplace (binding.Id .Value , PortBinding{binding, adapter->second .NicId , hostAddress});
973+ const auto [entry, inserted] =
974+ m_portBindings.emplace (binding.Id .Value , PortBinding{binding, {adapter->second .Backend .NicId , hostAddress}});
971975 WI_ASSERT (inserted);
972976 auto rollback = wil::scope_exit ([this , &entry] { m_portBindings.erase (entry); });
973- const auto result =
974- WslOpenVmmVmBindPort ( m_vm.get (), adapter->second .NicId .c_str (), Request.HostPort , Request.GuestPort , tcp, hostAddress.c_str ());
977+ const auto result = WslOpenVmmVmBindPort (
978+ m_vm.get (), adapter->second . Backend .NicId .c_str (), Request.HostPort , Request.GuestPort , tcp, hostAddress.c_str ());
975979 WSL_LOG (
976980 " OpenVmmBindPortEnd" ,
977981 TraceLoggingValue (m_description.Identity .VmId , " vmId" ),
@@ -999,16 +1003,16 @@ void OpenVmmVirtualMachineBackend::UnbindPort(VmPortBindingId Binding)
9991003
10001004 const auto result = WslOpenVmmVmUnbindPort (
10011005 m_vm.get (),
1002- binding->second .NicId .c_str (),
1003- binding->second .Binding . EffectiveHostPort ,
1004- binding->second .Binding . GuestPort ,
1005- binding->second .Binding . Protocol == TransportProtocol_Tcp,
1006- binding->second .HostAddress .c_str ());
1006+ binding->second .Backend . NicId .c_str (),
1007+ binding->second .EffectiveHostPort ,
1008+ binding->second .GuestPort ,
1009+ binding->second .Protocol == TransportProtocol_Tcp,
1010+ binding->second .Backend . HostAddress .c_str ());
10071011 WSL_LOG (
10081012 " OpenVmmUnbindPortEnd" ,
10091013 TraceLoggingValue (m_description.Identity .VmId , " vmId" ),
10101014 TraceLoggingValue (Binding.Value , " bindingId" ),
1011- TraceLoggingValue (binding->second .Binding . Device .Value , " deviceId" ),
1015+ TraceLoggingValue (binding->second .Device .Value , " deviceId" ),
10121016 TraceLoggingHResult (result, " result" ));
10131017 THROW_IF_FAILED (result);
10141018 m_portBindings.erase (binding);
@@ -1026,4 +1030,4 @@ void OpenVmmVirtualMachineBackend::CreateDnsRecord(VmDeviceId Device, const VmDn
10261030 ExecutionContext context (Context::ConfigureNetworking);
10271031 validation::ValidateResourceId (Device, m_description.Identity );
10281032 THROW_HR_MSG (c_notSupported, " OpenVMM does not support static DNS records" );
1029- }
1033+ }
0 commit comments