-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[qemu] Make logging code terser #3653
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -380,25 +380,17 @@ void mp::QemuVirtualMachine::shutdown(bool force) | |
mpl::log(mpl::Level::debug, vm_name, "No process to kill"); | ||
} | ||
|
||
if (mp::backend::instance_image_has_snapshot(desc.image.image_path, suspend_tag)) | ||
{ | ||
if (state != State::suspended) | ||
{ | ||
mpl::log( | ||
mpl::Level::warning, | ||
vm_name, | ||
fmt::format("{} has the image suspension snapshot, but it is not in the suspended state", vm_name)); | ||
} | ||
const auto has_suspend_snapshot = mp::backend::instance_image_has_snapshot(desc.image.image_path, suspend_tag); | ||
if (has_suspend_snapshot != (state == State::suspended)) // clang-format off | ||
mpl::log(mpl::Level::warning, vm_name, fmt::format("Image has {} suspension snapshot, but the state is {}", | ||
has_suspend_snapshot ? "a" : "no", | ||
static_cast<short>(state))); // clang-format on | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only problem of this is the integer value returns to us via There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, this is what my comment above about formatters is about. Ideally, we'd write a Formatter for VM::State... see above. |
||
if (has_suspend_snapshot) | ||
{ | ||
mpl::log(mpl::Level::info, vm_name, "Deleting suspend image"); | ||
mp::backend::delete_instance_suspend_image(desc.image.image_path, suspend_tag); | ||
} | ||
else if (state == State::suspended) | ||
{ | ||
mpl::log(mpl::Level::warning, | ||
vm_name, | ||
fmt::format("{} is suspended, but the image does not have the suspension snapshot", vm_name)); | ||
} | ||
|
||
state = State::off; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice trick to utilize the symmetry.