From ded9d80ddd2787ccd10b6cfb2f986d68089098c3 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 18:41:01 +0100 Subject: [PATCH 01/15] [cmake] Remove redundant compile option The rpc target already gets -Wno-pedantic from gRPC (declared with INTERFACE). --- src/rpc/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/rpc/CMakeLists.txt b/src/rpc/CMakeLists.txt index 74c6d6530c..7ab47dc7a1 100644 --- a/src/rpc/CMakeLists.txt +++ b/src/rpc/CMakeLists.txt @@ -16,9 +16,7 @@ get_filename_component(MULTIPASS_PROTOCOL_SPEC_ABS_PATH multipass.proto ABSOLUTE set(GRPC_GENERATED_SOURCE_DIR ${MULTIPASS_GENERATED_SOURCE_DIR}/multipass/rpc) file(MAKE_DIRECTORY ${GRPC_GENERATED_SOURCE_DIR}) -if(NOT MSVC) - add_compile_options(-Wno-error=pedantic) -else() +if(MSVC) add_compile_options(/bigobj) endif() From aee144041e65f06be8b3f638e89b2ea373a42164 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 18:48:45 +0100 Subject: [PATCH 02/15] [cmake] Stop propagating disabled warnings in gRPC Link `rpc` against gRPC with PRIVATE scope, to avoid propagating compilation options which are specific to that module. Warning strictness may need to be reduced for external code, but that should not affect our own code. This breaks the build until the uncovered warnings get fixed. --- src/rpc/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/CMakeLists.txt b/src/rpc/CMakeLists.txt index 7ab47dc7a1..6d87f3f40d 100644 --- a/src/rpc/CMakeLists.txt +++ b/src/rpc/CMakeLists.txt @@ -43,4 +43,4 @@ protobuf_generate( # Mark the generated folder as SYSTEM so the linters and other # tooling won't complain. target_include_directories(rpc SYSTEM PUBLIC ${GRPC_GENERATED_SOURCE_DIR}) -target_link_libraries(rpc gRPC) +target_link_libraries(rpc PRIVATE gRPC) From 0704ecc0ba3085bf92231d776be8bbf3c21f2dea Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 19:17:28 +0100 Subject: [PATCH 03/15] [warn] Fix a number of unused-param warnings --- include/multipass/xz_image_decoder.h | 1 + src/client/cli/cmd/authenticate.cpp | 6 +++--- src/client/cli/cmd/launch.cpp | 3 +-- src/client/cli/cmd/mount.cpp | 2 +- src/client/cli/cmd/recover.cpp | 2 +- src/client/cli/cmd/restore.cpp | 2 +- src/client/cli/cmd/stop.cpp | 2 +- src/client/cli/cmd/suspend.cpp | 2 +- src/client/cli/cmd/umount.cpp | 2 +- src/client/cli/cmd/version.cpp | 2 +- src/client/cli/cmd/wait_ready.cpp | 2 +- src/daemon/daemon.cpp | 13 +++++-------- src/daemon/daemon_rpc.cpp | 4 ++-- 13 files changed, 20 insertions(+), 23 deletions(-) diff --git a/include/multipass/xz_image_decoder.h b/include/multipass/xz_image_decoder.h index bed36f78d7..ef0c1411d9 100644 --- a/include/multipass/xz_image_decoder.h +++ b/include/multipass/xz_image_decoder.h @@ -19,6 +19,7 @@ #include +#include #include #include diff --git a/src/client/cli/cmd/authenticate.cpp b/src/client/cli/cmd/authenticate.cpp index 212465ed38..85cf89684c 100644 --- a/src/client/cli/cmd/authenticate.cpp +++ b/src/client/cli/cmd/authenticate.cpp @@ -26,7 +26,7 @@ namespace mp = multipass; namespace cmd = multipass::cmd; -mp::ReturnCodeVariant cmd::Authenticate::run(mp::ArgParser* parser) +mp::ReturnCodeVariant cmd::Authenticate::run(ArgParser* parser) { auto ret = parse_args(parser); if (ret != ParseCode::Ok) @@ -34,8 +34,8 @@ mp::ReturnCodeVariant cmd::Authenticate::run(mp::ArgParser* parser) return parser->returnCodeFrom(ret); } - auto on_success = [](mp::AuthenticateReply& reply) -> ReturnCodeVariant { - return mp::ReturnCode::Ok; + auto on_success = [](AuthenticateReply&) -> ReturnCodeVariant { + return ReturnCode::Ok; }; auto on_failure = [this](grpc::Status& status) -> ReturnCodeVariant { diff --git a/src/client/cli/cmd/launch.cpp b/src/client/cli/cmd/launch.cpp index b6f7fb3acd..c2eea98a71 100644 --- a/src/client/cli/cmd/launch.cpp +++ b/src/client/cli/cmd/launch.cpp @@ -633,8 +633,7 @@ mp::ReturnCodeVariant cmd::Launch::request_launch(const ArgParser* parser) }; auto streaming_callback = - [this](mp::LaunchReply& reply, - grpc::ClientReaderWriterInterface* client) { + [this](LaunchReply& reply, grpc::ClientReaderWriterInterface*) { std::unordered_map progress_messages{ {LaunchProgress_ProgressTypes_IMAGE, "Retrieving image: "}, {LaunchProgress_ProgressTypes_EXTRACT, "Extracting image: "}, diff --git a/src/client/cli/cmd/mount.cpp b/src/client/cli/cmd/mount.cpp index 2030ddb990..66127f2348 100644 --- a/src/client/cli/cmd/mount.cpp +++ b/src/client/cli/cmd/mount.cpp @@ -80,7 +80,7 @@ mp::ReturnCodeVariant cmd::Mount::run(mp::ArgParser* parser) mp::AnimatedSpinner spinner{cout}; - auto on_success = [&spinner](mp::MountReply& reply) -> ReturnCodeVariant { + auto on_success = [&spinner](MountReply&) -> ReturnCodeVariant { spinner.stop(); return ReturnCode::Ok; }; diff --git a/src/client/cli/cmd/recover.cpp b/src/client/cli/cmd/recover.cpp index 59de94d26b..610295c9f1 100644 --- a/src/client/cli/cmd/recover.cpp +++ b/src/client/cli/cmd/recover.cpp @@ -31,7 +31,7 @@ mp::ReturnCodeVariant cmd::Recover::run(mp::ArgParser* parser) return parser->returnCodeFrom(ret); } - auto on_success = [](mp::RecoverReply& reply) -> ReturnCodeVariant { + auto on_success = [](RecoverReply&) -> ReturnCodeVariant { return mp::ReturnCode::Ok; }; diff --git a/src/client/cli/cmd/restore.cpp b/src/client/cli/cmd/restore.cpp index fbb4feba93..657db652a6 100644 --- a/src/client/cli/cmd/restore.cpp +++ b/src/client/cli/cmd/restore.cpp @@ -33,7 +33,7 @@ mp::ReturnCodeVariant cmd::Restore::run(mp::ArgParser* parser) AnimatedSpinner spinner{cout}; - auto on_success = [this, &spinner](mp::RestoreReply& reply) -> ReturnCodeVariant { + auto on_success = [this, &spinner](RestoreReply&) -> ReturnCodeVariant { spinner.stop(); fmt::print(cout, "Snapshot restored: {}.{}\n", request.instance(), request.snapshot()); return ReturnCode::Ok; diff --git a/src/client/cli/cmd/stop.cpp b/src/client/cli/cmd/stop.cpp index a94101a204..1d7e1b3d0c 100644 --- a/src/client/cli/cmd/stop.cpp +++ b/src/client/cli/cmd/stop.cpp @@ -37,7 +37,7 @@ mp::ReturnCodeVariant cmd::Stop::run(mp::ArgParser* parser) return parser->returnCodeFrom(ret); } - auto on_success = [](mp::StopReply& reply) -> ReturnCodeVariant { return ReturnCode::Ok; }; + auto on_success = [](StopReply&) -> ReturnCodeVariant { return ReturnCode::Ok; }; AnimatedSpinner spinner{cout}; auto on_failure = [this, &spinner](grpc::Status& status) -> ReturnCodeVariant { diff --git a/src/client/cli/cmd/suspend.cpp b/src/client/cli/cmd/suspend.cpp index 67413acd62..de0aa1a75a 100644 --- a/src/client/cli/cmd/suspend.cpp +++ b/src/client/cli/cmd/suspend.cpp @@ -36,7 +36,7 @@ mp::ReturnCodeVariant cmd::Suspend::run(mp::ArgParser* parser) return parser->returnCodeFrom(ret); } - auto on_success = [](mp::SuspendReply& reply) -> ReturnCodeVariant { return ReturnCode::Ok; }; + auto on_success = [](SuspendReply&) -> ReturnCodeVariant { return ReturnCode::Ok; }; AnimatedSpinner spinner{cout}; auto on_failure = [this, &spinner](grpc::Status& status) -> ReturnCodeVariant { diff --git a/src/client/cli/cmd/umount.cpp b/src/client/cli/cmd/umount.cpp index d962324eef..7ab96e0745 100644 --- a/src/client/cli/cmd/umount.cpp +++ b/src/client/cli/cmd/umount.cpp @@ -31,7 +31,7 @@ mp::ReturnCodeVariant cmd::Umount::run(mp::ArgParser* parser) return parser->returnCodeFrom(ret); } - auto on_success = [](mp::UmountReply& reply) -> ReturnCodeVariant { return ReturnCode::Ok; }; + auto on_success = [](UmountReply&) -> ReturnCodeVariant { return ReturnCode::Ok; }; auto on_failure = [this](grpc::Status& status) -> ReturnCodeVariant { return standard_failure_handler_for(name(), cerr, status); diff --git a/src/client/cli/cmd/version.cpp b/src/client/cli/cmd/version.cpp index c67bece9fd..51fe78e0be 100644 --- a/src/client/cli/cmd/version.cpp +++ b/src/client/cli/cmd/version.cpp @@ -38,7 +38,7 @@ mp::ReturnCodeVariant cmd::Version::run(mp::ArgParser* parser) return ReturnCode::Ok; }; - auto on_failure = [this](grpc::Status& status) -> ReturnCodeVariant { + auto on_failure = [this](grpc::Status&) -> ReturnCodeVariant { VersionReply reply; cout << chosen_formatter->format(reply, multipass::version_string); diff --git a/src/client/cli/cmd/wait_ready.cpp b/src/client/cli/cmd/wait_ready.cpp index db7c8bcef6..dbba283cbe 100644 --- a/src/client/cli/cmd/wait_ready.cpp +++ b/src/client/cli/cmd/wait_ready.cpp @@ -51,7 +51,7 @@ mp::ReturnCodeVariant cmd::WaitReady::run(mp::ArgParser* parser) timer->start(); } - auto on_success = [&spinner, &timer](WaitReadyReply& reply) -> ReturnCodeVariant { + auto on_success = [&spinner, &timer](WaitReadyReply&) -> ReturnCodeVariant { if (timer) timer->stop(); spinner.stop(); diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 2d5aa9846f..b91c258477 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -279,7 +279,7 @@ auto fetch_image_for(const std::string& name, mp::VMImageVault& vault) { auto stub_prepare = [](const mp::VMImage&) -> mp::VMImage { return {}; }; - auto stub_progress = [](int download_type, int progress) { return true; }; + auto stub_progress = [](int /*download_type*/, int /*progress*/) { return true; }; mp::Query query{name, "", false, "", mp::Query::Type::Alias, false}; @@ -586,8 +586,7 @@ LinearInstanceSelection select_all(InstanceTable& instances) } // careful to keep the original `name` around while the provided `selection` is in use! -void rank_instance(const std::string& name, - const InstanceTrail& trail, +void rank_instance(const InstanceTrail& trail, InstanceSelectionReport& selection) { switch (trail.index()) @@ -635,7 +634,7 @@ InstanceSelectionReport select_instances(InstanceTable& operative_instances, if (seen_instances.insert(*vm_name).second) { auto trail = find_instance(operative_instances, deleted_instances, *vm_name); - rank_instance(*vm_name, trail, ret); + rank_instance(trail, ret); } } } @@ -1163,8 +1162,7 @@ mp::SettingsHandler* register_instance_mod( mp::SettingsHandler* register_snapshot_mod( std::unordered_map& operative_instances, const std::unordered_map& deleted_instances, - const std::unordered_set& preparing_instances, - const mp::VirtualMachineFactory& vm_factory) + const std::unordered_set& preparing_instances) { try { @@ -1299,8 +1297,7 @@ mp::Daemon::Daemon(std::unique_ptr the_config) [this](const std::string& n) { return add_bridged_interface(n); })}, snapshot_mod_handler{register_snapshot_mod(operative_instances, deleted_instances, - preparing_instances, - *config->factory)} + preparing_instances)} { using e_state = VirtualMachine::State; diff --git a/src/daemon/daemon_rpc.cpp b/src/daemon/daemon_rpc.cpp index 90a6f4fd10..51ac457db7 100644 --- a/src/daemon/daemon_rpc.cpp +++ b/src/daemon/daemon_rpc.cpp @@ -352,8 +352,8 @@ grpc::Status mp::DaemonRpc::version(grpc::ServerContext* context, } grpc::Status mp::DaemonRpc::ping(grpc::ServerContext* context, - const PingRequest* request, - PingReply* server) + const PingRequest* /*request*/, + PingReply* /*server*/) { auto client_cert = client_cert_from(context); From 89fe0cc816a3ec76745947d240d8dfaa83e7a09f Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 19:28:48 +0100 Subject: [PATCH 04/15] [warn] Fix a few more unused parameters Fix a few unused parameters, along with some redundant namespace qualifications. --- include/multipass/cli/command.h | 10 +++--- src/image_host/custom_image_host.cpp | 2 +- src/image_host/ubuntu_image_host.cpp | 2 +- .../backends/shared/base_virtual_machine.h | 8 ++--- .../shared/base_virtual_machine_factory.h | 12 +++---- .../virtualbox_virtual_machine_factory.cpp | 3 +- src/platform/platform_unix.cpp | 2 +- tests/unit/stub_status_monitor.h | 32 +++++++++++++------ 8 files changed, 40 insertions(+), 31 deletions(-) diff --git a/include/multipass/cli/command.h b/include/multipass/cli/command.h index b0387ff364..901da3217e 100644 --- a/include/multipass/cli/command.h +++ b/include/multipass/cli/command.h @@ -152,7 +152,7 @@ class Command : private DisabledCopyMove on_success, on_failure, [this](ReplyType& reply, - grpc::ClientReaderWriterInterface* client) { + grpc::ClientReaderWriterInterface*) { if (!reply.log_line().empty()) { cerr << reply.log_line(); @@ -167,10 +167,10 @@ class Command : private DisabledCopyMove private: template - void check_return_callables(SuccessCallable&& on_success, FailureCallable&& on_failure) + void check_return_callables(SuccessCallable&&, FailureCallable&&) { - using SuccessCallableTraits = multipass::callable_traits; - using FailureCallableTraits = multipass::callable_traits; + using SuccessCallableTraits = callable_traits; + using FailureCallableTraits = callable_traits; using SuccessCallableArg0Type = std::remove_reference_t::type>; using FailureCallableArg0Type = @@ -206,7 +206,7 @@ class Command : private DisabledCopyMove return [&on_failure, &reply](grpc::Status status) { (void)reply; // suppress unhelpful warning in clang: // https://bugs.llvm.org/show_bug.cgi?id=35450 - if constexpr (multipass::callable_traits::num_args == 2) + if constexpr (callable_traits::num_args == 2) return on_failure(status, reply); else return on_failure(status); diff --git a/src/image_host/custom_image_host.cpp b/src/image_host/custom_image_host.cpp index bb8650e766..dc9a07513a 100644 --- a/src/image_host/custom_image_host.cpp +++ b/src/image_host/custom_image_host.cpp @@ -146,7 +146,7 @@ std::vector> mp::CustomVMImageHost::all_ std::vector mp::CustomVMImageHost::all_images_for_impl( const std::string& remote_name, - bool allow_unsupported) const + bool /*allow_unsupported*/) const { return manifest_from(remote_name).products; } diff --git a/src/image_host/ubuntu_image_host.cpp b/src/image_host/ubuntu_image_host.cpp index 1199e319af..b3fe0d1fbd 100644 --- a/src/image_host/ubuntu_image_host.cpp +++ b/src/image_host/ubuntu_image_host.cpp @@ -332,7 +332,7 @@ bool mp::UbuntuVMImageRemote::apply_image_mutator(VMImageInfo& info) const return image_mutator(info); } -bool multipass::UbuntuVMImageRemote::default_image_mutator(VMImageInfo& image) +bool mp::UbuntuVMImageRemote::default_image_mutator(VMImageInfo&) { return true; } diff --git a/src/platform/backends/shared/base_virtual_machine.h b/src/platform/backends/shared/base_virtual_machine.h index 6e7c2d62cb..a24a6755a0 100644 --- a/src/platform/backends/shared/base_virtual_machine.h +++ b/src/platform/backends/shared/base_virtual_machine.h @@ -57,14 +57,12 @@ class BaseVirtualMachine : public VirtualMachine void wait_for_cloud_init(std::chrono::milliseconds timeout) override; std::vector get_all_ipv4() override; - void add_network_interface(int index, - const std::string& default_mac_addr, - const NetworkInterface& extra_interface) override + void add_network_interface(int, const std::string&, const NetworkInterface&) override { throw NotImplementedOnThisBackendException("networks"); } - std::unique_ptr make_native_mount_handler(const std::string& target, - const VMMount& mount) override + std::unique_ptr make_native_mount_handler(const std::string&, + const VMMount&) override { throw NotImplementedOnThisBackendException("native mounts"); } diff --git a/src/platform/backends/shared/base_virtual_machine_factory.h b/src/platform/backends/shared/base_virtual_machine_factory.h index 32921b3c2c..8023838e33 100644 --- a/src/platform/backends/shared/base_virtual_machine_factory.h +++ b/src/platform/backends/shared/base_virtual_machine_factory.h @@ -88,7 +88,7 @@ class BaseVirtualMachineFactory : public VirtualMachineFactory AvailabilityZoneManager& az_manager; protected: - std::string create_bridge_with(const NetworkInterfaceInfo& interface) override + std::string create_bridge_with(const NetworkInterfaceInfo&) override { throw NotImplementedOnThisBackendException{"bridge creation"}; } @@ -120,11 +120,11 @@ inline void multipass::BaseVirtualMachineFactory::remove_resources_for(const std } inline multipass::VirtualMachine::UPtr multipass::BaseVirtualMachineFactory::clone_vm_impl( - const std::string& source_vm_name, - const VMSpecs& src_vm_specs, - const VirtualMachineDescription& desc, - VMStatusMonitor& monitor, - const SSHKeyProvider& key_provider) + const std::string&, + const VMSpecs&, + const VirtualMachineDescription&, + VMStatusMonitor&, + const SSHKeyProvider&) { throw NotImplementedOnThisBackendException{"clone"}; } diff --git a/src/platform/backends/virtualbox/virtualbox_virtual_machine_factory.cpp b/src/platform/backends/virtualbox/virtualbox_virtual_machine_factory.cpp index b012b5dbe2..8ebe73bbc4 100644 --- a/src/platform/backends/virtualbox/virtualbox_virtual_machine_factory.cpp +++ b/src/platform/backends/virtualbox/virtualbox_virtual_machine_factory.cpp @@ -269,8 +269,7 @@ auto mp::VirtualBoxVirtualMachineFactory::networks() const -> std::vector& vector) +void multipass::VirtualBoxVirtualMachineFactory::prepare_networking(std::vector&) { // Nothing to do here, VirtualBox takes host interfaces directly } diff --git a/src/platform/platform_unix.cpp b/src/platform/platform_unix.cpp index 6f5483cf1d..2d1ccfbed8 100644 --- a/src/platform/platform_unix.cpp +++ b/src/platform/platform_unix.cpp @@ -100,7 +100,7 @@ void mp::platform::Platform::setup_permission_inheritance(bool restricted) const } } -bool mp::platform::Platform::symlink(const char* target, const char* link, bool is_dir) const +bool mp::platform::Platform::symlink(const char* target, const char* link, bool /*is_dir*/) const { return ::symlink(target, link) == 0; } diff --git a/tests/unit/stub_status_monitor.h b/tests/unit/stub_status_monitor.h index 6ea25db9c9..245e4bfeb4 100644 --- a/tests/unit/stub_status_monitor.h +++ b/tests/unit/stub_status_monitor.h @@ -25,18 +25,30 @@ namespace test { struct StubVMStatusMonitor : public multipass::VMStatusMonitor { - void on_resume() override{}; - ; - void on_shutdown() override{}; - void on_suspend() override{}; - void on_restart(const std::string& name) override{}; - void persist_state_for(const std::string& name, const VirtualMachine::State& state) override{}; - void update_metadata_for(const std::string& name, - const boost::json::object& metadata) override{}; - boost::json::object retrieve_metadata_for(const std::string& name) override + void on_resume() override + { + } + void on_shutdown() override + { + } + void on_suspend() override + { + } + void on_restart(const std::string& /*name*/) override + { + } + void persist_state_for(const std::string& /*name*/, + const VirtualMachine::State& /*state*/) override + { + } + void update_metadata_for(const std::string& /*name*/, + const boost::json::object& /*metadata*/) override + { + } + boost::json::object retrieve_metadata_for(const std::string& /*name*/) override { return {}; - }; + } }; } // namespace test } // namespace multipass From 5ef7a316ec55576d8d877b282d60baaad42492f7 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 21:19:49 +0100 Subject: [PATCH 05/15] [format] Tweak format break penalty Tweak clang-format's penalty to break on assignment, to prefer ``` auto a = foo(aaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbb, ccccccccccccccccccc, ddddddddddddddddddd); ``` to ``` auto a = foo(aaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbb, cccccccccccccc... ``` --- .clang-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 16afe1896c..0373755c75 100644 --- a/.clang-format +++ b/.clang-format @@ -15,7 +15,7 @@ BinPackArguments: false BinPackParameters: false BreakBeforeTernaryOperators: true AlignOperands: AlignAfterOperator -PenaltyBreakAssignment: 10 +PenaltyBreakAssignment: 150 BraceWrapping: AfterCaseLabel: true AfterClass: true From 321ce423355623217287610f4a1a15bdb78cff6d Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 21:12:04 +0100 Subject: [PATCH 06/15] [image] Remove FetchType This is obsolete now, as there is only one type left. --- include/multipass/fetch_type.h | 27 -- include/multipass/virtual_machine_factory.h | 2 - include/multipass/vm_image_vault.h | 8 +- src/daemon/daemon.cpp | 22 +- src/daemon/default_vm_image_vault.cpp | 12 +- src/daemon/default_vm_image_vault.h | 8 +- .../shared/base_virtual_machine_factory.h | 5 - tests/unit/daemon_test_fixture.cpp | 2 - tests/unit/mock_virtual_machine_factory.h | 1 - tests/unit/mock_vm_image_vault.h | 8 +- tests/unit/stub_virtual_machine_factory.h | 5 - tests/unit/stub_vm_image_vault.h | 7 +- .../test_base_virtual_machine_factory.cpp | 7 - tests/unit/test_daemon.cpp | 4 +- tests/unit/test_image_vault.cpp | 270 +++++------------- 15 files changed, 92 insertions(+), 296 deletions(-) delete mode 100644 include/multipass/fetch_type.h diff --git a/include/multipass/fetch_type.h b/include/multipass/fetch_type.h deleted file mode 100644 index 0dc429572c..0000000000 --- a/include/multipass/fetch_type.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) Canonical, Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Authored by: Alberto Aguirre - * - */ - -#pragma once -namespace multipass -{ -enum class FetchType -{ - ImageOnly -}; -} diff --git a/include/multipass/virtual_machine_factory.h b/include/multipass/virtual_machine_factory.h index 884fd8549e..d742d25001 100644 --- a/include/multipass/virtual_machine_factory.h +++ b/include/multipass/virtual_machine_factory.h @@ -19,7 +19,6 @@ #include "days.h" #include "disabled_copy_move.h" -#include "fetch_type.h" #include "path.h" #include "virtual_machine.h" #include "vm_image.h" @@ -62,7 +61,6 @@ class VirtualMachineFactory : private DisabledCopyMove */ virtual void remove_resources_for(const std::string& name) = 0; - virtual FetchType fetch_type() = 0; virtual void prepare_networking( std::vector& extra_interfaces) = 0; // note the arg may be updated virtual VMImage prepare_source_image(const VMImage& source_image) = 0; diff --git a/include/multipass/vm_image_vault.h b/include/multipass/vm_image_vault.h index 069b973975..5f682b098f 100644 --- a/include/multipass/vm_image_vault.h +++ b/include/multipass/vm_image_vault.h @@ -18,7 +18,6 @@ #pragma once #include "disabled_copy_move.h" -#include "fetch_type.h" #include "memory_size.h" #include "path.h" #include "progress_monitor.h" @@ -70,8 +69,7 @@ class VMImageVault : private DisabledCopyMove using PrepareAction = std::function; virtual ~VMImageVault() = default; - virtual VMImage fetch_image(const FetchType& fetch_type, - const Query& query, + virtual VMImage fetch_image(const Query& query, const PrepareAction& prepare, const ProgressMonitor& monitor, const std::optional& checksum, @@ -79,9 +77,7 @@ class VMImageVault : private DisabledCopyMove virtual void remove(const std::string& name) = 0; virtual bool has_record_for(const std::string& name) = 0; virtual void prune_expired_images() = 0; - virtual void update_images(const FetchType& fetch_type, - const PrepareAction& prepare, - const ProgressMonitor& monitor) = 0; + virtual void update_images(const PrepareAction& prepare, const ProgressMonitor& monitor) = 0; virtual MemorySize minimum_image_size_for(const std::string& id) = 0; virtual void clone(const std::string& source_instance_name, const std::string& destination_instance_name) = 0; diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index b91c258477..4506425460 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -283,8 +283,7 @@ auto fetch_image_for(const std::string& name, mp::Query query{name, "", false, "", mp::Query::Type::Alias, false}; - return vault.fetch_image(factory.fetch_type(), - query, + return vault.fetch_image(query, stub_prepare, stub_progress, std::nullopt, @@ -1470,9 +1469,7 @@ mp::Daemon::Daemon(std::unique_ptr the_config) try { - config->vault->update_images(config->factory->fetch_type(), - prepare_action, - download_monitor); + config->vault->update_images(prepare_action, download_monitor); } catch (const std::exception& e) { @@ -3350,19 +3347,16 @@ void mp::Daemon::create_vm(const CreateRequest* request, return config->factory->prepare_source_image(source_image); }; - auto fetch_type = config->factory->fetch_type(); - std::optional checksum; if (!vm_desc.image.id.empty()) checksum = vm_desc.image.id; - auto vm_image = - config->vault->fetch_image(fetch_type, - query, - prepare_action, - progress_monitor, - checksum, - config->factory->get_instance_directory(name)); + auto vm_image = config->vault->fetch_image( + query, + prepare_action, + progress_monitor, + checksum, + config->factory->get_instance_directory(name)); const auto image_size = config->vault->minimum_image_size_for(vm_image.id); vm_desc.disk_space = compute_final_image_size( diff --git a/src/daemon/default_vm_image_vault.cpp b/src/daemon/default_vm_image_vault.cpp index df917a4821..0cd58184d5 100644 --- a/src/daemon/default_vm_image_vault.cpp +++ b/src/daemon/default_vm_image_vault.cpp @@ -152,8 +152,7 @@ mp::DefaultVMImageVault::~DefaultVMImageVault() url_downloader->abort_all_downloads(); } -mp::VMImage mp::DefaultVMImageVault::fetch_image(const FetchType& fetch_type, - const Query& query, +mp::VMImage mp::DefaultVMImageVault::fetch_image(const Query& query, const PrepareAction& prepare, const ProgressMonitor& monitor, const std::optional& checksum, @@ -278,7 +277,6 @@ mp::VMImage mp::DefaultVMImageVault::fetch_image(const FetchType& fetch_type, info, source_image, image_dir, - fetch_type, prepare, monitor)); @@ -330,7 +328,6 @@ mp::VMImage mp::DefaultVMImageVault::fetch_image(const FetchType& fetch_type, *info, source_image, image_dir, - fetch_type, prepare, monitor)); @@ -417,8 +414,7 @@ void mp::DefaultVMImageVault::prune_expired_images() persist_image_records(); } -void mp::DefaultVMImageVault::update_images(const FetchType& fetch_type, - const PrepareAction& prepare, +void mp::DefaultVMImageVault::update_images(const PrepareAction& prepare, const ProgressMonitor& monitor) { mpl::debug(category, "Checking for images to update…"); @@ -460,8 +456,7 @@ void mp::DefaultVMImageVault::update_images(const FetchType& fetch_type, mpl::info(category, "Updating {} source image to latest", record.query.release); try { - fetch_image(fetch_type, - record.query, + fetch_image(record.query, prepare, monitor, std::nullopt, @@ -544,7 +539,6 @@ mp::VMImage mp::DefaultVMImageVault::download_and_prepare_source_image( const VMImageInfo& info, std::optional& existing_source_image, const QDir& image_dir, - const FetchType& fetch_type, const PrepareAction& prepare, const ProgressMonitor& monitor) { diff --git a/src/daemon/default_vm_image_vault.h b/src/daemon/default_vm_image_vault.h index 84af5d94db..7a4261b6f5 100644 --- a/src/daemon/default_vm_image_vault.h +++ b/src/daemon/default_vm_image_vault.h @@ -53,8 +53,7 @@ class DefaultVMImageVault final : public BaseVMImageVault const multipass::days& days_to_expire); ~DefaultVMImageVault(); - VMImage fetch_image(const FetchType& fetch_type, - const Query& query, + VMImage fetch_image(const Query& query, const PrepareAction& prepare, const ProgressMonitor& monitor, const std::optional& checksum, @@ -62,9 +61,7 @@ class DefaultVMImageVault final : public BaseVMImageVault void remove(const std::string& name) override; bool has_record_for(const std::string& name) override; void prune_expired_images() override; - void update_images(const FetchType& fetch_type, - const PrepareAction& prepare, - const ProgressMonitor& monitor) override; + void update_images(const PrepareAction& prepare, const ProgressMonitor& monitor) override; MemorySize minimum_image_size_for(const std::string& id) override; void clone(const std::string& source_instance_name, const std::string& destination_instance_name) override; @@ -74,7 +71,6 @@ class DefaultVMImageVault final : public BaseVMImageVault VMImage download_and_prepare_source_image(const VMImageInfo& info, std::optional& existing_source_image, const QDir& image_dir, - const FetchType& fetch_type, const PrepareAction& prepare, const ProgressMonitor& monitor); std::filesystem::path extract_image_from(const VMImage& source_image, diff --git a/src/platform/backends/shared/base_virtual_machine_factory.h b/src/platform/backends/shared/base_virtual_machine_factory.h index 8023838e33..f9d6c7cd37 100644 --- a/src/platform/backends/shared/base_virtual_machine_factory.h +++ b/src/platform/backends/shared/base_virtual_machine_factory.h @@ -46,11 +46,6 @@ class BaseVirtualMachineFactory : public VirtualMachineFactory void remove_resources_for(const std::string& name) final; - FetchType fetch_type() override - { - return FetchType::ImageOnly; - }; - QString get_backend_directory_name() const override { return {}; diff --git a/tests/unit/daemon_test_fixture.cpp b/tests/unit/daemon_test_fixture.cpp index 50ed809b93..06a75a04e8 100644 --- a/tests/unit/daemon_test_fixture.cpp +++ b/tests/unit/daemon_test_fixture.cpp @@ -351,8 +351,6 @@ mpt::MockVirtualMachineFactory* mpt::DaemonTestFixture::use_a_mock_vm_factory() auto mock_factory = std::make_unique>(); auto mock_factory_ptr = mock_factory.get(); - ON_CALL(*mock_factory_ptr, fetch_type()).WillByDefault(Return(FetchType::ImageOnly)); - ON_CALL(*mock_factory_ptr, create_virtual_machine).WillByDefault([](auto&&...) { return std::make_unique(); }); diff --git a/tests/unit/mock_virtual_machine_factory.h b/tests/unit/mock_virtual_machine_factory.h index 974fdb5844..1b6c0b37c4 100644 --- a/tests/unit/mock_virtual_machine_factory.h +++ b/tests/unit/mock_virtual_machine_factory.h @@ -46,7 +46,6 @@ struct MockVirtualMachineFactory : public VirtualMachineFactory (override)); MOCK_METHOD(void, remove_resources_for, (const std::string&), (override)); - MOCK_METHOD(FetchType, fetch_type, (), (override)); MOCK_METHOD(void, prepare_networking, (std::vector&), (override)); MOCK_METHOD(VMImage, prepare_source_image, (const VMImage&), (override)); MOCK_METHOD(void, diff --git a/tests/unit/mock_vm_image_vault.h b/tests/unit/mock_vm_image_vault.h index 0eb8120b9c..2a56ec6424 100644 --- a/tests/unit/mock_vm_image_vault.h +++ b/tests/unit/mock_vm_image_vault.h @@ -60,8 +60,7 @@ class MockVMImageVault : public VMImageVault MOCK_METHOD(VMImage, fetch_image, - (const FetchType&, - const Query&, + (const Query&, const PrepareAction&, const ProgressMonitor&, const std::optional&, @@ -70,10 +69,7 @@ class MockVMImageVault : public VMImageVault MOCK_METHOD(void, remove, (const std::string&), (override)); MOCK_METHOD(bool, has_record_for, (const std::string&), (override)); MOCK_METHOD(void, prune_expired_images, (), (override)); - MOCK_METHOD(void, - update_images, - (const FetchType&, const PrepareAction&, const ProgressMonitor&), - (override)); + MOCK_METHOD(void, update_images, (const PrepareAction&, const ProgressMonitor&), (override)); MOCK_METHOD(MemorySize, minimum_image_size_for, (const std::string&), (override)); MOCK_METHOD(void, clone, (const std::string&, const std::string&), (override)); MOCK_METHOD(VMImageHost*, image_host_for, (const std::string&), (const, override)); diff --git a/tests/unit/stub_virtual_machine_factory.h b/tests/unit/stub_virtual_machine_factory.h index 7e546bb4b5..6977af2e5a 100644 --- a/tests/unit/stub_virtual_machine_factory.h +++ b/tests/unit/stub_virtual_machine_factory.h @@ -51,11 +51,6 @@ struct StubVirtualMachineFactory : public multipass::BaseVirtualMachineFactory { } - multipass::FetchType fetch_type() override - { - return multipass::FetchType::ImageOnly; - } - multipass::VMImage prepare_source_image(const multipass::VMImage& source_image) override { return source_image; diff --git a/tests/unit/stub_vm_image_vault.h b/tests/unit/stub_vm_image_vault.h index c86c0694c1..a3ce937fd8 100644 --- a/tests/unit/stub_vm_image_vault.h +++ b/tests/unit/stub_vm_image_vault.h @@ -29,8 +29,7 @@ namespace test { struct StubVMImageVault final : public multipass::VMImageVault { - multipass::VMImage fetch_image(const multipass::FetchType&, - const multipass::Query&, + multipass::VMImage fetch_image(const multipass::Query&, const PrepareAction& prepare, const multipass::ProgressMonitor&, const std::optional&, @@ -46,9 +45,7 @@ struct StubVMImageVault final : public multipass::VMImageVault } void prune_expired_images() override{}; - void update_images(const FetchType& fetch_type, - const PrepareAction& prepare, - const ProgressMonitor& monitor) override{}; + void update_images(const PrepareAction& prepare, const ProgressMonitor& monitor) override {}; MemorySize minimum_image_size_for(const std::string& image) override { diff --git a/tests/unit/test_base_virtual_machine_factory.cpp b/tests/unit/test_base_virtual_machine_factory.cpp index 5166f090d6..010b8d2da3 100644 --- a/tests/unit/test_base_virtual_machine_factory.cpp +++ b/tests/unit/test_base_virtual_machine_factory.cpp @@ -90,13 +90,6 @@ struct BaseFactory : public Test mpt::StubAvailabilityZoneManager az_manager{}; }; -TEST_F(BaseFactory, returnsImageOnlyFetchType) -{ - MockBaseFactory factory{az_manager}; - - EXPECT_EQ(factory.fetch_type(), mp::FetchType::ImageOnly); -} - TEST_F(BaseFactory, dirNameReturnsEmptyString) { MockBaseFactory factory{az_manager}; diff --git a/tests/unit/test_daemon.cpp b/tests/unit/test_daemon.cpp index 6d38261c78..055c1c8926 100644 --- a/tests/unit/test_daemon.cpp +++ b/tests/unit/test_daemon.cpp @@ -1520,10 +1520,10 @@ TEST_F(Daemon, ctorDropsRemovedInstances) .WillRepeatedly(Invoke([](const auto& p) { return p.filename() != "nowhere"; })); auto mock_image_vault = std::make_unique>(); - EXPECT_CALL(*mock_image_vault, fetch_image(_, Field(&mp::Query::name, stayed), _, _, _, _)) + EXPECT_CALL(*mock_image_vault, fetch_image(Field(&mp::Query::name, stayed), _, _, _, _)) .WillRepeatedly( DoDefault()); // returns an image that can be verified to exist for this instance - EXPECT_CALL(*mock_image_vault, fetch_image(_, Field(&mp::Query::name, gone), _, _, _, _)) + EXPECT_CALL(*mock_image_vault, fetch_image(Field(&mp::Query::name, gone), _, _, _, _)) .WillOnce(Return( mp::VMImage{"/path/to/nowhere", "", "", "", "", "", {}})); // an image that can't be // verified to exist for diff --git a/tests/unit/test_image_vault.cpp b/tests/unit/test_image_vault.cpp index ce76515d51..4e62457bb8 100644 --- a/tests/unit/test_image_vault.cpp +++ b/tests/unit/test_image_vault.cpp @@ -226,8 +226,7 @@ TEST_F(ImageVault, downloadsImage) cache_dir.path(), data_dir.path(), mp::days{0}}; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image = vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, @@ -246,8 +245,7 @@ TEST_F(ImageVault, downloadsImageXz) mp::days{0}}; auto query = default_query; query.release = "xenial.xz"; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - query, + auto vm_image = vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, @@ -264,8 +262,7 @@ TEST_F(ImageVault, returnedImageContainsInstanceName) cache_dir.path(), data_dir.path(), mp::days{0}}; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image = vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, @@ -281,12 +278,7 @@ TEST_F(ImageVault, imageCloneSuccess) cache_dir.path(), data_dir.path(), mp::days{0}}; - vault.fetch_image(mp::FetchType::ImageOnly, - default_query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir); + vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, instance_dir); const std::string dest_name = instance_name + "clone"; EXPECT_NO_THROW(vault.clone(instance_name, dest_name)); @@ -305,12 +297,7 @@ TEST_F(ImageVault, invalidFileURLThrows) const mp::Query query{"", invalid_url, false, "", mp::Query::Type::LocalFile}; MP_EXPECT_THROW_THAT( - vault.fetch_image(mp::FetchType::ImageOnly, - query, - stub_prepare, - stub_monitor, - std::nullopt, - save_dir.path()), + vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, save_dir.path()), std::runtime_error, mpt::match_what( StrEq(fmt::format("Invalid file URL `{}`; did you forget a slash?", invalid_url)))); @@ -323,8 +310,7 @@ TEST_F(ImageVault, imageCloneWithInvalidInstanceDirThrows) cache_dir.path(), data_dir.path(), mp::days{0}}; - vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, @@ -353,12 +339,7 @@ TEST_F(ImageVault, nonexistentLocalFileImageThrows) mp::Query::Type::LocalFile}; MP_EXPECT_THROW_THAT( - vault.fetch_image(mp::FetchType::ImageOnly, - query, - stub_prepare, - stub_monitor, - std::nullopt, - save_dir.path()), + vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, save_dir.path()), std::runtime_error, mpt::match_what(StrEq(fmt::format("Custom image `{}` does not exist.", missing_file)))); } @@ -377,12 +358,8 @@ TEST_F(ImageVault, DISABLE_ON_UNIX(imageFileNameWithDriveLetter)) const mp::Query query{"", file.url().toStdString(), false, "", mp::Query::Type::LocalFile}; - EXPECT_NO_THROW(vault.fetch_image(mp::FetchType::ImageOnly, - query, - stub_prepare, - stub_monitor, - std::nullopt, - save_dir.path())); + EXPECT_NO_THROW( + vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, save_dir.path())); } TEST_F(ImageVault, imageCloneFailOnNonExistSrcImage) @@ -403,18 +380,12 @@ TEST_F(ImageVault, imageCloneFailOnAlreadyExistDestImage) cache_dir.path(), data_dir.path(), mp::days{0}}; - vault.fetch_image(mp::FetchType::ImageOnly, - default_query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir); + vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, instance_dir); const std::string dest_name = "valley-pied-piper-clone"; const mp::Query second_query{dest_name, "xenial", false, "", mp::Query::Type::Alias}; - vault.fetch_image(mp::FetchType::ImageOnly, - second_query, + vault.fetch_image(second_query, stub_prepare, stub_monitor, std::nullopt, @@ -437,8 +408,7 @@ TEST_F(ImageVault, callsPrepare) prepare_called = true; return source_image; }; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image = vault.fetch_image(default_query, prepare, stub_monitor, std::nullopt, @@ -459,14 +429,12 @@ TEST_F(ImageVault, recordsInstancedImages) ++prepare_called_count; return source_image; }; - auto vm_image1 = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image1 = vault.fetch_image(default_query, prepare, stub_monitor, std::nullopt, instance_dir); - auto vm_image2 = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image2 = vault.fetch_image(default_query, prepare, stub_monitor, std::nullopt, @@ -490,8 +458,7 @@ TEST_F(ImageVault, cachesPreparedImages) ++prepare_called_count; return source_image; }; - auto vm_image1 = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image1 = vault.fetch_image(default_query, prepare, stub_monitor, std::nullopt, @@ -499,13 +466,12 @@ TEST_F(ImageVault, cachesPreparedImages) auto another_query = default_query; another_query.name = "valley-pied-piper-chat"; - auto vm_image2 = - vault.fetch_image(mp::FetchType::ImageOnly, - another_query, - prepare, - stub_monitor, - std::nullopt, - save_dir.filePath(QString::fromStdString(another_query.name))); + auto vm_image2 = vault.fetch_image( + another_query, + prepare, + stub_monitor, + std::nullopt, + save_dir.filePath(QString::fromStdString(another_query.name))); EXPECT_THAT(url_downloader.downloaded_files.size(), Eq(1)); EXPECT_THAT(prepare_called_count, Eq(1)); @@ -529,18 +495,12 @@ TEST_F(ImageVault, emptyAndReleaseRemoteNamesShareCache) auto cli_query = default_query; cli_query.remote_name = ""; - vault.fetch_image(mp::FetchType::ImageOnly, - cli_query, - prepare, - stub_monitor, - std::nullopt, - instance_dir); + vault.fetch_image(cli_query, prepare, stub_monitor, std::nullopt, instance_dir); auto gui_query = default_query; gui_query.name = "valley-pied-piper-gui"; gui_query.remote_name = mpt::release_remote; - vault.fetch_image(mp::FetchType::ImageOnly, - gui_query, + vault.fetch_image(gui_query, prepare, stub_monitor, std::nullopt, @@ -573,18 +533,12 @@ TEST_F(ImageVault, sameImageIdFromDifferentRemotesSharesCache) auto release_query = default_query; release_query.remote_name = mpt::release_remote; - vault.fetch_image(mp::FetchType::ImageOnly, - release_query, - prepare, - stub_monitor, - std::nullopt, - instance_dir); + vault.fetch_image(release_query, prepare, stub_monitor, std::nullopt, instance_dir); auto daily_query = default_query; daily_query.name = "valley-pied-piper-daily"; daily_query.remote_name = "daily"; - vault.fetch_image(mp::FetchType::ImageOnly, - daily_query, + vault.fetch_image(daily_query, prepare, stub_monitor, std::nullopt, @@ -607,8 +561,7 @@ TEST_F(ImageVault, remembersInstanceImages) cache_dir.path(), data_dir.path(), mp::days{0}}; - auto vm_image1 = first_vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image1 = first_vault.fetch_image(default_query, prepare, stub_monitor, std::nullopt, @@ -619,8 +572,7 @@ TEST_F(ImageVault, remembersInstanceImages) cache_dir.path(), data_dir.path(), mp::days{0}}; - auto vm_image2 = another_vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image2 = another_vault.fetch_image(default_query, prepare, stub_monitor, std::nullopt, @@ -644,8 +596,7 @@ TEST_F(ImageVault, remembersPreparedImages) cache_dir.path(), data_dir.path(), mp::days{0}}; - auto vm_image1 = first_vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image1 = first_vault.fetch_image(default_query, prepare, stub_monitor, std::nullopt, @@ -658,13 +609,12 @@ TEST_F(ImageVault, remembersPreparedImages) cache_dir.path(), data_dir.path(), mp::days{0}}; - auto vm_image2 = - another_vault.fetch_image(mp::FetchType::ImageOnly, - another_query, - prepare, - stub_monitor, - std::nullopt, - save_dir.filePath(QString::fromStdString(another_query.name))); + auto vm_image2 = another_vault.fetch_image( + another_query, + prepare, + stub_monitor, + std::nullopt, + save_dir.filePath(QString::fromStdString(another_query.name))); EXPECT_THAT(url_downloader.downloaded_files.size(), Eq(1)); EXPECT_THAT(prepare_called_count, Eq(1)); @@ -689,8 +639,7 @@ TEST_F(ImageVault, usesImageFromPrepare) cache_dir.path(), data_dir.path(), mp::days{0}}; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image = vault.fetch_image(default_query, prepare, stub_monitor, std::nullopt, @@ -716,8 +665,7 @@ TEST_F(ImageVault, imagePurgedExpired) mpt::make_file_with_content(file_name); return {file_name.toStdString(), source_image.id, "", "", "", "", {}}; }; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image = vault.fetch_image(default_query, prepare, stub_monitor, std::nullopt, @@ -745,8 +693,7 @@ TEST_F(ImageVault, imageExistsNotExpired) mpt::make_file_with_content(file_name); return {file_name.toStdString(), source_image.id, "", "", "", "", {}}; }; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image = vault.fetch_image(default_query, prepare, stub_monitor, std::nullopt, @@ -769,12 +716,7 @@ TEST_F(ImageVault, inProgressDownloadDirectoryNotPrunedDuringFetch) mp::days{0}}; auto fetch_future = std::async(std::launch::async, [&] { - vault.fetch_image(mp::FetchType::ImageOnly, - default_query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir); + vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, instance_dir); }); // Wait for download to start @@ -828,8 +770,7 @@ TEST_F(ImageVault, DISABLE_ON_WINDOWS_AND_MACOS(fileBasedFetchCopiesImageAndRetu query.release = file.url().toStdString(); query.query_type = mp::Query::Type::LocalFile; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - query, + auto vm_image = vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, @@ -851,12 +792,7 @@ TEST_F(ImageVault, invalidCustomImageFileThrows) query.release = "file://foo"; query.query_type = mp::Query::Type::LocalFile; - EXPECT_THROW(vault.fetch_image(mp::FetchType::ImageOnly, - query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir), + EXPECT_THROW(vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, instance_dir), std::runtime_error); } @@ -872,12 +808,7 @@ TEST_F(ImageVault, DISABLE_ON_WINDOWS_AND_MACOS(customImageUrlDownloads)) query.release = "http://www.foo.com/fake.img"; query.query_type = mp::Query::Type::HttpDownload; - vault.fetch_image(mp::FetchType::ImageOnly, - query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir); + vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, instance_dir); EXPECT_THAT(url_downloader.downloaded_files.size(), Eq(1)); EXPECT_TRUE(url_downloader.downloaded_urls.contains(QString::fromStdString(query.release))); @@ -891,13 +822,9 @@ TEST_F(ImageVault, missingDownloadedImageThrows) cache_dir.path(), data_dir.path(), mp::days{0}}; - EXPECT_THROW(vault.fetch_image(mp::FetchType::ImageOnly, - default_query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir), - mp::CreateImageException); + EXPECT_THROW( + vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, instance_dir), + mp::CreateImageException); } TEST_F(ImageVault, hashMismatchThrows) @@ -908,13 +835,9 @@ TEST_F(ImageVault, hashMismatchThrows) cache_dir.path(), data_dir.path(), mp::days{0}}; - EXPECT_THROW(vault.fetch_image(mp::FetchType::ImageOnly, - default_query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir), - mp::CreateImageException); + EXPECT_THROW( + vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, instance_dir), + mp::CreateImageException); } TEST_F(ImageVault, invalidRemoteThrows) @@ -929,12 +852,7 @@ TEST_F(ImageVault, invalidRemoteThrows) query.remote_name = "foo"; - EXPECT_THROW(vault.fetch_image(mp::FetchType::ImageOnly, - query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir), + EXPECT_THROW(vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, instance_dir), std::runtime_error); } @@ -950,12 +868,7 @@ TEST_F(ImageVault, DISABLE_ON_WINDOWS_AND_MACOS(invalidImageAliasThrow)) query.release = "foo"; - EXPECT_THROW(vault.fetch_image(mp::FetchType::ImageOnly, - query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir), + EXPECT_THROW(vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, instance_dir), mp::CreateImageException); } @@ -972,12 +885,8 @@ TEST_F(ImageVault, validRemoteAndAliasReturnsValidImageInfo) query.remote_name = "release"; mp::VMImage image; - EXPECT_NO_THROW(image = vault.fetch_image(mp::FetchType::ImageOnly, - query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir)); + EXPECT_NO_THROW( + image = vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, instance_dir)); EXPECT_THAT(image.original_release, Eq("18.04 LTS")); EXPECT_THAT(image.id, Eq("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")); @@ -996,12 +905,8 @@ TEST_F(ImageVault, DISABLE_ON_WINDOWS_AND_MACOS(httpDownloadReturnsExpectedImage mp::Query query{instance_name, image_url, false, "", mp::Query::Type::HttpDownload}; mp::VMImage image; - EXPECT_NO_THROW(image = vault.fetch_image(mp::FetchType::ImageOnly, - query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir)); + EXPECT_NO_THROW( + image = vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, instance_dir)); // Hash is based on image url EXPECT_THAT(image.id, Eq("7404f51c9b4f40312fa048a0ad36e07b74b718a2d3a5a08e8cca906c69059ddf")); @@ -1015,12 +920,7 @@ TEST_F(ImageVault, imageUpdateCreatesNewDirAndRemovesOld) cache_dir.path(), data_dir.path(), mp::days{1}}; - vault.fetch_image(mp::FetchType::ImageOnly, - default_query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir); + vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, instance_dir); auto original_file{url_downloader.downloaded_files[0]}; auto original_absolute_path{QFileInfo(original_file).absolutePath()}; @@ -1034,7 +934,7 @@ TEST_F(ImageVault, imageUpdateCreatesNewDirAndRemovesOld) host.mock_bionic_image_info.version = new_date_string; host.mock_bionic_image_info.verify = false; - vault.update_images(mp::FetchType::ImageOnly, stub_prepare, stub_monitor); + vault.update_images(stub_prepare, stub_monitor); auto updated_file{url_downloader.downloaded_files[1]}; EXPECT_TRUE(QFileInfo::exists(updated_file)); @@ -1056,13 +956,9 @@ TEST_F(ImageVault, abortedDownloadThrows) running_url_downloader.abort_all_downloads(); - EXPECT_THROW(vault.fetch_image(mp::FetchType::ImageOnly, - default_query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir), - mp::AbortedDownloadException); + EXPECT_THROW( + vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, instance_dir), + mp::AbortedDownloadException); } TEST_F(ImageVault, minimumImageSizeReturnsExpectedSize) @@ -1077,8 +973,7 @@ TEST_F(ImageVault, minimumImageSizeReturnsExpectedSize) cache_dir.path(), data_dir.path(), mp::days{0}}; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image = vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, @@ -1107,8 +1002,7 @@ TEST_F(ImageVault, DISABLE_ON_WINDOWS_AND_MACOS(fileBasedMinimumSizeReturnsExpec query.release = file.url().toStdString(); query.query_type = mp::Query::Type::LocalFile; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - query, + auto vm_image = vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, @@ -1148,8 +1042,7 @@ TEST_F(ImageVault, minimumImageSizeThrowsWhenQemuimgInfoCrashes) cache_dir.path(), data_dir.path(), mp::days{0}}; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image = vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, @@ -1172,8 +1065,7 @@ TEST_F(ImageVault, minimumImageSizeThrowsWhenQemuimgInfoCannotFindTheImage) cache_dir.path(), data_dir.path(), mp::days{0}}; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image = vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, @@ -1196,8 +1088,7 @@ TEST_F(ImageVault, minimumImageSizeThrowsWhenQemuimgInfoDoesNotUnderstandTheImag cache_dir.path(), data_dir.path(), mp::days{0}}; - auto vm_image = vault.fetch_image(mp::FetchType::ImageOnly, - default_query, + auto vm_image = vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, @@ -1292,12 +1183,7 @@ TEST_F(ImageVault, updateImagesLogsWarningOnUnsupportedImage) cache_dir.path(), data_dir.path(), mp::days{1}}; - vault.fetch_image(mp::FetchType::ImageOnly, - default_query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir); + vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, instance_dir); EXPECT_CALL(host, info_for(_)) .WillOnce(Throw(mp::UnsupportedImageException(default_query.release))); @@ -1309,7 +1195,7 @@ TEST_F(ImageVault, updateImagesLogsWarningOnUnsupportedImage) StrEq(fmt::format("Skipping update: The {} release is no longer supported.", default_query.release)))); - EXPECT_NO_THROW(vault.update_images(mp::FetchType::ImageOnly, stub_prepare, stub_monitor)); + EXPECT_NO_THROW(vault.update_images(stub_prepare, stub_monitor)); } TEST_F(ImageVault, updateImagesLogsWarningOnEmptyVault) @@ -1320,12 +1206,7 @@ TEST_F(ImageVault, updateImagesLogsWarningOnEmptyVault) cache_dir.path(), data_dir.path(), mp::days{1}}; - vault.fetch_image(mp::FetchType::ImageOnly, - default_query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir); + vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, instance_dir); EXPECT_CALL(host, info_for(_)).WillOnce(Return(std::nullopt)); @@ -1339,7 +1220,7 @@ TEST_F(ImageVault, updateImagesLogsWarningOnEmptyVault) default_query.release, default_query.remote_name)))); - EXPECT_NO_THROW(vault.update_images(mp::FetchType::ImageOnly, stub_prepare, stub_monitor)); + EXPECT_NO_THROW(vault.update_images(stub_prepare, stub_monitor)); } TEST_F(ImageVault, fetchLocalImageThrowsOnEmptyVault) @@ -1352,13 +1233,9 @@ TEST_F(ImageVault, fetchLocalImageThrowsOnEmptyVault) EXPECT_CALL(host, info_for(_)).WillOnce(Return(std::nullopt)); - EXPECT_THROW(vault.fetch_image(mp::FetchType::ImageOnly, - default_query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir), - mp::ImageNotFoundException); + EXPECT_THROW( + vault.fetch_image(default_query, stub_prepare, stub_monitor, std::nullopt, instance_dir), + mp::ImageNotFoundException); } TEST_F(ImageVault, fetchRemoteImageThrowsOnMissingKernel) @@ -1372,11 +1249,6 @@ TEST_F(ImageVault, fetchRemoteImageThrowsOnMissingKernel) EXPECT_CALL(host, info_for(_)).WillOnce(Return(std::nullopt)); - EXPECT_THROW(vault.fetch_image(mp::FetchType::ImageOnly, - query, - stub_prepare, - stub_monitor, - std::nullopt, - instance_dir), + EXPECT_THROW(vault.fetch_image(query, stub_prepare, stub_monitor, std::nullopt, instance_dir), mp::ImageNotFoundException); } From 575f545c1b17219f1e032fd4191fba8272d8b356 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 21:43:49 +0100 Subject: [PATCH 07/15] [warn] Fix some more unused parameter warnings --- src/daemon/daemon.cpp | 4 ++-- src/platform/platform_linux.cpp | 2 +- src/sshfs_mount/sftp_server.cpp | 4 ++-- tests/unit/stub_availability_zone.h | 6 +++--- tests/unit/stub_availability_zone_manager.h | 2 +- tests/unit/stub_process_factory.cpp | 8 ++++---- tests/unit/stub_terminal.h | 4 ++-- tests/unit/stub_url_downloader.h | 10 +++++----- tests/unit/test_cloud_init_iso.cpp | 5 +++-- 9 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 4506425460..a3288a6b48 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1452,7 +1452,7 @@ mp::Daemon::Daemon(std::unique_ptr the_config) return config->factory->prepare_source_image(source_image); }; - auto download_monitor = [](int download_type, int percentage) { + auto download_monitor = [](int /*progress_type*/, int percentage) { static int last_percentage_logged = -1; if (percentage % 10 == 0) { @@ -1568,7 +1568,7 @@ catch (const std::exception& e) status_promise->set_value(grpc::Status(grpc::StatusCode::FAILED_PRECONDITION, e.what(), "")); } -void mp::Daemon::purge(const PurgeRequest* request, +void mp::Daemon::purge(const PurgeRequest*, grpc::ServerReaderWriterInterface* server, std::promise* status_promise) try diff --git a/src/platform/platform_linux.cpp b/src/platform/platform_linux.cpp index 3a3172f5f6..7dc2abfd00 100644 --- a/src/platform/platform_linux.cpp +++ b/src/platform/platform_linux.cpp @@ -290,7 +290,7 @@ QDir mp::platform::Platform::get_alias_scripts_folder() const } void mp::platform::Platform::create_alias_script(const std::string& alias, - const mp::AliasDefinition& def) const + const AliasDefinition& /*def*/) const { std::string file_path = get_alias_script_path(alias); diff --git a/src/sshfs_mount/sftp_server.cpp b/src/sshfs_mount/sftp_server.cpp index b5f5844ad3..d73c98eea6 100644 --- a/src/sshfs_mount/sftp_server.cpp +++ b/src/sshfs_mount/sftp_server.cpp @@ -224,7 +224,7 @@ auto to_unix_permissions(QFile::Permissions perms) return out; } -void check_sshfs_status(mp::SSHSession& session, mp::SSHProcess& sshfs_process) +void check_sshfs_status(mp::SSHProcess& sshfs_process) { if (sshfs_process.exit_recognized(250ms)) { @@ -243,7 +243,7 @@ auto create_sshfs_process(mp::SSHSession& session, auto sshfs_process = session.exec(fmt::format("sudo {} :{:?} {:?}", sshfs_exec_line, source, target)); - check_sshfs_status(session, sshfs_process); + check_sshfs_status(sshfs_process); return std::make_unique(std::move(sshfs_process)); } diff --git a/tests/unit/stub_availability_zone.h b/tests/unit/stub_availability_zone.h index ad5a37a8ac..557821a95d 100644 --- a/tests/unit/stub_availability_zone.h +++ b/tests/unit/stub_availability_zone.h @@ -47,15 +47,15 @@ class StubAvailabilityZone final : public AvailabilityZone return true; } - void set_available(bool new_available) override + void set_available(bool) override { } - void add_vm(VirtualMachine& vm) override + void add_vm(VirtualMachine&) override { } - void remove_vm(VirtualMachine& vm) override + void remove_vm(VirtualMachine&) override { } diff --git a/tests/unit/stub_availability_zone_manager.h b/tests/unit/stub_availability_zone_manager.h index 88d482679f..a934e6b034 100644 --- a/tests/unit/stub_availability_zone_manager.h +++ b/tests/unit/stub_availability_zone_manager.h @@ -31,7 +31,7 @@ struct StubAvailabilityZoneManager final : public AvailabilityZoneManager { } - AvailabilityZone& get_zone(const std::string& name) override + AvailabilityZone& get_zone(const std::string&) override { return zone; } diff --git a/tests/unit/stub_process_factory.cpp b/tests/unit/stub_process_factory.cpp index bf2f8a3e04..402f01ef64 100644 --- a/tests/unit/stub_process_factory.cpp +++ b/tests/unit/stub_process_factory.cpp @@ -72,17 +72,17 @@ class StubProcess : public mp::Process emit finished(exit_state); } - bool wait_for_started(int msecs = 30000) override + bool wait_for_started(int = 30000) override { return true; } - bool wait_for_finished(int msecs = 30000) override + bool wait_for_finished(int = 30000) override { return false; } - bool wait_for_ready_read(int msecs = 30000) override + bool wait_for_ready_read(int = 30000) override { return true; } @@ -111,7 +111,7 @@ class StubProcess : public mp::Process return ""; } - qint64 write(const QByteArray& data) override + qint64 write(const QByteArray&) override { return 0; } diff --git a/tests/unit/stub_terminal.h b/tests/unit/stub_terminal.h index 7b683c58be..af3ff9836e 100644 --- a/tests/unit/stub_terminal.h +++ b/tests/unit/stub_terminal.h @@ -59,11 +59,11 @@ class StubTerminal : public multipass::Terminal return false; } - void set_cin_echo(const bool enable) override + void set_cin_echo(const bool) override { } - ConsolePtr make_console(ssh_channel channel) override + ConsolePtr make_console(ssh_channel) override { return std::make_unique(); } diff --git a/tests/unit/stub_url_downloader.h b/tests/unit/stub_url_downloader.h index 89be0743e1..a240bbcd19 100644 --- a/tests/unit/stub_url_downloader.h +++ b/tests/unit/stub_url_downloader.h @@ -28,14 +28,14 @@ struct StubURLDownloader : public multipass::URLDownloader StubURLDownloader() : multipass::URLDownloader{std::chrono::seconds(10)} { } - void download_to(const QUrl& url, - const QString& file_name, - int64_t size, - const int download_type, + void download_to(const QUrl&, + const QString&, + int64_t, + const int, const multipass::ProgressMonitor&) override { } - QByteArray download(const QUrl& url) override + QByteArray download(const QUrl&) override { return {}; } diff --git a/tests/unit/test_cloud_init_iso.cpp b/tests/unit/test_cloud_init_iso.cpp index d6c6ebf7f6..e5d38088d0 100644 --- a/tests/unit/test_cloud_init_iso.cpp +++ b/tests/unit/test_cloud_init_iso.cpp @@ -277,8 +277,9 @@ TEST_F(CloudInitIso, readsIsoFileFailedToCheckRootDirRecordData) // default buffer values makes the buffer[0] not 34_u8 which causes root directory record data // checking fail - auto read_return_default_buffer = - [](std::ifstream& file, char* buffer, std::streamsize) -> std::ifstream& { return file; }; + auto read_return_default_buffer = [](std::ifstream& file, + char* /*buffer*/, + std::streamsize) -> std::ifstream& { return file; }; EXPECT_CALL(*mock_file_ops, read(An(), A(), A())) .WillOnce(read_return_default_buffer); From dfdbfced128876a9bc3120fa2bb17d8172b8cad4 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 22:40:36 +0100 Subject: [PATCH 08/15] [warn] Fix a bunch more unused params --- tests/unit/daemon_test_fixture.cpp | 2 +- tests/unit/qemu/linux/test_dnsmasq_server.cpp | 2 +- tests/unit/sftp_server_test_fixture.h | 2 +- tests/unit/stub_cert_store.h | 4 +-- tests/unit/stub_image_host.h | 12 ++++----- tests/unit/stub_virtual_machine.h | 12 ++++----- tests/unit/stub_virtual_machine_factory.h | 18 ++++++------- tests/unit/stub_vm_image_vault.h | 12 ++++----- tests/unit/test_base_virtual_machine.cpp | 8 +++--- tests/unit/test_cli_client.cpp | 20 +++++++------- tests/unit/test_custom_image_host.cpp | 2 +- tests/unit/test_daemon_find.cpp | 2 +- tests/unit/test_exception.cpp | 4 +-- tests/unit/test_image_vault.cpp | 26 +++++++++---------- tests/unit/test_mount_handler.cpp | 4 +-- tests/unit/test_qemu_img_utils.cpp | 2 +- tests/unit/test_sftp_client.cpp | 4 +-- tests/unit/test_sftpserver.cpp | 6 ++--- tests/unit/test_ssh_process.cpp | 2 +- tests/unit/test_sshfsmount.cpp | 2 +- tests/unit/test_ubuntu_image_host.cpp | 2 +- tests/unit/tracking_url_downloader.h | 8 +++--- 22 files changed, 78 insertions(+), 78 deletions(-) diff --git a/tests/unit/daemon_test_fixture.cpp b/tests/unit/daemon_test_fixture.cpp index 06a75a04e8..b28351ac1a 100644 --- a/tests/unit/daemon_test_fixture.cpp +++ b/tests/unit/daemon_test_fixture.cpp @@ -80,7 +80,7 @@ class TestCreate final : public multipass::cmd::Command auto streaming_callback = [this](mp::CreateReply& reply, - grpc::ClientReaderWriterInterface* client) { + grpc::ClientReaderWriterInterface*) { cout << reply.create_message() << std::endl; }; diff --git a/tests/unit/qemu/linux/test_dnsmasq_server.cpp b/tests/unit/qemu/linux/test_dnsmasq_server.cpp index dab939b446..7162e4c808 100644 --- a/tests/unit/qemu/linux/test_dnsmasq_server.cpp +++ b/tests/unit/qemu/linux/test_dnsmasq_server.cpp @@ -46,7 +46,7 @@ namespace { struct CapturingLogger : public mp::logging::Logger { - void log(mpl::Level level, + void log(mpl::Level /*level*/, std::string_view /*category*/, std::string_view message) const override { diff --git a/tests/unit/sftp_server_test_fixture.h b/tests/unit/sftp_server_test_fixture.h index 196ea4a850..15d8d668a2 100644 --- a/tests/unit/sftp_server_test_fixture.h +++ b/tests/unit/sftp_server_test_fixture.h @@ -29,7 +29,7 @@ struct SftpServerTest : public testing::Test { SftpServerTest() : sftp_server_new{mock_sftp_server_new, - [](ssh_session session, ssh_channel chan) -> sftp_session { + [](ssh_session, ssh_channel) -> sftp_session { auto sftp = static_cast( std::calloc(1, sizeof(struct sftp_session_struct))); return sftp; diff --git a/tests/unit/stub_cert_store.h b/tests/unit/stub_cert_store.h index 67946cbcb8..efde4fb157 100644 --- a/tests/unit/stub_cert_store.h +++ b/tests/unit/stub_cert_store.h @@ -26,7 +26,7 @@ namespace test class StubCertStore : public CertStore { public: - void add_cert(const std::string& pem_cert) override + void add_cert(const std::string& /*pem_cert*/) override { } @@ -35,7 +35,7 @@ class StubCertStore : public CertStore return {}; } - bool verify_cert(const std::string& pem_cert) override + bool verify_cert(const std::string& /*pem_cert*/) override { return true; } diff --git a/tests/unit/stub_image_host.h b/tests/unit/stub_image_host.h index 8652a209a3..51b37fe65a 100644 --- a/tests/unit/stub_image_host.h +++ b/tests/unit/stub_image_host.h @@ -25,25 +25,25 @@ namespace test { struct StubVMImageHost final : public multipass::VMImageHost { - std::optional info_for(const multipass::Query& query) const override + std::optional info_for(const multipass::Query&) const override { return std::optional{ VMImageInfo{{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, -1, {}}}; }; std::vector> all_info_for( - const multipass::Query& query) const override + const multipass::Query&) const override { return {}; }; - multipass::VMImageInfo info_for_full_hash(const std::string& full_hash) const override + multipass::VMImageInfo info_for_full_hash(const std::string& /*full_hash*/) const override { return {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, -1, {}}; }; - std::vector all_images_for(const std::string& remote_name, - bool allow_unsupported) const override + std::vector all_images_for(const std::string& /*remote_name*/, + bool /*allow_unsupported*/) const override { return {}; }; @@ -57,7 +57,7 @@ struct StubVMImageHost final : public multipass::VMImageHost return {}; } - void update_manifests(bool force_update) override + void update_manifests(bool /*force_update*/) override { } }; diff --git a/tests/unit/stub_virtual_machine.h b/tests/unit/stub_virtual_machine.h index bf248c8d01..5ea8aab2bf 100644 --- a/tests/unit/stub_virtual_machine.h +++ b/tests/unit/stub_virtual_machine.h @@ -49,7 +49,7 @@ struct StubVirtualMachine final : public multipass::VirtualMachine { } - void shutdown(ShutdownPolicy shutdown_policy = ShutdownPolicy::Powerdown) override + void shutdown(ShutdownPolicy = ShutdownPolicy::Powerdown) override { } @@ -91,7 +91,7 @@ struct StubVirtualMachine final : public multipass::VirtualMachine return {IPAddress{"192.168.2.123"}}; } - std::string ssh_exec(const std::string& cmd, bool whisper = false) override + std::string ssh_exec(const std::string& /*cmd*/, bool /*whisper*/ = false) override { return {}; } @@ -100,7 +100,7 @@ struct StubVirtualMachine final : public multipass::VirtualMachine { } - void wait_for_cloud_init(std::chrono::milliseconds timeout) override + void wait_for_cloud_init(std::chrono::milliseconds /*timeout*/) override { } @@ -108,7 +108,7 @@ struct StubVirtualMachine final : public multipass::VirtualMachine { } - void update_cpus(int num_cores) override + void update_cpus(int /*num_cores*/) override { } @@ -167,7 +167,7 @@ struct StubVirtualMachine final : public multipass::VirtualMachine return {}; } - void rename_snapshot(const std::string& old_name, const std::string& new_name) override + void rename_snapshot(const std::string& /*old_name*/, const std::string& /*new_name*/) override { } @@ -175,7 +175,7 @@ struct StubVirtualMachine final : public multipass::VirtualMachine { } - void restore_snapshot(const std::string& name, VMSpecs& specs) override + void restore_snapshot(const std::string& /*name*/, VMSpecs& /*specs*/) override { } diff --git a/tests/unit/stub_virtual_machine_factory.h b/tests/unit/stub_virtual_machine_factory.h index 6977af2e5a..03f21738cb 100644 --- a/tests/unit/stub_virtual_machine_factory.h +++ b/tests/unit/stub_virtual_machine_factory.h @@ -47,7 +47,7 @@ struct StubVirtualMachineFactory : public multipass::BaseVirtualMachineFactory return std::make_unique(); } - void remove_resources_for_impl(const std::string& name) override + void remove_resources_for_impl(const std::string&) override { } @@ -56,8 +56,8 @@ struct StubVirtualMachineFactory : public multipass::BaseVirtualMachineFactory return source_image; } - void prepare_instance_image(const multipass::VMImage& instance_image, - const multipass::VirtualMachineDescription& vm_desc) override + void prepare_instance_image(const multipass::VMImage&, + const multipass::VirtualMachineDescription&) override { } @@ -70,7 +70,7 @@ struct StubVirtualMachineFactory : public multipass::BaseVirtualMachineFactory return {}; } - QString get_instance_directory(const std::string& name) const override + QString get_instance_directory(const std::string&) const override { return tmp_dir->path(); } @@ -80,11 +80,11 @@ struct StubVirtualMachineFactory : public multipass::BaseVirtualMachineFactory return "stub-5678"; } - multipass::VMImageVault::UPtr create_image_vault(std::vector image_hosts, - URLDownloader* downloader, - const Path& cache_dir_path, - const Path& data_dir_path, - const days& days_to_expire) override + multipass::VMImageVault::UPtr create_image_vault(std::vector /*image_hosts*/, + URLDownloader* /*downloader*/, + const Path& /*cache_dir_path*/, + const Path& /*data_dir_path*/, + const days& /*days_to_expire*/) override { return std::make_unique(); } diff --git a/tests/unit/stub_vm_image_vault.h b/tests/unit/stub_vm_image_vault.h index a3ce937fd8..7d680297f4 100644 --- a/tests/unit/stub_vm_image_vault.h +++ b/tests/unit/stub_vm_image_vault.h @@ -45,19 +45,19 @@ struct StubVMImageVault final : public multipass::VMImageVault } void prune_expired_images() override{}; - void update_images(const PrepareAction& prepare, const ProgressMonitor& monitor) override {}; + void update_images(const PrepareAction&, const ProgressMonitor&) override {}; - MemorySize minimum_image_size_for(const std::string& image) override + MemorySize minimum_image_size_for(const std::string& /*image*/) override { return MemorySize{}; } - VMImageHost* image_host_for(const std::string& remote_name) const override + VMImageHost* image_host_for(const std::string& /*remote_name*/) const override { return nullptr; } - std::vector> all_info_for(const Query& query) const override + std::vector> all_info_for(const Query&) const override { return std::vector>{ std::pair{"default", @@ -75,8 +75,8 @@ struct StubVMImageVault final : public multipass::VMImageVault true}}}; } - void clone(const std::string& source_instance_name, - const std::string& destination_instance_name) override + void clone(const std::string& /*src*/, + const std::string& /*dst*/) override { } diff --git a/tests/unit/test_base_virtual_machine.cpp b/tests/unit/test_base_virtual_machine.cpp index 516925b997..d8308ecb53 100644 --- a/tests/unit/test_base_virtual_machine.cpp +++ b/tests/unit/test_base_virtual_machine.cpp @@ -146,7 +146,7 @@ struct StubBaseVirtualMachine : public mp::BaseVirtualMachine state = St::running; } - void shutdown(ShutdownPolicy shutdown_policy = ShutdownPolicy::Powerdown) override + void shutdown(ShutdownPolicy = ShutdownPolicy::Powerdown) override { state = St::off; } @@ -189,7 +189,7 @@ struct StubBaseVirtualMachine : public mp::BaseVirtualMachine { } - void update_cpus(int num_cores) override + void update_cpus(int /*num_cores*/) override { } @@ -345,7 +345,7 @@ TEST_P(IpExecution, getAllIpv4WorksWhenSshWorks) }; REPLACE(ssh_add_channel_callbacks, add_channel_cbs); - auto event_dopoll = [&callbacks, &test_params](ssh_event, int timeout) { + auto event_dopoll = [&callbacks, &test_params](ssh_event, int /*timeout*/) { EXPECT_TRUE(callbacks); callbacks->channel_exit_status_function(nullptr, nullptr, @@ -356,7 +356,7 @@ TEST_P(IpExecution, getAllIpv4WorksWhenSshWorks) REPLACE(ssh_event_dopoll, event_dopoll); auto channel_read = [&test_params, - &remaining](ssh_channel, void* dest, uint32_t count, int is_stderr, int) { + &remaining](ssh_channel, void* dest, uint32_t count, int, int) { const auto num_to_copy = std::min(count, static_cast(remaining)); const auto begin = test_params.output.begin() + test_params.output.size() - remaining; std::copy_n(begin, num_to_copy, reinterpret_cast(dest)); diff --git a/tests/unit/test_cli_client.cpp b/tests/unit/test_cli_client.cpp index 760933e4a9..59017a01dd 100644 --- a/tests/unit/test_cli_client.cpp +++ b/tests/unit/test_cli_client.cpp @@ -1845,7 +1845,7 @@ TEST_P(SSHClientReturnTest, execCmdWithoutDirWorks) }); EXPECT_CALL(mock_daemon, ssh_info(_, _)) .WillOnce( - [&response](grpc::ServerContext* context, + [&response](grpc::ServerContext*, grpc::ServerReaderWriter* server) { server->Write(response); return grpc::Status{}; @@ -1871,7 +1871,7 @@ TEST_P(SSHClientReturnTest, execCmdWithDirWorks) }); EXPECT_CALL(mock_daemon, ssh_info(_, _)) .WillOnce( - [&response](grpc::ServerContext* context, + [&response](grpc::ServerContext*, grpc::ServerReaderWriter* server) { server->Write(response); return grpc::Status{}; @@ -1906,7 +1906,7 @@ TEST_F(Client, execCmdWithDirPrependsCd) EXPECT_CALL(mock_daemon, ssh_info(_, _)) .WillOnce( - [&response](grpc::ServerContext* context, + [&response](grpc::ServerContext*, grpc::ServerReaderWriter* server) { server->Write(response); return grpc::Status{}; @@ -1945,7 +1945,7 @@ TEST_F(Client, execCmdWithDirAndSudoUsesSh) EXPECT_CALL(mock_daemon, ssh_info(_, _)) .WillOnce( - [&response](grpc::ServerContext* context, + [&response](grpc::ServerContext*, grpc::ServerReaderWriter* server) { server->Write(response); return grpc::Status{}; @@ -1963,7 +1963,7 @@ TEST_F(Client, execCmdFailsIfSshExecThrows) std::string dir{"/home/ubuntu/"}; std::string cmd{"pwd"}; - REPLACE(ssh_channel_request_exec, ([](ssh_channel, const char* raw_cmd) { + REPLACE(ssh_channel_request_exec, ([](ssh_channel, const char*) { throw mp::SSHException("some exception"); return SSH_OK; })); @@ -1975,7 +1975,7 @@ TEST_F(Client, execCmdFailsIfSshExecThrows) EXPECT_CALL(mock_daemon, ssh_info(_, _)) .WillOnce( - [&response](grpc::ServerContext* context, + [&response](grpc::ServerContext*, grpc::ServerReaderWriter* server) { server->Write(response); return grpc::Status{}; @@ -4059,8 +4059,8 @@ struct TimeoutSuite : Client, WithParamInterface } template - static grpc::Status request_sleeper(grpc::ServerContext* context, - grpc::ServerReaderWriter* response) + static grpc::Status request_sleeper(grpc::ServerContext*, + grpc::ServerReaderWriter*) { std::this_thread::sleep_for(std::chrono::seconds(2)); return grpc::Status::OK; @@ -4936,7 +4936,7 @@ TEST_F(ClientAlias, execAliasRewritesMountedDir) EXPECT_CALL(mock_daemon, ssh_info(_, _)) .WillOnce([&ssh_info_response]( - grpc::ServerContext* context, + grpc::ServerContext*, grpc::ServerReaderWriter* server) { server->Write(ssh_info_response); @@ -4989,7 +4989,7 @@ TEST_P(NotDirRewriteTestsuite, execAliasDoesNotRewriteMountedDir) EXPECT_CALL(mock_daemon, ssh_info(_, _)) .WillOnce([&ssh_info_response]( - grpc::ServerContext* context, + grpc::ServerContext*, grpc::ServerReaderWriter* server) { server->Write(ssh_info_response); diff --git a/tests/unit/test_custom_image_host.cpp b/tests/unit/test_custom_image_host.cpp index c7e6c50963..b59d859381 100644 --- a/tests/unit/test_custom_image_host.cpp +++ b/tests/unit/test_custom_image_host.cpp @@ -80,7 +80,7 @@ TEST_F(CustomImageHost, iteratesOverAllEntries) host.update_manifests(false); std::unordered_set ids; - auto action = [&ids](const std::string& remote, const mp::VMImageInfo& info) { + auto action = [&ids](const std::string& /*remote*/, const mp::VMImageInfo& info) { ids.insert(info.id.toStdString()); }; host.for_each_entry_do(action); diff --git a/tests/unit/test_daemon_find.cpp b/tests/unit/test_daemon_find.cpp index 8712bbd831..a24f3fd414 100644 --- a/tests/unit/test_daemon_find.cpp +++ b/tests/unit/test_daemon_find.cpp @@ -91,7 +91,7 @@ TEST_F(DaemonFind, queryForDefaultReturnsExpectedData) { auto mock_image_vault = std::make_unique>(); - EXPECT_CALL(*mock_image_vault, all_info_for(_)).WillOnce([](const mp::Query& query) { + EXPECT_CALL(*mock_image_vault, all_info_for(_)).WillOnce([](const mp::Query&) { mpt::MockImageHost mock_image_host; std::vector> info; info.push_back(std::make_pair(mpt::release_remote, mock_image_host.mock_bionic_image_info)); diff --git a/tests/unit/test_exception.cpp b/tests/unit/test_exception.cpp index 408e0c9529..b15334e298 100644 --- a/tests/unit/test_exception.cpp +++ b/tests/unit/test_exception.cpp @@ -66,8 +66,8 @@ struct fmt::formatter } template - fmt::context::iterator format(const AngryTypeThatThrowsUnexpectedThings& api, - FormatContext& ctx) const + fmt::context::iterator format(const AngryTypeThatThrowsUnexpectedThings&, + FormatContext&) const { // What an unusual sight. throw int{5}; diff --git a/tests/unit/test_image_vault.cpp b/tests/unit/test_image_vault.cpp index 4e62457bb8..d734fd2547 100644 --- a/tests/unit/test_image_vault.cpp +++ b/tests/unit/test_image_vault.cpp @@ -62,16 +62,16 @@ struct BadURLDownloader : public mp::URLDownloader BadURLDownloader() : mp::URLDownloader{std::chrono::seconds(10)} { } - void download_to(const QUrl& url, + void download_to(const QUrl& /*url*/, const QString& file_name, - int64_t size, - const int download_type, + int64_t /*size*/, + const int /*download_type*/, const mp::ProgressMonitor&) override { mpt::make_file_with_content(file_name, "Bad hash"); } - QByteArray download(const QUrl& url) override + QByteArray download(const QUrl& /*url*/) override { return {}; } @@ -84,8 +84,8 @@ struct HttpURLDownloader : public mp::URLDownloader } void download_to(const QUrl& url, const QString& file_name, - int64_t size, - const int download_type, + int64_t /*size*/, + const int /*download_type*/, const mp::ProgressMonitor&) override { mpt::make_file_with_content(file_name, ""); @@ -93,12 +93,12 @@ struct HttpURLDownloader : public mp::URLDownloader downloaded_files << file_name; } - QByteArray download(const QUrl& url) override + QByteArray download(const QUrl& /*url*/) override { return {}; } - QDateTime last_modified(const QUrl& url) override + QDateTime last_modified(const QUrl& /*url*/) override { return default_last_modified; } @@ -112,10 +112,10 @@ struct RunningURLDownloader : public mp::URLDownloader RunningURLDownloader() : mp::URLDownloader{std::chrono::seconds(10)} { } - void download_to(const QUrl& url, - const QString& file_name, - int64_t size, - const int download_type, + void download_to(const QUrl& /*url*/, + const QString& /*file_name*/, + int64_t /*size*/, + const int /*download_type*/, const mp::ProgressMonitor&) override { while (!abort_downloads) @@ -124,7 +124,7 @@ struct RunningURLDownloader : public mp::URLDownloader throw mp::AbortedDownloadException("Aborted!"); } - QByteArray download(const QUrl& url) override + QByteArray download(const QUrl& /*url*/) override { return {}; } diff --git a/tests/unit/test_mount_handler.cpp b/tests/unit/test_mount_handler.cpp index e07858b229..facc7828d5 100644 --- a/tests/unit/test_mount_handler.cpp +++ b/tests/unit/test_mount_handler.cpp @@ -37,11 +37,11 @@ struct PublicMountHandler : public mp::MountHandler { } - void activate_impl(mp::ServerVariant server, std::chrono::milliseconds timeout) override + void activate_impl(mp::ServerVariant, std::chrono::milliseconds) override { } - void deactivate_impl(bool force) override + void deactivate_impl(bool) override { } }; diff --git a/tests/unit/test_qemu_img_utils.cpp b/tests/unit/test_qemu_img_utils.cpp index 1d89224f41..1f311a1f94 100644 --- a/tests/unit/test_qemu_img_utils.cpp +++ b/tests/unit/test_qemu_img_utils.cpp @@ -152,7 +152,7 @@ void simulate_qemuimg_amend(const mpt::MockProcess* process, template void test_image_resizing(const char* img, - const mp::MemorySize& img_virtual_size, + const mp::MemorySize& /*img_virtual_size*/, const mp::MemorySize& requested_size, const mp::ProcessState& qemuimg_resize_result, std::optional throw_msg_matcher) diff --git a/tests/unit/test_sftp_client.cpp b/tests/unit/test_sftp_client.cpp index 734bec8b1e..d7132c6347 100644 --- a/tests/unit/test_sftp_client.cpp +++ b/tests/unit/test_sftp_client.cpp @@ -73,7 +73,7 @@ struct SFTPClient : public testing::Test { SFTPClient() : sftp_new{mock_sftp_new, - [](ssh_session session) -> sftp_session { + [](ssh_session) -> sftp_session { auto sftp = static_cast( std::calloc(1, sizeof(struct sftp_session_struct))); return sftp; @@ -820,7 +820,7 @@ TEST_F(SFTPClient, pullDirSuccessRegular) .WillOnce(Return(std::make_unique(test_file.rdbuf()))); REPLACE(sftp_open, [](auto sftp, auto...) { return get_dummy_sftp_file(sftp); }); - auto mocked_sftp_read = [&, read = false](auto, const void* data, auto size) mutable { + auto mocked_sftp_read = [&, read = false](auto, const void* data, auto /*size*/) mutable { strcpy((char*)data, test_data.c_str()); return (read = !read) ? test_data.size() : 0; }; diff --git a/tests/unit/test_sftpserver.cpp b/tests/unit/test_sftpserver.cpp index 403078d469..91f6a9d6a4 100644 --- a/tests/unit/test_sftpserver.cpp +++ b/tests/unit/test_sftpserver.cpp @@ -474,7 +474,7 @@ TEST_F(SftpServer, handlesRealpath) bool invoked{false}; auto reply_name = [&msg, &invoked, &file_name](sftp_client_message cmsg, const char* name, - sftp_attributes attr) { + sftp_attributes) { EXPECT_THAT(cmsg, Eq(msg.get())); EXPECT_THAT(name, StrEq(file_name.data())); invoked = true; @@ -3117,7 +3117,7 @@ TEST_P(PathValidation, validatesAccordingToRequest) int num_calls_attr{0}; auto reply_attr = [&num_calls_attr, &msg, expected_status = params.expected_status](sftp_client_message m, - sftp_attributes attr) { + sftp_attributes) { EXPECT_THAT(m, Eq(msg.get())); EXPECT_THAT(expected_status, Eq(SSH_FX_OK)); // We only expect this if SSH_FX_OK was the goal @@ -3513,7 +3513,7 @@ TEST_F(SftpServer, canonicalErrorPermissionDenied) }); EXPECT_CALL(*file_ops, weakly_canonical) .WillOnce([](const fs::path& path) { return fs::weakly_canonical(path); }) - .WillRepeatedly([](const fs::path& path) { + .WillRepeatedly([](const fs::path&) { throw fs::filesystem_error(std::string{}, std::error_code{}); return fs::path(); }); diff --git a/tests/unit/test_ssh_process.cpp b/tests/unit/test_ssh_process.cpp index 43618831e9..7fc4b146f0 100644 --- a/tests/unit/test_ssh_process.cpp +++ b/tests/unit/test_ssh_process.cpp @@ -135,7 +135,7 @@ TEST_F(SSHProcess, canReadOutput) std::string expected_output{"some content here"}; auto remaining = expected_output.size(); auto channel_read = [&expected_output, - &remaining](ssh_channel, void* dest, uint32_t count, int is_stderr, int) { + &remaining](ssh_channel, void* dest, uint32_t count, int, int) { const auto num_to_copy = std::min(count, static_cast(remaining)); const auto begin = expected_output.begin() + expected_output.size() - remaining; std::copy_n(begin, num_to_copy, reinterpret_cast(dest)); diff --git a/tests/unit/test_sshfsmount.cpp b/tests/unit/test_sshfsmount.cpp index a539743f1d..4148ae146e 100644 --- a/tests/unit/test_sshfsmount.cpp +++ b/tests/unit/test_sshfsmount.cpp @@ -161,7 +161,7 @@ struct SshfsMount : public mp::test::SftpServerTest auto channel_read = [&output, &remaining, - &prereq_invoked](ssh_channel, void* dest, uint32_t count, int is_stderr, int) { + &prereq_invoked](ssh_channel, void* dest, uint32_t count, int, int) { if (!prereq_invoked) return 0u; const auto num_to_copy = std::min(count, static_cast(remaining)); diff --git a/tests/unit/test_ubuntu_image_host.cpp b/tests/unit/test_ubuntu_image_host.cpp index 8b13162d53..eb20b1ec16 100644 --- a/tests/unit/test_ubuntu_image_host.cpp +++ b/tests/unit/test_ubuntu_image_host.cpp @@ -169,7 +169,7 @@ TEST_F(UbuntuImageHost, iteratesOverAllEntries) host.update_manifests(false); std::unordered_set ids; - auto action = [&ids](const std::string& remote, const mp::VMImageInfo& info) { + auto action = [&ids](const std::string& /*remote*/, const mp::VMImageInfo& info) { ids.insert(info.id.toStdString()); }; host.for_each_entry_do(action); diff --git a/tests/unit/tracking_url_downloader.h b/tests/unit/tracking_url_downloader.h index 1c82b45569..11105eb174 100644 --- a/tests/unit/tracking_url_downloader.h +++ b/tests/unit/tracking_url_downloader.h @@ -38,8 +38,8 @@ struct TrackingURLDownloader : public URLDownloader void download_to(const QUrl& url, const QString& file_name, - int64_t size, - const int download_type, + int64_t /*size*/, + const int /*download_type*/, const ProgressMonitor&) override { make_file_with_content(file_name, content); @@ -47,12 +47,12 @@ struct TrackingURLDownloader : public URLDownloader downloaded_files << file_name; } - QByteArray download(const QUrl& url) override + QByteArray download(const QUrl&) override { return {}; } - QDateTime last_modified(const QUrl& url) override + QDateTime last_modified(const QUrl&) override { return QDateTime::currentDateTime(); } From 8047af56fdfd1d3d035577f68cc1269f077dbe84 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 22:42:16 +0100 Subject: [PATCH 09/15] [tests] Replace lambda with action Replace lambda with gmock action, removing another couple of unused-parameter cases. --- .../qemu/linux/test_qemu_platform_linux.cpp | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/tests/unit/qemu/linux/test_qemu_platform_linux.cpp b/tests/unit/qemu/linux/test_qemu_platform_linux.cpp index 4162342954..26884af3dc 100644 --- a/tests/unit/qemu/linux/test_qemu_platform_linux.cpp +++ b/tests/unit/qemu/linux/test_qemu_platform_linux.cpp @@ -233,7 +233,7 @@ TEST_F(QemuPlatformLinux, platformArgsGenerateNetResourcesRemovesWorksAsExpected vm_desc.default_mac_address = vswitch.hw_addr; vm_desc.extra_interfaces = {extra_interface}; - QString tap_name; + QStringList saved_opts; EXPECT_CALL(*mock_dnsmasq_server, release_mac(vswitch.hw_addr, vswitch.bridge_name)) .WillOnce(Return()); @@ -244,10 +244,7 @@ TEST_F(QemuPlatformLinux, platformArgsGenerateNetResourcesRemovesWorksAsExpected QString("ip"), ElementsAre(QString("addr"), QString("show"), mpt::match_qstring(StartsWith("tap-"))), _)) - .WillOnce([&tap_name](auto& cmd, auto& opts, auto...) { - tap_name = opts.last(); - return false; - }); + .WillOnce(DoAll(SaveArg<1>(&saved_opts), Return(false))); mp::QemuPlatformLinux qemu_platform_linux{data_dir.path(), stub_zones}; @@ -288,7 +285,7 @@ TEST_F(QemuPlatformLinux, platformArgsGenerateNetResourcesRemovesWorksAsExpected // clang-format on "-nic", QString::fromStdString(fmt::format("tap,ifname={},script=no,downscript=no,model={},mac={}", - tap_name, + saved_opts.last(), network_interface, vm_desc.default_mac_address)), "-nic", @@ -302,12 +299,12 @@ TEST_F(QemuPlatformLinux, platformArgsGenerateNetResourcesRemovesWorksAsExpected EXPECT_CALL(*mock_utils, run_cmd_for_status(QString("ip"), - ElementsAre(QString("addr"), QString("show"), tap_name), + ElementsAre(QString("addr"), QString("show"), saved_opts.last()), _)) .WillOnce(Return(true)); EXPECT_CALL(*mock_utils, run_cmd_for_status(QString("ip"), - ElementsAre(QString("link"), QString("delete"), tap_name), + ElementsAre(QString("link"), QString("delete"), saved_opts.last()), _)) .WillOnce(Return(true)); @@ -325,7 +322,7 @@ TEST_F(QemuPlatformLinux, tapDevicesAreRemovedOnDestruction) vm_desc.default_mac_address = vswitch.hw_addr; vm_desc.extra_interfaces = {extra_interface}; - QString tap_name; + QStringList saved_opts; EXPECT_CALL( *mock_utils, @@ -333,10 +330,7 @@ TEST_F(QemuPlatformLinux, tapDevicesAreRemovedOnDestruction) QString("ip"), ElementsAre(QString("addr"), QString("show"), mpt::match_qstring(StartsWith("tap-"))), _)) - .WillOnce([&tap_name](auto& cmd, auto& opts, auto...) { - tap_name = opts.last(); - return false; - }); + .WillOnce(DoAll(SaveArg<1>(&saved_opts), Return(false))); mp::QemuPlatformLinux qemu_platform_linux{data_dir.path(), stub_zones}; @@ -344,12 +338,12 @@ TEST_F(QemuPlatformLinux, tapDevicesAreRemovedOnDestruction) EXPECT_CALL(*mock_utils, run_cmd_for_status(QString("ip"), - ElementsAre(QString("addr"), QString("show"), tap_name), + ElementsAre(QString("addr"), QString("show"), saved_opts.last()), _)) .WillOnce(Return(true)); EXPECT_CALL(*mock_utils, run_cmd_for_status(QString("ip"), - ElementsAre(QString("link"), QString("delete"), tap_name), + ElementsAre(QString("link"), QString("delete"), saved_opts.last()), _)) .WillOnce(Return(true)); } From 3ba451ba59ac4e76f34b21b1dca7f8d5bf25e5d4 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 22:44:59 +0100 Subject: [PATCH 10/15] [warn] Fix a couple more unused params --- tests/unit/test_base_virtual_machine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_base_virtual_machine.cpp b/tests/unit/test_base_virtual_machine.cpp index d8308ecb53..d766e8e879 100644 --- a/tests/unit/test_base_virtual_machine.cpp +++ b/tests/unit/test_base_virtual_machine.cpp @@ -511,14 +511,14 @@ TEST_F(BaseVM, providesSnapshotsView) { // Select nothing - auto snapshots = vm.view_snapshots([&](const auto& snapshot) { return false; }); + auto snapshots = vm.view_snapshots([&](const auto&) { return false; }); EXPECT_THAT(snapshots, SizeIs(0)); } { // Select everything - auto snapshots = vm.view_snapshots([&](const auto& snapshot) { return true; }); + auto snapshots = vm.view_snapshots([&](const auto&) { return true; }); EXPECT_THAT(snapshots, SizeIs(4)); } From 855a7728a4da274bfdffc5161115eb7af6b064c5 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 22:46:22 +0100 Subject: [PATCH 11/15] [tests] Avoid unnecessary captures --- tests/unit/test_base_virtual_machine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_base_virtual_machine.cpp b/tests/unit/test_base_virtual_machine.cpp index d766e8e879..a36710a283 100644 --- a/tests/unit/test_base_virtual_machine.cpp +++ b/tests/unit/test_base_virtual_machine.cpp @@ -511,21 +511,21 @@ TEST_F(BaseVM, providesSnapshotsView) { // Select nothing - auto snapshots = vm.view_snapshots([&](const auto&) { return false; }); + auto snapshots = vm.view_snapshots([](const auto&) { return false; }); EXPECT_THAT(snapshots, SizeIs(0)); } { // Select everything - auto snapshots = vm.view_snapshots([&](const auto&) { return true; }); + auto snapshots = vm.view_snapshots([](const auto&) { return true; }); EXPECT_THAT(snapshots, SizeIs(4)); } { // Select index 2 and 5 - auto snapshots = vm.view_snapshots([&](const multipass::Snapshot& snapshot) { + auto snapshots = vm.view_snapshots([](const multipass::Snapshot& snapshot) { return snapshot.get_index() == 2 || snapshot.get_index() == 5; }); From 9966dc3aa12f37b7ecefb93dc55fe7e6fa0d7aa1 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 23:46:57 +0100 Subject: [PATCH 12/15] [cmake] Stop disabling specific warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤞 --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b70427d016..edb4ac1e03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -311,10 +311,6 @@ else() add_compile_options(-Wcast-align) endif() - CHECK_CXX_COMPILER_FLAG("-Wno-expansion-to-defined" COMPILER_SUPPORTS_NO_EXP_TO_DEFINED) - if(COMPILER_SUPPORTS_NO_EXP_TO_DEFINED) - add_compile_options(-Wno-expansion-to-defined) - endif() add_definitions(-DMULTIPASS_PLATFORM_LINUX) set(MULTIPASS_PLATFORM linux) From d51d9b734eaad3fd9ea7cc2a6cc06034912879bb Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Tue, 9 Jun 2026 23:50:33 +0100 Subject: [PATCH 13/15] [cmake] Improve format --- 3rd-party/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/3rd-party/CMakeLists.txt b/3rd-party/CMakeLists.txt index b1f8e7e15c..19324e6933 100644 --- a/3rd-party/CMakeLists.txt +++ b/3rd-party/CMakeLists.txt @@ -25,7 +25,10 @@ target_link_libraries(gRPC INTERFACE protobuf::libprotobuf) if (NOT MSVC) - target_compile_options(gRPC INTERFACE "-Wno-unused-parameter" "-Wno-non-virtual-dtor" "-Wno-pedantic") + target_compile_options(gRPC INTERFACE + "-Wno-unused-parameter" + "-Wno-non-virtual-dtor" + "-Wno-pedantic") endif () include(ExternalProject) From ce58db9a31b6abcf90a7edafcc1de6a9d9b090b7 Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Wed, 10 Jun 2026 01:11:26 +0100 Subject: [PATCH 14/15] [progress] Fix param name to match intended arg --- include/multipass/progress_monitor.h | 2 +- include/multipass/url_downloader.h | 2 +- src/daemon/daemon.cpp | 2 +- src/network/url_downloader.cpp | 6 +++--- tests/unit/mischievous_url_downloader.cpp | 4 ++-- tests/unit/mischievous_url_downloader.h | 2 +- tests/unit/test_image_vault.cpp | 6 +++--- tests/unit/test_url_downloader.cpp | 8 ++++---- tests/unit/tracking_url_downloader.h | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/multipass/progress_monitor.h b/include/multipass/progress_monitor.h index 675d0a59a3..48704ee513 100644 --- a/include/multipass/progress_monitor.h +++ b/include/multipass/progress_monitor.h @@ -23,5 +23,5 @@ namespace multipass { -using ProgressMonitor = std::function; +using ProgressMonitor = std::function; } diff --git a/include/multipass/url_downloader.h b/include/multipass/url_downloader.h index 60f3943814..ef7e682326 100644 --- a/include/multipass/url_downloader.h +++ b/include/multipass/url_downloader.h @@ -55,7 +55,7 @@ class URLDownloader : private DisabledCopyMove virtual void download_to(const QUrl& url, const QString& file_name, int64_t size, - const int download_type, + const int progress_type, const ProgressMonitor& monitor); virtual QByteArray download(const QUrl& url); virtual QByteArray download(const QUrl& url, const bool force_update); diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index a3288a6b48..a601cba4a1 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -279,7 +279,7 @@ auto fetch_image_for(const std::string& name, mp::VMImageVault& vault) { auto stub_prepare = [](const mp::VMImage&) -> mp::VMImage { return {}; }; - auto stub_progress = [](int /*download_type*/, int /*progress*/) { return true; }; + auto stub_progress = [](int /*progress_type*/, int /*progress*/) { return true; }; mp::Query query{name, "", false, "", mp::Query::Type::Alias, false}; diff --git a/src/network/url_downloader.cpp b/src/network/url_downloader.cpp index 5b087b06a7..a94bf99e26 100644 --- a/src/network/url_downloader.cpp +++ b/src/network/url_downloader.cpp @@ -242,7 +242,7 @@ mp::URLDownloader::URLDownloader(const mp::Path& cache_dir, std::chrono::millise void mp::URLDownloader::download_to(const QUrl& url, const QString& file_name, int64_t size, - const int download_type, + const int progress_type, const mp::ProgressMonitor& monitor) { std::atomic_bool abort_download{false}; @@ -253,7 +253,7 @@ void mp::URLDownloader::download_to(const QUrl& url, throw std::runtime_error( fmt::format("unable to write to file \"{}\"", file_name.toStdString())); - auto progress_monitor = [this, &abort_download, &monitor, download_type, size]( + auto progress_monitor = [this, &abort_download, &monitor, progress_type, size]( QNetworkReply* reply, qint64 bytes_received, qint64 bytes_total) { @@ -267,7 +267,7 @@ void mp::URLDownloader::download_to(const QUrl& url, auto progress = (size < 0) ? size : (100 * bytes_received + bytes_total / 2) / bytes_total; abort_download = abort_downloads || - (last_progress_printed != progress && !monitor(download_type, progress)); + (last_progress_printed != progress && !monitor(progress_type, progress)); last_progress_printed = progress; if (abort_download) diff --git a/tests/unit/mischievous_url_downloader.cpp b/tests/unit/mischievous_url_downloader.cpp index 3f7d34b3f0..2f43a51902 100644 --- a/tests/unit/mischievous_url_downloader.cpp +++ b/tests/unit/mischievous_url_downloader.cpp @@ -28,10 +28,10 @@ mpt::MischievousURLDownloader::MischievousURLDownloader(std::chrono::millisecond void mpt::MischievousURLDownloader::download_to(const QUrl& url, const QString& file_name, int64_t size, - const int download_type, + const int progress_type, const mp::ProgressMonitor& monitor) { - URLDownloader::download_to(choose_url(url), file_name, size, download_type, monitor); + URLDownloader::download_to(choose_url(url), file_name, size, progress_type, monitor); } QByteArray mpt::MischievousURLDownloader::download(const QUrl& url) diff --git a/tests/unit/mischievous_url_downloader.h b/tests/unit/mischievous_url_downloader.h index 054a78f99c..74034ba9b8 100644 --- a/tests/unit/mischievous_url_downloader.h +++ b/tests/unit/mischievous_url_downloader.h @@ -33,7 +33,7 @@ class MischievousURLDownloader : public URLDownloader void download_to(const QUrl& url, const QString& file_name, int64_t size, - const int download_type, + const int progress_type, const ProgressMonitor& monitor) override; QByteArray download(const QUrl& url) override; QByteArray download(const QUrl& url, const bool force_update) override; diff --git a/tests/unit/test_image_vault.cpp b/tests/unit/test_image_vault.cpp index d734fd2547..28e7e31a0b 100644 --- a/tests/unit/test_image_vault.cpp +++ b/tests/unit/test_image_vault.cpp @@ -65,7 +65,7 @@ struct BadURLDownloader : public mp::URLDownloader void download_to(const QUrl& /*url*/, const QString& file_name, int64_t /*size*/, - const int /*download_type*/, + const int /*progress_type*/, const mp::ProgressMonitor&) override { mpt::make_file_with_content(file_name, "Bad hash"); @@ -85,7 +85,7 @@ struct HttpURLDownloader : public mp::URLDownloader void download_to(const QUrl& url, const QString& file_name, int64_t /*size*/, - const int /*download_type*/, + const int /*progress_type*/, const mp::ProgressMonitor&) override { mpt::make_file_with_content(file_name, ""); @@ -115,7 +115,7 @@ struct RunningURLDownloader : public mp::URLDownloader void download_to(const QUrl& /*url*/, const QString& /*file_name*/, int64_t /*size*/, - const int /*download_type*/, + const int /*progress_type*/, const mp::ProgressMonitor&) override { while (!abort_downloads) diff --git a/tests/unit/test_url_downloader.cpp b/tests/unit/test_url_downloader.cpp index dd726ceabb..1671de4095 100644 --- a/tests/unit/test_url_downloader.cpp +++ b/tests/unit/test_url_downloader.cpp @@ -181,7 +181,7 @@ TEST_F(URLDownloader, fileDownloadNoErrorHasExpectedResults) { mpt::MockQNetworkReply* mock_reply = new mpt::MockQNetworkReply(); const QByteArray test_data{"This is some data to put in a file when downloaded."}; - const int download_type{-1}; + const int progress_type{-1}; EXPECT_CALL(*mock_network_access_manager, createRequest(_, _, _)) .WillOnce([&mock_reply, &test_data](auto...) { @@ -203,8 +203,8 @@ TEST_F(URLDownloader, fileDownloadNoErrorHasExpectedResults) .WillRepeatedly(Return(0)); bool progress_called{false}; - auto progress_monitor = [download_type, &progress_called](int type, int progress) { - EXPECT_EQ(type, download_type); + auto progress_monitor = [progress_type, &progress_called](int type, int progress) { + EXPECT_EQ(type, progress_type); EXPECT_EQ(progress, 100); progress_called = true; @@ -224,7 +224,7 @@ TEST_F(URLDownloader, fileDownloadNoErrorHasExpectedResults) downloader.download_to(fake_url, download_file, test_data.size(), - download_type, + progress_type, progress_monitor); EXPECT_TRUE(progress_called); diff --git a/tests/unit/tracking_url_downloader.h b/tests/unit/tracking_url_downloader.h index 11105eb174..2c1bf0df99 100644 --- a/tests/unit/tracking_url_downloader.h +++ b/tests/unit/tracking_url_downloader.h @@ -39,7 +39,7 @@ struct TrackingURLDownloader : public URLDownloader void download_to(const QUrl& url, const QString& file_name, int64_t /*size*/, - const int /*download_type*/, + const int /*progress_type*/, const ProgressMonitor&) override { make_file_with_content(file_name, content); From 2f231608084c44eb0fd781cdee4dfa3047f9eaab Mon Sep 17 00:00:00 2001 From: Ricardo Abreu Date: Wed, 10 Jun 2026 01:24:28 +0100 Subject: [PATCH 15/15] [proto] Tweak type name for consistency --- src/client/cli/cmd/launch.cpp | 8 ++++---- src/daemon/daemon.cpp | 2 +- src/rpc/multipass.proto | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client/cli/cmd/launch.cpp b/src/client/cli/cmd/launch.cpp index c2eea98a71..f2a49cdaa6 100644 --- a/src/client/cli/cmd/launch.cpp +++ b/src/client/cli/cmd/launch.cpp @@ -635,10 +635,10 @@ mp::ReturnCodeVariant cmd::Launch::request_launch(const ArgParser* parser) auto streaming_callback = [this](LaunchReply& reply, grpc::ClientReaderWriterInterface*) { std::unordered_map progress_messages{ - {LaunchProgress_ProgressTypes_IMAGE, "Retrieving image: "}, - {LaunchProgress_ProgressTypes_EXTRACT, "Extracting image: "}, - {LaunchProgress_ProgressTypes_VERIFY, "Verifying image"}, - {LaunchProgress_ProgressTypes_WAITING, "Preparing image: "}}; + {LaunchProgress_ProgressType_IMAGE, "Retrieving image: "}, + {LaunchProgress_ProgressType_EXTRACT, "Extracting image: "}, + {LaunchProgress_ProgressType_VERIFY, "Verifying image"}, + {LaunchProgress_ProgressType_WAITING, "Preparing image: "}}; if (!reply.log_line().empty()) { diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index a601cba4a1..b214ddceba 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -3335,7 +3335,7 @@ void mp::Daemon::create_vm(const CreateRequest* request, create_reply.mutable_launch_progress()->set_percent_complete( std::to_string(percentage)); create_reply.mutable_launch_progress()->set_type( - (CreateProgress::ProgressTypes)progress_type); + (CreateProgress::ProgressType)progress_type); return server->Write(create_reply); }; diff --git a/src/rpc/multipass.proto b/src/rpc/multipass.proto index 3ea2eb5a77..2f2f20842e 100644 --- a/src/rpc/multipass.proto +++ b/src/rpc/multipass.proto @@ -93,13 +93,13 @@ message LaunchError { } message LaunchProgress { - enum ProgressTypes { + enum ProgressType { IMAGE = 0; EXTRACT = 1; VERIFY = 2; WAITING = 3; } - ProgressTypes type = 1; + ProgressType type = 1; string percent_complete = 2; }