Skip to content

Commit

Permalink
Add the virtual machine existence check for solving network unavailab…
Browse files Browse the repository at this point in the history
…le issues when people reopen the same virtual machine accidentally.
  • Loading branch information
MouriNaruto committed Jun 16, 2024
1 parent 297117c commit 732d913
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions NanaBox/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,25 @@ void NanaBox::MainWindow::InitializeVirtualMachine()
this->m_Configuration = NanaBox::DeserializeConfiguration(
ConfigurationFileContent);

{
bool VirtualMachineExisted = true;
try
{
winrt::make_self<NanaBox::ComputeSystem>(
winrt::to_hstring(
this->m_Configuration.Name));
}
catch (...)
{
VirtualMachineExisted = false;
}

if (VirtualMachineExisted)
{
winrt::throw_hresult(HCS_E_SYSTEM_ALREADY_EXISTS);
}
}

for (NanaBox::ScsiDeviceConfiguration& ScsiDevice
: this->m_Configuration.ScsiDevices)
{
Expand Down

0 comments on commit 732d913

Please sign in to comment.