@@ -374,7 +374,10 @@ void OpenVmmVirtualMachineBackend::Initialize(const VmCreateRequest& Request)
374374 THROW_LAST_ERROR_IF (result == WAIT_FAILED );
375375 THROW_HR_WITH_USER_ERROR_IF (WSL_E_VM_CRASHED , wsl::shared::Localization::MessageWSL2Crashed (), result == WAIT_OBJECT_0 );
376376 THROW_IF_FAILED_MSG (createResult, " Failed to create OpenVMM VM" );
377- m_state = VmState::Created;
377+ {
378+ auto lock = m_lock.lock_exclusive ();
379+ m_state = VmState::Created;
380+ }
378381}
379382
380383void OpenVmmVirtualMachineBackend::ReadProcessLog (wil::unique_hfile Pipe) noexcept
@@ -402,47 +405,23 @@ void OpenVmmVirtualMachineBackend::OnProcessExit(DWORD ExitCode) noexcept
402405{
403406 WSL_LOG (
404407 " OpenVmmProcessExited" , TraceLoggingValue (m_description.Identity .VmId , " vmId" ), TraceLoggingValue (ExitCode, " exitCode" ));
405- LOG_IF_WIN32_BOOL_FALSE (SetEvent (m_exitEvent.get ()));
406408 {
407409 auto lock = m_lock.lock_exclusive ();
408410 m_state = VmState::Stopped;
409411 m_exitDetails = std::format (L" OpenVMM process exited with code {}" , ExitCode);
410412 CloseGuestListenersLocked (m_description.Identity );
411413 }
414+ LOG_IF_WIN32_BOOL_FALSE (SetEvent (m_exitEvent.get ()));
412415 NotifyTerminated (m_description.Identity );
413416}
414417
415418VmPlatformCapabilities OpenVmmVirtualMachineBackend::QueryCapabilities ()
416419{
417420 VmPlatformCapabilities capabilities;
418421 capabilities.Backend = BackendKind::OpenVmm;
419- // Report known OpenVMM support independently of which backend methods are wired through the C ABI.
420- for (const auto operation :
421- {VmOperation::Create,
422- VmOperation::Start,
423- VmOperation::Terminate,
424- VmOperation::CreateGuestListener,
425- VmOperation::AcceptGuestConnection,
426- VmOperation::ConnectGuest,
427- VmOperation::CloseGuestListener,
428- VmOperation::AttachDisk,
429- VmOperation::DetachDisk,
430- VmOperation::CreateFileSystemDevice,
431- VmOperation::GetFileSystemDeviceStatus,
432- VmOperation::AddFileSystemShare,
433- VmOperation::RemoveFileSystemShare,
434- VmOperation::RemoveDevice,
435- VmOperation::BindPort,
436- VmOperation::UnbindPort})
437- {
438- capabilities.Operations .set (static_cast <size_t >(operation));
439- }
440422 for (const auto feature :
441- {VmFeature::LinuxDirectBoot,
442- VmFeature::SerialConsole,
423+ {VmFeature::SerialConsole,
443424 VmFeature::VirtioConsole,
444- VmFeature::Vhd,
445- VmFeature::Vhdx,
446425 VmFeature::VirtioFsFileBacked,
447426 VmFeature::UserModeNatNetwork,
448427 VmFeature::TcpPortBinding,
@@ -597,11 +576,6 @@ VmGuestListener OpenVmmVirtualMachineBackend::CreateGuestListener(GuestServicePo
597576 return RegisterGuestListenerLocked (m_description.Identity , Port);
598577}
599578
600- wil::unique_socket OpenVmmVirtualMachineBackend::AcceptGuestConnection (VmListenerId Listener)
601- {
602- return AcceptGuestListenerConnection (Listener, m_description.Identity );
603- }
604-
605579wil::unique_socket OpenVmmVirtualMachineBackend::ConnectGuest (GuestServicePort Port)
606580{
607581 const auto startTimeMs = GetTickCount64 ();
@@ -758,6 +732,11 @@ VmFileSystemDevice OpenVmmVirtualMachineBackend::CreateFileSystemDevice(const Vm
758732 c_notSupported,
759733 transport->Layout != VmVirtioFsLayout::SingleShare,
760734 " OpenVMM currently supports only single-share virtio-fs devices" );
735+ // WslOpenVmmVmAddShare carries neither mount options nor an identity, so device options are
736+ // rejected rather than silently dropped, just as share-level mount options are.
737+ THROW_HR_IF_MSG (c_notSupported, !transport->Options .MountOptions .empty (), " OpenVMM does not support virtio-fs mount options" );
738+ THROW_HR_IF_MSG (
739+ c_notSupported, !!transport->Options .UserToken , " OpenVMM does not support serving a virtio-fs device under a user token" );
761740
762741 auto lock = m_lock.lock_exclusive ();
763742 THROW_HR_IF (HRESULT_FROM_WIN32 (ERROR_INVALID_STATE ), !m_vm);
@@ -804,6 +783,7 @@ VmFileSystemShare OpenVmmVirtualMachineBackend::AddFileSystemShare(VmDeviceId De
804783 const auto * options = std::get_if<VmVirtioFsShareOptions>(&Request.Options );
805784 THROW_HR_IF_MSG (c_notSupported, !options, " OpenVMM supports only virtio-fs share options" );
806785 THROW_HR_IF_MSG (c_notSupported, !options->MountOptions .empty (), " OpenVMM does not support virtio-fs mount options" );
786+ THROW_HR_IF_MSG (c_notSupported, !!options->UserToken , " OpenVMM does not support serving a virtio-fs share under a user token" );
807787 const auto hostPath = wsl::windows::common::filesystem::GetCanonicalPath (Request.HostPath );
808788 const auto attributes = GetFileAttributesW (hostPath.c_str ());
809789 THROW_LAST_ERROR_IF (attributes == INVALID_FILE_ATTRIBUTES );
0 commit comments