Skip to content

Commit

Permalink
[qemu] Handle exceptions gracefully in destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sploder12 committed Sep 19, 2024
1 parent 265d141 commit 4729fe4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/platform/backends/qemu/qemu_virtual_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <multipass/logging/log.h>
#include <multipass/memory_size.h>
#include <multipass/platform.h>
#include <multipass/top_catch_all.h>
#include <multipass/utils.h>
#include <multipass/vm_mount.h>
#include <multipass/vm_status_monitor.h>
Expand Down Expand Up @@ -286,14 +287,16 @@ mp::QemuVirtualMachine::~QemuVirtualMachine()
{
update_shutdown_status = false;

if (state == State::running)
{
suspend();
}
else
{
shutdown();
}
mp::top_catch_all(vm_name, [this]() {
if (state == State::running)
{
suspend();
}
else
{
shutdown();
}
});
}
}

Expand Down

0 comments on commit 4729fe4

Please sign in to comment.