Skip to content

Commit

Permalink
[qemu] remove instance variables that are a duplicate of vm desc members
Browse files Browse the repository at this point in the history
  • Loading branch information
sharder996 committed Sep 18, 2024
1 parent 6731497 commit daddd3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/platform/backends/qemu/qemu_virtual_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ mp::QemuVirtualMachine::QemuVirtualMachine(const VirtualMachineDescription& desc
key_provider,
instance_dir},
desc{desc},
mac_addr{desc.default_mac_address},
username{desc.ssh_username},
qemu_platform{qemu_platform},
monitor{&monitor},
mount_args{mount_args_from_json(monitor.retrieve_metadata_for(vm_name))}
Expand Down Expand Up @@ -527,21 +525,21 @@ void mp::QemuVirtualMachine::ensure_vm_is_running()

std::string mp::QemuVirtualMachine::ssh_hostname(std::chrono::milliseconds timeout)
{
auto get_ip = [this]() -> std::optional<IPAddress> { return qemu_platform->get_ip_for(mac_addr); };
auto get_ip = [this]() -> std::optional<IPAddress> { return qemu_platform->get_ip_for(desc.default_mac_address); };

return mp::backend::ip_address_for(this, get_ip, timeout);
}

std::string mp::QemuVirtualMachine::ssh_username()
{
return username;
return desc.ssh_username;

Check warning on line 535 in src/platform/backends/qemu/qemu_virtual_machine.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/backends/qemu/qemu_virtual_machine.cpp#L535

Added line #L535 was not covered by tests
}

std::string mp::QemuVirtualMachine::management_ipv4()
{
if (!management_ip)
{
auto result = qemu_platform->get_ip_for(mac_addr);
auto result = qemu_platform->get_ip_for(desc.default_mac_address);
if (result)
management_ip.emplace(result.value());
else
Expand Down
2 changes: 0 additions & 2 deletions src/platform/backends/qemu/qemu_virtual_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ class QemuVirtualMachine : public QObject, public BaseVirtualMachine

VirtualMachineDescription desc;
std::unique_ptr<Process> vm_process{nullptr};
const std::string mac_addr;
const std::string username;
QemuPlatform* qemu_platform;
VMStatusMonitor* monitor;
MountArgs mount_args;
Expand Down

0 comments on commit daddd3d

Please sign in to comment.