Skip to content

Commit

Permalink
Merge #815
Browse files Browse the repository at this point in the history
815: Remove unused passing around of key_provider r=townsend2010 a=gerboland

I do not see it being used in any VM

Co-authored-by: Gerry Boland <[email protected]>
  • Loading branch information
bors[bot] and gerboland committed May 31, 2019
2 parents 4d733b2 + cc53d0f commit 50fe23b
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 30 deletions.
9 changes: 3 additions & 6 deletions include/multipass/virtual_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,15 @@ class VirtualMachine
virtual void update_state() = 0;

VirtualMachine::State state;
const SSHKeyProvider* key_provider;
const std::string vm_name;
std::condition_variable state_wait;
std::mutex state_mutex;

protected:
VirtualMachine(VirtualMachine::State state, const SSHKeyProvider* key_provider, const std::string& vm_name)
: state{state}, key_provider{key_provider}, vm_name{vm_name} {};
VirtualMachine(const SSHKeyProvider* key_provider, const std::string& vm_name)
: VirtualMachine(State::off, key_provider, vm_name){};
VirtualMachine(VirtualMachine::State state, const std::string& vm_name) : state{state}, vm_name{vm_name} {};
VirtualMachine(const std::string& vm_name) : VirtualMachine(State::off, vm_name){};
VirtualMachine(const VirtualMachine&) = delete;
VirtualMachine& operator=(const VirtualMachine&) = delete;
};
}
} // namespace multipass
#endif // MULTIPASS_VIRTUAL_MACHINE_H
5 changes: 1 addition & 4 deletions include/multipass/virtual_machine_description.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Alberto Aguirre <[email protected]>
*
*/

#ifndef MULTIPASS_VIRTUAL_MACHINE_DESCRIPTION_H
Expand Down Expand Up @@ -42,9 +40,8 @@ class VirtualMachineDescription
std::string ssh_username;
VMImage image;
Path cloud_init_iso;
const SSHKeyProvider* key_provider;
};
}
} // namespace multipass

Q_DECLARE_METATYPE(multipass::VirtualMachineDescription)

Expand Down
13 changes: 5 additions & 8 deletions src/daemon/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,13 @@ mp::VirtualMachineDescription to_machine_desc(const mp::LaunchRequest* request,
const mp::MemorySize& mem_size, const mp::MemorySize& disk_space,
const std::string& mac_addr, const std::string& ssh_username,
const mp::VMImage& image, YAML::Node& meta_data_config,
YAML::Node& user_data_config, YAML::Node& vendor_data_config,
const mp::SSHKeyProvider* key_provider)
YAML::Node& user_data_config, YAML::Node& vendor_data_config)
{
const auto num_cores = request->num_cores() < 1 ? 1 : request->num_cores();
const auto instance_dir = mp::utils::base_dir(image.image_path);
const auto cloud_init_iso =
make_cloud_init_image(name, instance_dir, meta_data_config, user_data_config, vendor_data_config);
return {num_cores, mem_size, disk_space, name, mac_addr, ssh_username, image, cloud_init_iso, key_provider};
return {num_cores, mem_size, disk_space, name, mac_addr, ssh_username, image, cloud_init_iso};
}

template <typename T>
Expand Down Expand Up @@ -580,9 +579,8 @@ mp::Daemon::Daemon(std::unique_ptr<const DaemonConfig> the_config)
auto vm_image = fetch_image_for(name, config->factory->fetch_type(), *config->vault);
const auto instance_dir = mp::utils::base_dir(vm_image.image_path);
const auto cloud_init_iso = instance_dir.filePath("cloud-init-config.iso");
mp::VirtualMachineDescription vm_desc{spec.num_cores, spec.mem_size, spec.disk_space,
name, mac_addr, spec.ssh_username,
vm_image, cloud_init_iso, config->ssh_key_provider.get()};
mp::VirtualMachineDescription vm_desc{spec.num_cores, spec.mem_size, spec.disk_space, name,
mac_addr, spec.ssh_username, vm_image, cloud_init_iso};

try
{
Expand Down Expand Up @@ -1984,8 +1982,7 @@ void mp::Daemon::create_vm(const CreateRequest* request, grpc::ServerWriter<Crea
}
auto vm_desc = to_machine_desc(request, name, checked_args.mem_size, checked_args.disk_space, mac_addr,
config->ssh_username, vm_image, meta_data_cloud_init_config,
user_data_cloud_init_config, vendor_data_cloud_init_config,
config->ssh_key_provider.get());
user_data_cloud_init_config, vendor_data_cloud_init_config);

config->factory->prepare_instance_image(vm_image, vm_desc);

Expand Down
2 changes: 1 addition & 1 deletion src/platform/backends/libvirt/libvirt_virtual_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ auto domain_state_for(virDomainPtr domain)

mp::LibVirtVirtualMachine::LibVirtVirtualMachine(const mp::VirtualMachineDescription& desc, virConnectPtr connection,
const std::string& bridge_name, mp::VMStatusMonitor& monitor)
: VirtualMachine{desc.key_provider, desc.vm_name},
: VirtualMachine{desc.vm_name},
connection{connection},
domain{domain_definition_for(connection, desc, bridge_name)},
mac_addr{instance_mac_addr_for(domain.get())},
Expand Down
3 changes: 1 addition & 2 deletions src/platform/backends/qemu/qemu_virtual_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ auto get_metadata()
mp::QemuVirtualMachine::QemuVirtualMachine(const ProcessFactory* process_factory, const VirtualMachineDescription& desc,
const std::string& tap_device_name, DNSMasqServer& dnsmasq_server,
VMStatusMonitor& monitor)
: VirtualMachine{instance_image_has_snapshot(desc.image.image_path) ? State::suspended : State::off,
desc.key_provider, desc.vm_name},
: VirtualMachine{instance_image_has_snapshot(desc.image.image_path) ? State::suspended : State::off, desc.vm_name},
tap_device_name{tap_device_name},
mac_addr{desc.mac_addr},
username{desc.ssh_username},
Expand Down
6 changes: 3 additions & 3 deletions tests/stub_virtual_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace test
{
struct StubVirtualMachine final : public multipass::VirtualMachine
{
StubVirtualMachine() : VirtualMachine{nullptr, ""}
StubVirtualMachine() : VirtualMachine{""}
{
}

Expand Down Expand Up @@ -84,6 +84,6 @@ struct StubVirtualMachine final : public multipass::VirtualMachine
{
}
};
}
}
} // namespace test
} // namespace multipass
#endif // MULTIPASS_STUB_VIRTUAL_MACHINE_H
4 changes: 1 addition & 3 deletions tests/test_libvirt_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,14 @@ struct LibVirtBackend : public Test
mpt::TempFile dummy_image;
mpt::TempFile dummy_cloud_init_iso;
mpt::StubProcessFactory process_factory;
mpt::StubSSHKeyProvider key_provider;
mp::VirtualMachineDescription default_description{2,
mp::MemorySize{"3M"},
mp::MemorySize{}, // not used
"pied-piper-valley",
"",
"",
{dummy_image.name(), "", "", "", "", "", "", {}},
dummy_cloud_init_iso.name(),
&key_provider};
dummy_cloud_init_iso.name()};
mpt::TempDir data_dir;

decltype(MOCK(virConnectClose)) connect_close{MOCK(virConnectClose)};
Expand Down
4 changes: 1 addition & 3 deletions tests/test_qemu_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,14 @@ struct QemuBackend : public mpt::TestWithMockedBinPath
mpt::TempFile dummy_image;
mpt::TempFile dummy_cloud_init_iso;
mp::ProcessFactory process_factory; // want to launch actual processes
mpt::StubSSHKeyProvider key_provider;
mp::VirtualMachineDescription default_description{2,
mp::MemorySize{"3M"},
mp::MemorySize{}, // not used
"pied-piper-valley",
"",
"",
{dummy_image.name(), "", "", "", "", "", "", {}},
dummy_cloud_init_iso.name(),
&key_provider};
dummy_cloud_init_iso.name()};
mpt::TempDir data_dir;
};

Expand Down

0 comments on commit 50fe23b

Please sign in to comment.