Skip to content

Commit

Permalink
Merge pull request #3330 from canonical/qemu-sync-clock
Browse files Browse the repository at this point in the history
[qemu] sync clock with host after resuming from suspension
  • Loading branch information
Chris Townsend authored Jan 10, 2024
2 parents fbf0f09 + a843fd2 commit b0875ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/platform/backends/qemu/qemu_virtual_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,18 @@ mp::QemuVirtualMachine::QemuVirtualMachine(const VirtualMachineDescription& desc
vm_process->write(QJsonDocument(qmp).toJson());
},
Qt::QueuedConnection);

QObject::connect(
this,
&QemuVirtualMachine::on_synchronize_clock,
this,
[this](const SSHKeyProvider* key_provider) {
mpl::log(mpl::Level::debug, vm_name, fmt::format("Syncing RTC clock"));

mp::SSHSession session{VirtualMachine::ssh_hostname(), ssh_port(), ssh_username(), *key_provider};
mp::utils::run_in_ssh_session(session, "sudo hwclock --hctosys");
},
Qt::QueuedConnection);
}

mp::QemuVirtualMachine::~QemuVirtualMachine()
Expand Down Expand Up @@ -489,6 +501,7 @@ void mp::QemuVirtualMachine::wait_until_ssh_up(std::chrono::milliseconds timeout
if (is_starting_from_suspend)
{
emit on_delete_memory_snapshot();
emit on_synchronize_clock(&key_provider);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/platform/backends/qemu/qemu_virtual_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <multipass/network_interface.h>
#include <multipass/process/process.h>
#include <multipass/ssh/ssh_key_provider.h>
#include <multipass/virtual_machine_description.h>

#include <QObject>
Expand Down Expand Up @@ -72,6 +73,7 @@ class QemuVirtualMachine : public QObject, public BaseVirtualMachine
signals:
void on_delete_memory_snapshot();
void on_reset_network();
void on_synchronize_clock(const SSHKeyProvider* key_provider);

protected:
// TODO remove this, the onus of composing a VM of stubs should be on the stub VMs
Expand Down

0 comments on commit b0875ea

Please sign in to comment.