From f2ac0240ceeed9affab01050b72ccda2d1231837 Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Thu, 3 Apr 2025 15:06:28 +0200 Subject: [PATCH 01/22] [daemon] added the lxd deprecation warning for multipass list command. --- src/daemon/daemon.cpp | 19 +++++++++++++++++++ tests/test_daemon.cpp | 1 + 2 files changed, 20 insertions(+) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 16183fd200..4768e60523 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1285,6 +1285,24 @@ void populate_snapshot_info(mp::VirtualMachine& vm, populate_snapshot_fundamentals(snapshot, fundamentals); } + +template +void lxd_deprecation_warning(grpc::ServerReaderWriterInterface& server) // TODO lxd migration, remove +{ +#ifdef MULTIPASS_PLATFORM_LINUX + constexpr auto deprecation_warning = + "*** Warning! The lxd driver is deprecated and will be removed in an upcoming release. ***\n\n" + "When you are ready to have your instances migrated, please stop them (multipass stop --all) and " + "switch to the QEMU driver (multipass set local.driver=qemu).\n\n"; + + if (MP_SETTINGS.get(mp::driver_key) == "lxd") + { + W reply{}; + reply.set_log_line(deprecation_warning); + server.Write(reply); + } +#endif +} } // namespace mp::Daemon::Daemon(std::unique_ptr the_config) @@ -1818,6 +1836,7 @@ void mp::Daemon::list(const ListRequest* request, grpc::ServerReaderWriterInterf std::promise* status_promise) // clang-format off try // clang-format on { + lxd_deprecation_warning(*server); // TODO lxd migration, remove mpl::ClientLogger logger{mpl::level_from(request->verbosity_level()), *config->logger, server}; ListReply response; diff --git a/tests/test_daemon.cpp b/tests/test_daemon.cpp index 8ceaf74de1..4d01e8404f 100644 --- a/tests/test_daemon.cpp +++ b/tests/test_daemon.cpp @@ -132,6 +132,7 @@ struct Daemon : public mpt::DaemonTestFixture a few more tests for `false`, since there are different portions of code depending on it */ EXPECT_CALL(mock_settings, get(Eq(mp::winterm_key))).WillRepeatedly(Return("none")); EXPECT_CALL(mock_settings, get(Eq(mp::bridged_interface_key))).WillRepeatedly(Return("eth8")); + EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))).Times(AnyNumber()); // TODO lxd migration, remove } mpt::MockUtils::GuardedMock mock_utils_injection{mpt::MockUtils::inject()}; From 9d5354c766e39c6fc097936f7945ad47edd89d74 Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Thu, 3 Apr 2025 22:39:02 +0200 Subject: [PATCH 02/22] [daemon] improve the template parameters name --- src/daemon/daemon.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 4768e60523..7cfde35b04 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1286,8 +1286,8 @@ void populate_snapshot_info(mp::VirtualMachine& vm, populate_snapshot_fundamentals(snapshot, fundamentals); } -template -void lxd_deprecation_warning(grpc::ServerReaderWriterInterface& server) // TODO lxd migration, remove +template +void lxd_deprecation_warning(grpc::ServerReaderWriterInterface& server) // TODO lxd migration, remove { #ifdef MULTIPASS_PLATFORM_LINUX constexpr auto deprecation_warning = @@ -1297,7 +1297,7 @@ void lxd_deprecation_warning(grpc::ServerReaderWriterInterface& server) // if (MP_SETTINGS.get(mp::driver_key) == "lxd") { - W reply{}; + Reply reply{}; reply.set_log_line(deprecation_warning); server.Write(reply); } From 25d5a65c7f26a0a4d69fdcf5866be80a78bfc3a1 Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Thu, 3 Apr 2025 22:49:55 +0200 Subject: [PATCH 03/22] [daemon] extended the warning to libvirt. --- src/daemon/daemon.cpp | 14 ++++++++------ tests/test_daemon.cpp | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 7cfde35b04..d4c88552b0 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1287,18 +1287,20 @@ void populate_snapshot_info(mp::VirtualMachine& vm, } template -void lxd_deprecation_warning(grpc::ServerReaderWriterInterface& server) // TODO lxd migration, remove +void lxd_and_libvirt_deprecation_warning(grpc::ServerReaderWriterInterface& server) // TODO lxd and libvirt migration, remove { #ifdef MULTIPASS_PLATFORM_LINUX - constexpr auto deprecation_warning = - "*** Warning! The lxd driver is deprecated and will be removed in an upcoming release. ***\n\n" + constexpr auto deprecation_warning_template = + "*** Warning! The {} driver is deprecated and will be removed in an upcoming release. ***\n\n" "When you are ready to have your instances migrated, please stop them (multipass stop --all) and " "switch to the QEMU driver (multipass set local.driver=qemu).\n\n"; - if (MP_SETTINGS.get(mp::driver_key) == "lxd") + const auto current_driver = MP_SETTINGS.get(mp::driver_key); + if (current_driver == "lxd" || current_driver == "libvirt") { + const std::string deprecation_warning_message = fmt::format(deprecation_warning_template, current_driver); Reply reply{}; - reply.set_log_line(deprecation_warning); + reply.set_log_line(deprecation_warning_message); server.Write(reply); } #endif @@ -1836,7 +1838,7 @@ void mp::Daemon::list(const ListRequest* request, grpc::ServerReaderWriterInterf std::promise* status_promise) // clang-format off try // clang-format on { - lxd_deprecation_warning(*server); // TODO lxd migration, remove + lxd_and_libvirt_deprecation_warning(*server); // TODO lxd and libvirt migration, remove mpl::ClientLogger logger{mpl::level_from(request->verbosity_level()), *config->logger, server}; ListReply response; diff --git a/tests/test_daemon.cpp b/tests/test_daemon.cpp index 4d01e8404f..751935e87b 100644 --- a/tests/test_daemon.cpp +++ b/tests/test_daemon.cpp @@ -132,7 +132,7 @@ struct Daemon : public mpt::DaemonTestFixture a few more tests for `false`, since there are different portions of code depending on it */ EXPECT_CALL(mock_settings, get(Eq(mp::winterm_key))).WillRepeatedly(Return("none")); EXPECT_CALL(mock_settings, get(Eq(mp::bridged_interface_key))).WillRepeatedly(Return("eth8")); - EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))).Times(AnyNumber()); // TODO lxd migration, remove + EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))).Times(AnyNumber()); // TODO lxd and libvirt migration, remove } mpt::MockUtils::GuardedMock mock_utils_injection{mpt::MockUtils::inject()}; From 200b974253389869b90a74c47848264e2dfb89cf Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Fri, 4 Apr 2025 11:12:56 +0200 Subject: [PATCH 04/22] [daemon] added the deprecation warning to launch command. --- src/daemon/daemon.cpp | 1 + tests/test_daemon_launch.cpp | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index d4c88552b0..64376cac19 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1564,6 +1564,7 @@ void mp::Daemon::launch(const LaunchRequest* request, std::promise* status_promise) // clang-format off try // clang-format on { + lxd_and_libvirt_deprecation_warning(*server); // TODO lxd and libvirt migration, remove mpl::ClientLogger logger{mpl::level_from(request->verbosity_level()), *config->logger, server}; diff --git a/tests/test_daemon_launch.cpp b/tests/test_daemon_launch.cpp index e01bff9f80..fed737c052 100644 --- a/tests/test_daemon_launch.cpp +++ b/tests/test_daemon_launch.cpp @@ -16,19 +16,14 @@ */ #include "blueprint_test_lambdas.h" -#include "common.h" #include "daemon_test_fixture.h" -#include "mock_image_host.h" #include "mock_json_utils.h" #include "mock_permission_utils.h" #include "mock_platform.h" #include "mock_server_reader_writer.h" #include "mock_settings.h" -#include "mock_virtual_machine.h" #include "mock_vm_blueprint_provider.h" #include "mock_vm_image_vault.h" -#include "stub_virtual_machine.h" -#include "stub_vm_image_vault.h" #include @@ -46,6 +41,7 @@ struct TestDaemonLaunch : public mpt::DaemonTestFixture EXPECT_CALL(mock_settings, register_handler).WillRepeatedly(Return(nullptr)); EXPECT_CALL(mock_settings, unregister_handler).Times(AnyNumber()); EXPECT_CALL(mock_settings, get(Eq(mp::mounts_key))).WillRepeatedly(Return("true")); + EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))).Times(AnyNumber()); // TODO lxd and libvirt migration, remove } mpt::MockPlatform::GuardedMock attr{mpt::MockPlatform::inject()}; From b8e59580f81973243c01a6cb5ecc73e01cf1bb37 Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Fri, 4 Apr 2025 11:17:57 +0200 Subject: [PATCH 05/22] [daemon] added warning message to find command. --- src/daemon/daemon.cpp | 1 + tests/test_daemon_find.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 64376cac19..3f769f27ac 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1614,6 +1614,7 @@ void mp::Daemon::find(const FindRequest* request, grpc::ServerReaderWriterInterf std::promise* status_promise) // clang-format off try // clang-format on { + lxd_and_libvirt_deprecation_warning(*server); // TODO lxd and libvirt migration, remove mpl::ClientLogger logger{mpl::level_from(request->verbosity_level()), *config->logger, server}; FindReply response; diff --git a/tests/test_daemon_find.cpp b/tests/test_daemon_find.cpp index 04dfbedc43..dfc3c6b09c 100644 --- a/tests/test_daemon_find.cpp +++ b/tests/test_daemon_find.cpp @@ -51,6 +51,8 @@ struct DaemonFind : public mpt::DaemonTestFixture EXPECT_CALL(mock_settings, register_handler).WillRepeatedly(Return(nullptr)); EXPECT_CALL(mock_settings, unregister_handler).Times(AnyNumber()); EXPECT_CALL(mock_settings, get(Eq(mp::winterm_key))).WillRepeatedly(Return("none")); + EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))) + .Times(AnyNumber()); // TODO lxd and libvirt migration, remove ON_CALL(mock_utils, contents_of(_)).WillByDefault(Return(mpt::root_cert)); } From 2e172b032029a268fc47d5625daf256acbc302ac Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Fri, 4 Apr 2025 16:27:02 +0200 Subject: [PATCH 06/22] [set] added the warning to setting the driver to lxd or libvirt --- src/client/cli/cmd/set.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/client/cli/cmd/set.cpp b/src/client/cli/cmd/set.cpp index 03f3d43e98..f099951a11 100644 --- a/src/client/cli/cmd/set.cpp +++ b/src/client/cli/cmd/set.cpp @@ -96,6 +96,17 @@ mp::ParseCode cmd::Set::parse_args(mp::ArgParser* parser) { key = keyval.at(0); val = keyval.at(1); + + constexpr auto deprecation_warning_template = + "*** Warning! The {} driver is deprecated and will be removed in an upcoming release. ***\n\n" + "When you are ready to have your instances migrated, please stop them (multipass stop --all) and " + "switch to the QEMU driver (multipass set local.driver=qemu).\n\n"; + + if (key == mp::driver_key && (val == "lxd" || val == "libvirt")) + { + const std::string deprecation_warning_message = fmt::format(deprecation_warning_template, val); + std::cout << deprecation_warning_message << std::endl; + } } else { From 691f4dfc4ac83785dcbf7c5ad9f38973b3ea799a Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Fri, 4 Apr 2025 16:29:42 +0200 Subject: [PATCH 07/22] [daemon] added the warning message to the info command. --- src/daemon/daemon.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 3f769f27ac..2c616e9ab1 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1750,6 +1750,7 @@ void mp::Daemon::info(const InfoRequest* request, grpc::ServerReaderWriterInterf std::promise* status_promise) // clang-format off try // clang-format on { + lxd_and_libvirt_deprecation_warning(*server); // TODO lxd and libvirt migration, remove mpl::ClientLogger logger{mpl::level_from(request->verbosity_level()), *config->logger, server}; InfoReply response; From e4fd637d966687eb150854b129bca93070955d8d Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Fri, 4 Apr 2025 16:48:37 +0200 Subject: [PATCH 08/22] Revert "[daemon] added warning message to find command." This reverts commit 3dcdf720594b7a11a4d95e247b2816b4ebe876ba. --- src/daemon/daemon.cpp | 1 - tests/test_daemon_find.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 2c616e9ab1..894ec15f47 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1614,7 +1614,6 @@ void mp::Daemon::find(const FindRequest* request, grpc::ServerReaderWriterInterf std::promise* status_promise) // clang-format off try // clang-format on { - lxd_and_libvirt_deprecation_warning(*server); // TODO lxd and libvirt migration, remove mpl::ClientLogger logger{mpl::level_from(request->verbosity_level()), *config->logger, server}; FindReply response; diff --git a/tests/test_daemon_find.cpp b/tests/test_daemon_find.cpp index dfc3c6b09c..04dfbedc43 100644 --- a/tests/test_daemon_find.cpp +++ b/tests/test_daemon_find.cpp @@ -51,8 +51,6 @@ struct DaemonFind : public mpt::DaemonTestFixture EXPECT_CALL(mock_settings, register_handler).WillRepeatedly(Return(nullptr)); EXPECT_CALL(mock_settings, unregister_handler).Times(AnyNumber()); EXPECT_CALL(mock_settings, get(Eq(mp::winterm_key))).WillRepeatedly(Return("none")); - EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))) - .Times(AnyNumber()); // TODO lxd and libvirt migration, remove ON_CALL(mock_utils, contents_of(_)).WillByDefault(Return(mpt::root_cert)); } From 6276dc757fa5af68d71b3f9c779075b4cf56e8bd Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Fri, 4 Apr 2025 18:23:27 +0200 Subject: [PATCH 09/22] [daemon][set cmd] move the deprecation_warning_template central place to de-duplicate the code. --- include/multipass/constants.h | 5 +++++ src/client/cli/cmd/set.cpp | 10 ++++------ src/daemon/daemon.cpp | 7 +------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/multipass/constants.h b/include/multipass/constants.h index 00ad8bfe3b..eca04fd3fe 100644 --- a/include/multipass/constants.h +++ b/include/multipass/constants.h @@ -72,6 +72,11 @@ constexpr auto petenv_default = "primary"; constexpr auto timeout_exit_code = 5; constexpr auto authenticated_certs_dir = "authenticated-certs"; + +constexpr auto deprecation_warning_template = + "*** Warning! The {} driver is deprecated and will be removed in an upcoming release. ***\n\n" + "When you are ready to have your instances migrated, please stop them (multipass stop --all) and " + "switch to the QEMU driver (multipass set local.driver=qemu).\n\n"; // TODO lxd and libvirt migration, remove } // namespace multipass #endif // MULTIPASS_CONSTANTS_H diff --git a/src/client/cli/cmd/set.cpp b/src/client/cli/cmd/set.cpp index f099951a11..afd0d09dcc 100644 --- a/src/client/cli/cmd/set.cpp +++ b/src/client/cli/cmd/set.cpp @@ -97,16 +97,14 @@ mp::ParseCode cmd::Set::parse_args(mp::ArgParser* parser) key = keyval.at(0); val = keyval.at(1); - constexpr auto deprecation_warning_template = - "*** Warning! The {} driver is deprecated and will be removed in an upcoming release. ***\n\n" - "When you are ready to have your instances migrated, please stop them (multipass stop --all) and " - "switch to the QEMU driver (multipass set local.driver=qemu).\n\n"; - +#ifdef MULTIPASS_PLATFORM_LINUX + // TODO lxd and libvirt migration, remove if (key == mp::driver_key && (val == "lxd" || val == "libvirt")) { - const std::string deprecation_warning_message = fmt::format(deprecation_warning_template, val); + const std::string deprecation_warning_message = fmt::format(mp::deprecation_warning_template, val); std::cout << deprecation_warning_message << std::endl; } +#endif } else { diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 894ec15f47..2a3f0ef60b 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1290,15 +1290,10 @@ template void lxd_and_libvirt_deprecation_warning(grpc::ServerReaderWriterInterface& server) // TODO lxd and libvirt migration, remove { #ifdef MULTIPASS_PLATFORM_LINUX - constexpr auto deprecation_warning_template = - "*** Warning! The {} driver is deprecated and will be removed in an upcoming release. ***\n\n" - "When you are ready to have your instances migrated, please stop them (multipass stop --all) and " - "switch to the QEMU driver (multipass set local.driver=qemu).\n\n"; - const auto current_driver = MP_SETTINGS.get(mp::driver_key); if (current_driver == "lxd" || current_driver == "libvirt") { - const std::string deprecation_warning_message = fmt::format(deprecation_warning_template, current_driver); + const std::string deprecation_warning_message = fmt::format(mp::deprecation_warning_template, current_driver); Reply reply{}; reply.set_log_line(deprecation_warning_message); server.Write(reply); From 2adbf60bd1434b26ccbd98264c8dbb7525a79a69 Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Fri, 4 Apr 2025 22:47:35 +0200 Subject: [PATCH 10/22] [unit test] fix the linter. --- src/daemon/daemon.cpp | 3 ++- tests/test_daemon.cpp | 3 ++- tests/test_daemon_launch.cpp | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 2a3f0ef60b..69b9296ce5 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1287,7 +1287,8 @@ void populate_snapshot_info(mp::VirtualMachine& vm, } template -void lxd_and_libvirt_deprecation_warning(grpc::ServerReaderWriterInterface& server) // TODO lxd and libvirt migration, remove +void lxd_and_libvirt_deprecation_warning( + grpc::ServerReaderWriterInterface& server) // TODO lxd and libvirt migration, remove { #ifdef MULTIPASS_PLATFORM_LINUX const auto current_driver = MP_SETTINGS.get(mp::driver_key); diff --git a/tests/test_daemon.cpp b/tests/test_daemon.cpp index 751935e87b..f6f1ba6143 100644 --- a/tests/test_daemon.cpp +++ b/tests/test_daemon.cpp @@ -132,7 +132,8 @@ struct Daemon : public mpt::DaemonTestFixture a few more tests for `false`, since there are different portions of code depending on it */ EXPECT_CALL(mock_settings, get(Eq(mp::winterm_key))).WillRepeatedly(Return("none")); EXPECT_CALL(mock_settings, get(Eq(mp::bridged_interface_key))).WillRepeatedly(Return("eth8")); - EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))).Times(AnyNumber()); // TODO lxd and libvirt migration, remove + EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))) + .Times(AnyNumber()); // TODO lxd and libvirt migration, remove } mpt::MockUtils::GuardedMock mock_utils_injection{mpt::MockUtils::inject()}; diff --git a/tests/test_daemon_launch.cpp b/tests/test_daemon_launch.cpp index fed737c052..580fd2b398 100644 --- a/tests/test_daemon_launch.cpp +++ b/tests/test_daemon_launch.cpp @@ -41,7 +41,8 @@ struct TestDaemonLaunch : public mpt::DaemonTestFixture EXPECT_CALL(mock_settings, register_handler).WillRepeatedly(Return(nullptr)); EXPECT_CALL(mock_settings, unregister_handler).Times(AnyNumber()); EXPECT_CALL(mock_settings, get(Eq(mp::mounts_key))).WillRepeatedly(Return("true")); - EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))).Times(AnyNumber()); // TODO lxd and libvirt migration, remove + EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))) + .Times(AnyNumber()); // TODO lxd and libvirt migration, remove } mpt::MockPlatform::GuardedMock attr{mpt::MockPlatform::inject()}; From 2233847ca94dab46c0290612b10f9a0cb7186cfa Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Mon, 7 Apr 2025 10:36:55 +0200 Subject: [PATCH 11/22] [daemon] rename the warning message name. --- include/multipass/constants.h | 2 +- src/client/cli/cmd/set.cpp | 3 ++- src/daemon/daemon.cpp | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/multipass/constants.h b/include/multipass/constants.h index eca04fd3fe..b6a4556c23 100644 --- a/include/multipass/constants.h +++ b/include/multipass/constants.h @@ -73,7 +73,7 @@ constexpr auto timeout_exit_code = 5; constexpr auto authenticated_certs_dir = "authenticated-certs"; -constexpr auto deprecation_warning_template = +constexpr auto driver_deprecation_warning_template = "*** Warning! The {} driver is deprecated and will be removed in an upcoming release. ***\n\n" "When you are ready to have your instances migrated, please stop them (multipass stop --all) and " "switch to the QEMU driver (multipass set local.driver=qemu).\n\n"; // TODO lxd and libvirt migration, remove diff --git a/src/client/cli/cmd/set.cpp b/src/client/cli/cmd/set.cpp index afd0d09dcc..061a7b76e3 100644 --- a/src/client/cli/cmd/set.cpp +++ b/src/client/cli/cmd/set.cpp @@ -101,7 +101,8 @@ mp::ParseCode cmd::Set::parse_args(mp::ArgParser* parser) // TODO lxd and libvirt migration, remove if (key == mp::driver_key && (val == "lxd" || val == "libvirt")) { - const std::string deprecation_warning_message = fmt::format(mp::deprecation_warning_template, val); + const std::string deprecation_warning_message = + fmt::format(mp::driver_deprecation_warning_template, val); std::cout << deprecation_warning_message << std::endl; } #endif diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 69b9296ce5..8669960519 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1294,7 +1294,8 @@ void lxd_and_libvirt_deprecation_warning( const auto current_driver = MP_SETTINGS.get(mp::driver_key); if (current_driver == "lxd" || current_driver == "libvirt") { - const std::string deprecation_warning_message = fmt::format(mp::deprecation_warning_template, current_driver); + const std::string deprecation_warning_message = + fmt::format(mp::driver_deprecation_warning_template, current_driver); Reply reply{}; reply.set_log_line(deprecation_warning_message); server.Write(reply); From 1644495ab4b0247516db2b3461c9675db6c3bf06 Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Wed, 9 Apr 2025 17:05:58 +0200 Subject: [PATCH 12/22] [constants] refined the warning message for driver deprecation. --- include/multipass/constants.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/multipass/constants.h b/include/multipass/constants.h index b6a4556c23..861bd14646 100644 --- a/include/multipass/constants.h +++ b/include/multipass/constants.h @@ -74,9 +74,9 @@ constexpr auto timeout_exit_code = 5; constexpr auto authenticated_certs_dir = "authenticated-certs"; constexpr auto driver_deprecation_warning_template = - "*** Warning! The {} driver is deprecated and will be removed in an upcoming release. ***\n\n" - "When you are ready to have your instances migrated, please stop them (multipass stop --all) and " - "switch to the QEMU driver (multipass set local.driver=qemu).\n\n"; // TODO lxd and libvirt migration, remove + "*** Warning! The {0} driver is deprecated and will be removed in an future release. ***\n\n" + "After the removal, you will find the guide on how to access the {0} virtual machines on \n" + "https://documentation.ubuntu.com/multipass/en/latest/\n\n"; // TODO lxd and libvirt migration, remove } // namespace multipass #endif // MULTIPASS_CONSTANTS_H From b6ea000bfbdcb38ea8af4e33f5f071eb257359a7 Mon Sep 17 00:00:00 2001 From: George Liao Date: Fri, 11 Apr 2025 16:19:01 +0200 Subject: [PATCH 13/22] Update include/multipass/constants.h Co-authored-by: ScottH <59572507+sharder996@users.noreply.github.com> Signed-off-by: George Liao --- include/multipass/constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/multipass/constants.h b/include/multipass/constants.h index 861bd14646..c05e535510 100644 --- a/include/multipass/constants.h +++ b/include/multipass/constants.h @@ -74,7 +74,7 @@ constexpr auto timeout_exit_code = 5; constexpr auto authenticated_certs_dir = "authenticated-certs"; constexpr auto driver_deprecation_warning_template = - "*** Warning! The {0} driver is deprecated and will be removed in an future release. ***\n\n" + "**Warning! The {0} driver is deprecated and will be removed in an future release.**\n\n" "After the removal, you will find the guide on how to access the {0} virtual machines on \n" "https://documentation.ubuntu.com/multipass/en/latest/\n\n"; // TODO lxd and libvirt migration, remove } // namespace multipass From 2958ee917d25aa343e01dc4b365d93d11d39bb71 Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Fri, 11 Apr 2025 16:20:48 +0200 Subject: [PATCH 14/22] [constants] improve the text based on review comments. --- include/multipass/constants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/multipass/constants.h b/include/multipass/constants.h index c05e535510..c3efa1d1dc 100644 --- a/include/multipass/constants.h +++ b/include/multipass/constants.h @@ -75,7 +75,7 @@ constexpr auto authenticated_certs_dir = "authenticated-certs"; constexpr auto driver_deprecation_warning_template = "**Warning! The {0} driver is deprecated and will be removed in an future release.**\n\n" - "After the removal, you will find the guide on how to access the {0} virtual machines on \n" + "After the removal, you will find the guide on how to access the {0} instances on \n" "https://documentation.ubuntu.com/multipass/en/latest/\n\n"; // TODO lxd and libvirt migration, remove } // namespace multipass From f0dff69121ea547e5b643a6c32ae4f9a46d1fbe0 Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Mon, 14 Apr 2025 17:47:34 +0200 Subject: [PATCH 15/22] [constants] refined the warning message. --- include/multipass/constants.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/multipass/constants.h b/include/multipass/constants.h index c3efa1d1dc..ab196b0f99 100644 --- a/include/multipass/constants.h +++ b/include/multipass/constants.h @@ -74,9 +74,11 @@ constexpr auto timeout_exit_code = 5; constexpr auto authenticated_certs_dir = "authenticated-certs"; constexpr auto driver_deprecation_warning_template = - "**Warning! The {0} driver is deprecated and will be removed in an future release.**\n\n" - "After the removal, you will find the guide on how to access the {0} instances on \n" - "https://documentation.ubuntu.com/multipass/en/latest/\n\n"; // TODO lxd and libvirt migration, remove + "**Warning! The {0} driver is deprecated and will be removed in an future " + "release.**\n\n" + "- for libvirt: \"The instances will remain available with the QEMU driver\"\n" + "- for LXD: \"The instances will no longer be available in Multipass then, " + "but they will remain in LXD\"\n\n"; // TODO lxd and libvirt migration, remove } // namespace multipass #endif // MULTIPASS_CONSTANTS_H From 858be3c276c362182d4de95c57b39ee0718dd40c Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Tue, 22 Apr 2025 11:18:00 +0200 Subject: [PATCH 16/22] [unit test] changing return empty string to qemu string for future proof. --- tests/test_daemon.cpp | 2 +- tests/test_daemon_launch.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_daemon.cpp b/tests/test_daemon.cpp index f6f1ba6143..0c663ba92d 100644 --- a/tests/test_daemon.cpp +++ b/tests/test_daemon.cpp @@ -133,7 +133,7 @@ struct Daemon : public mpt::DaemonTestFixture EXPECT_CALL(mock_settings, get(Eq(mp::winterm_key))).WillRepeatedly(Return("none")); EXPECT_CALL(mock_settings, get(Eq(mp::bridged_interface_key))).WillRepeatedly(Return("eth8")); EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))) - .Times(AnyNumber()); // TODO lxd and libvirt migration, remove + .WillRepeatedly(Return("qemu")); // TODO lxd and libvirt migration, remove } mpt::MockUtils::GuardedMock mock_utils_injection{mpt::MockUtils::inject()}; diff --git a/tests/test_daemon_launch.cpp b/tests/test_daemon_launch.cpp index 580fd2b398..b2a441a16f 100644 --- a/tests/test_daemon_launch.cpp +++ b/tests/test_daemon_launch.cpp @@ -42,7 +42,7 @@ struct TestDaemonLaunch : public mpt::DaemonTestFixture EXPECT_CALL(mock_settings, unregister_handler).Times(AnyNumber()); EXPECT_CALL(mock_settings, get(Eq(mp::mounts_key))).WillRepeatedly(Return("true")); EXPECT_CALL(mock_settings, get(Eq(mp::driver_key))) - .Times(AnyNumber()); // TODO lxd and libvirt migration, remove + .WillRepeatedly(Return("qemu")); // TODO lxd and libvirt migration, remove } mpt::MockPlatform::GuardedMock attr{mpt::MockPlatform::inject()}; From 7b8f7ac05bdd9eb04f65ab9cf9caa5f9362d0f87 Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Tue, 22 Apr 2025 12:49:13 +0200 Subject: [PATCH 17/22] [daemon][set] recompose the deprecation message and refactor the code accordingly. --- include/multipass/constants.h | 7 ------- include/multipass/utils.h | 4 ++-- src/client/cli/cmd/set.cpp | 4 +--- src/daemon/daemon.cpp | 4 +--- src/utils/utils.cpp | 20 ++++++++++++++++++++ 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/include/multipass/constants.h b/include/multipass/constants.h index ab196b0f99..00ad8bfe3b 100644 --- a/include/multipass/constants.h +++ b/include/multipass/constants.h @@ -72,13 +72,6 @@ constexpr auto petenv_default = "primary"; constexpr auto timeout_exit_code = 5; constexpr auto authenticated_certs_dir = "authenticated-certs"; - -constexpr auto driver_deprecation_warning_template = - "**Warning! The {0} driver is deprecated and will be removed in an future " - "release.**\n\n" - "- for libvirt: \"The instances will remain available with the QEMU driver\"\n" - "- for LXD: \"The instances will no longer be available in Multipass then, " - "but they will remain in LXD\"\n\n"; // TODO lxd and libvirt migration, remove } // namespace multipass #endif // MULTIPASS_CONSTANTS_H diff --git a/include/multipass/utils.h b/include/multipass/utils.h index 73f9936a8a..cc3cee53fd 100644 --- a/include/multipass/utils.h +++ b/include/multipass/utils.h @@ -31,9 +31,7 @@ #include #include #include -#include #include -#include #include #include @@ -321,4 +319,6 @@ std::string multipass::utils::qenum_to_string(RegisteredQtEnum val) return qenum_to_qstring(val).toStdString(); } +std::string deprecation_warning_message_driver_concatenated( + const QString driver_name); // TODO lxd and libvirt migration, remove #endif // MULTIPASS_UTILS_H diff --git a/src/client/cli/cmd/set.cpp b/src/client/cli/cmd/set.cpp index 061a7b76e3..e742bd09c6 100644 --- a/src/client/cli/cmd/set.cpp +++ b/src/client/cli/cmd/set.cpp @@ -101,9 +101,7 @@ mp::ParseCode cmd::Set::parse_args(mp::ArgParser* parser) // TODO lxd and libvirt migration, remove if (key == mp::driver_key && (val == "lxd" || val == "libvirt")) { - const std::string deprecation_warning_message = - fmt::format(mp::driver_deprecation_warning_template, val); - std::cout << deprecation_warning_message << std::endl; + std::cout << deprecation_warning_message_driver_concatenated(val) << std::endl; } #endif } diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 8669960519..51b7676c1e 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1294,10 +1294,8 @@ void lxd_and_libvirt_deprecation_warning( const auto current_driver = MP_SETTINGS.get(mp::driver_key); if (current_driver == "lxd" || current_driver == "libvirt") { - const std::string deprecation_warning_message = - fmt::format(mp::driver_deprecation_warning_template, current_driver); Reply reply{}; - reply.set_log_line(deprecation_warning_message); + reply.set_log_line(deprecation_warning_message_driver_concatenated(current_driver)); server.Write(reply); } #endif diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 877b6ece06..50710275d0 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -583,3 +583,23 @@ auto mp::utils::find_bridge_with(const std::vector& ne }); return it == std::cend(networks) ? std::nullopt : std::make_optional(*it); } + +std::string deprecation_warning_message_driver_concatenated( + const QString driver_name) // TODO lxd and libvirt migration, remove +{ + constexpr auto driver_deprecation_warning_template_common_part = + "**Warning! The {0} driver is deprecated and will be removed in an future " + "release.**\n\n"; + + constexpr auto driver_deprecation_warning_lxd_part = "The instances will no longer be available in Multipass then, " + "but they will remain in LXD.\n\n"; + + constexpr auto driver_deprecation_warning_libvirt_part = + "The instances will remain available with the QEMU driver.\n\n"; + + const std::string deprecation_warning_message_driver_specific_part = + driver_name == "lxd" ? driver_deprecation_warning_lxd_part : driver_deprecation_warning_libvirt_part; + + return fmt::format(driver_deprecation_warning_template_common_part, driver_name) + + deprecation_warning_message_driver_specific_part; +} From 5f4f5d451052e5b53b576a91359740bc6e0f36a8 Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Wed, 23 Apr 2025 17:39:00 +0200 Subject: [PATCH 18/22] [utils] polished the deprecation warning message. --- src/utils/utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 50710275d0..b918a517d4 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -588,8 +588,8 @@ std::string deprecation_warning_message_driver_concatenated( const QString driver_name) // TODO lxd and libvirt migration, remove { constexpr auto driver_deprecation_warning_template_common_part = - "**Warning! The {0} driver is deprecated and will be removed in an future " - "release.**\n\n"; + "***Warning! The {0} driver is deprecated and will be removed in an future " + "release.***\n\n"; constexpr auto driver_deprecation_warning_lxd_part = "The instances will no longer be available in Multipass then, " "but they will remain in LXD.\n\n"; From 728a75452ecc0afb9da77712f24d7f7d301fe368 Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Wed, 30 Apr 2025 13:29:30 +0200 Subject: [PATCH 19/22] [utils] added space between the * and the message. --- src/utils/utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index b918a517d4..0e33c19c07 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -588,8 +588,8 @@ std::string deprecation_warning_message_driver_concatenated( const QString driver_name) // TODO lxd and libvirt migration, remove { constexpr auto driver_deprecation_warning_template_common_part = - "***Warning! The {0} driver is deprecated and will be removed in an future " - "release.***\n\n"; + "*** Warning! The {0} driver is deprecated and will be removed in an future " + "release. ***\n\n"; constexpr auto driver_deprecation_warning_lxd_part = "The instances will no longer be available in Multipass then, " "but they will remain in LXD.\n\n"; From e55a34a85e77e7a7a3f809e558ba8bd9c7ef0815 Mon Sep 17 00:00:00 2001 From: George Liao Date: Tue, 6 May 2025 14:39:08 +0200 Subject: [PATCH 20/22] Update src/client/cli/cmd/set.cpp Co-authored-by: Ricardo Abreu Signed-off-by: George Liao --- src/client/cli/cmd/set.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/cli/cmd/set.cpp b/src/client/cli/cmd/set.cpp index e742bd09c6..66494a68b0 100644 --- a/src/client/cli/cmd/set.cpp +++ b/src/client/cli/cmd/set.cpp @@ -101,7 +101,7 @@ mp::ParseCode cmd::Set::parse_args(mp::ArgParser* parser) // TODO lxd and libvirt migration, remove if (key == mp::driver_key && (val == "lxd" || val == "libvirt")) { - std::cout << deprecation_warning_message_driver_concatenated(val) << std::endl; + std::cout << deprecation_warning_message_driver_concatenated(val); } #endif } From 4c44ff741dc8bcf1017d0d9ac0a13304b1d5710f Mon Sep 17 00:00:00 2001 From: George Liao Date: Tue, 6 May 2025 14:42:01 +0200 Subject: [PATCH 21/22] Update src/utils/utils.cpp Co-authored-by: Ricardo Abreu Signed-off-by: George Liao --- src/utils/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 0e33c19c07..8e2079cb72 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -591,7 +591,7 @@ std::string deprecation_warning_message_driver_concatenated( "*** Warning! The {0} driver is deprecated and will be removed in an future " "release. ***\n\n"; - constexpr auto driver_deprecation_warning_lxd_part = "The instances will no longer be available in Multipass then, " + constexpr auto driver_deprecation_warning_lxd_part = "Instances will no longer be available in Multipass then, " "but they will remain in LXD.\n\n"; constexpr auto driver_deprecation_warning_libvirt_part = From 9c57114206ff160bb1c708ab6d4718728f892d9b Mon Sep 17 00:00:00 2001 From: George Liao Date: Tue, 6 May 2025 14:42:10 +0200 Subject: [PATCH 22/22] Update src/utils/utils.cpp Co-authored-by: Ricardo Abreu Signed-off-by: George Liao --- src/utils/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 8e2079cb72..c38ad67635 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -595,7 +595,7 @@ std::string deprecation_warning_message_driver_concatenated( "but they will remain in LXD.\n\n"; constexpr auto driver_deprecation_warning_libvirt_part = - "The instances will remain available with the QEMU driver.\n\n"; + "Instances will remain available with the QEMU driver.\n\n"; const std::string deprecation_warning_message_driver_specific_part = driver_name == "lxd" ? driver_deprecation_warning_lxd_part : driver_deprecation_warning_libvirt_part;