Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.1.0 #1375

Merged
merged 11 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
url = https://github.com/CanonicalLtd/libssh.git
[submodule "3rd-party/fmt"]
path = 3rd-party/fmt
url = https://github.com/fmtlib/fmt.git
url = https://github.com/canonical/fmt.git
[submodule "3rd-party/xz-decoder/xz-embedded"]
path = 3rd-party/xz-decoder/xz-embedded
url = https://git.tukaani.org/xz-embedded.git
Expand Down
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ before_install:

# when it's a release branch or tag
if [[ "${TRAVIS_BRANCH}" =~ ${MULTIPASS_RELEASE_BRANCH_PATTERN} \
|| "${TRAVIS_PULL_REQUEST_BRANCH}" =~ ${MULTIPASS_RELEASE_BRANCH_PATTERN} \
|| "${TRAVIS_BRANCH}" =~ ${MULTIPASS_RELEASE_TAG_PATTERN} ]]; then

# publish pushes on candidate/*
# only publish pushes, on candidate/*
if [ "${TRAVIS_EVENT_TYPE}" == "push" ]; then
MULTIPASS_PUBLISH="true"
MULTIPASS_SNAP_CHANNEL="candidate/${BASH_REMATCH[1]}"
fi

# but report on the PR if it's a release branch
if [[ "${TRAVIS_BRANCH}" == release/* ]]; then
MULTIPASS_REPORT_OPTIONS+=("--branch" "${TRAVIS_BRANCH}")
# but report on the PR if it's a release branch
if [[ "${TRAVIS_BRANCH}" == release/* ]]; then
MULTIPASS_REPORT_OPTIONS+=("--branch" "${TRAVIS_BRANCH}")
fi
fi

# other branches publish on the commits by default
Expand All @@ -78,7 +79,7 @@ before_install:
MULTIPASS_REPORT_OPTIONS+=("--parent")
fi

# non-release publish on edge/pr*
# publish all other PRs on edge/pr*
elif [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]; then
MULTIPASS_PUBLISH="true"
MULTIPASS_SNAP_CHANNEL="edge/${MULTIPASS_BUILD_LABEL}"
Expand Down Expand Up @@ -130,7 +131,7 @@ jobs:
- sg lxd -c '/snap/bin/lxc profile device add default ccache disk source=${HOME}/.ccache/ path=/root/.ccache'
- ccache --zero-stats

# inject build identifier
# inject build identifier and upstream
- sed -i "/configflags:/a \ - -DMULTIPASS_BUILD_LABEL=${MULTIPASS_BUILD_LABEL}" snap/snapcraft.yaml

script:
Expand Down
2 changes: 1 addition & 1 deletion 3rd-party/fmt
Submodule fmt updated 1 files
+2 −2 include/fmt/core.h
31 changes: 21 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,37 @@ add_subdirectory(3rd-party)
find_package(Qt5 COMPONENTS Core Network Widgets REQUIRED)

function(determine_version OUTPUT_VARIABLE)
execute_process(COMMAND git describe --all --match release/*
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
ERROR_QUIET
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
# use upstream repo as the authoritative reference when checking for release status
# set -DMULTIPASS_UPSTREAM="" to use the local repository
if(MULTIPASS_UPSTREAM)
set(MULTIPASS_UPSTREAM "${MULTIPASS_UPSTREAM}/")
endif()

execute_process(COMMAND git describe --exact
execute_process(COMMAND git describe --all --exact --match "${MULTIPASS_UPSTREAM}release/*"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_RELEASE
OUTPUT_VARIABLE GIT_RELEASE_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)

execute_process(COMMAND git describe
execute_process(COMMAND git describe --long
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)

# only use -rc tags on release/* branches
string(REGEX MATCH "release/[0-9]+.[0-9]+$" GIT_BRANCH_MATCH "${GIT_BRANCH}")
if(GIT_BRANCH_MATCH)
string(REGEX MATCH "release/[0-9]+.[0-9]+" GIT_RELEASE_MATCH "${GIT_RELEASE_BRANCH}")
if(GIT_RELEASE_MATCH)
if(NOT DEFINED MULTIPASS_UPSTREAM)
message(FATAL_ERROR "You need to set MULTIPASS_UPSTREAM for a release build.\
\nUse an empty string to make local the authoritative repository.")
endif()

execute_process(COMMAND git describe --exact
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_RELEASE
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)

execute_process(COMMAND git describe --tags --match *-rc --abbrev=0
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG
Expand Down
5 changes: 4 additions & 1 deletion include/multipass/logging/level.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ enum class Level : int
error = 0,
warning = 1,
info = 2,
debug = 3
debug = 3,
trace = 4
};

constexpr CString as_string(const Level& l) noexcept
Expand All @@ -44,6 +45,8 @@ constexpr CString as_string(const Level& l) noexcept
return "info";
case Level::warning:
return "warning";
case Level::trace:
return "trace";
}
return "unknown";
}
Expand Down
6 changes: 3 additions & 3 deletions include/multipass/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ struct ProcessState
{
bool completed_successfully() const // if process stopped successfully with exit code 0
{
return !error && exit_code && exit_code.value() == 0;
return !error && exit_code && *exit_code == 0;
}
QString failure_message() const
{
if (error)
{
return error->message;
}
if (exit_code && exit_code.value() != 0)
if (exit_code && *exit_code != 0)
{
return QString("Process returned exit code: %1").arg(exit_code.value());
return QString("Process returned exit code: %1").arg(*exit_code);
}
return QString();
}
Expand Down
3 changes: 2 additions & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ parts:
- -DCMAKE_BUILD_TYPE=RelWithDebInfo
- -DCMAKE_INSTALL_PREFIX=/
- -DMULTIPASS_ENABLE_TESTS=off
- -DMULTIPASS_UPSTREAM=origin
override-build: |
snapcraftctl build
set -e
Expand All @@ -103,7 +104,7 @@ parts:
cat ../src/completions/bash/multipass >> ${SNAPCRAFT_PART_INSTALL}/etc/bash_completion.d/snap.multipass
VERSION=$( awk -F\" '/version_string/ { print $2 }' gen/multipass/version.h )
snapcraftctl set-version ${VERSION}
snapcraftctl set-grade $( echo ${VERSION} | grep -qe '^[0-9]\+\.[0-9]\+\.[0-9]\+$' && echo stable || echo devel )
snapcraftctl set-grade $( echo ${VERSION} | grep -qe '^[0-9]\+\.[0-9]\+\.[0-9]\+\($\|-rc\)' && echo stable || echo devel )
sed -i -e 's@^Icon=\(.\+\)$@Icon=/usr/share/icons/hicolor/scalable/apps/\1.svg@' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/multipass.gui.desktop

cd ${SNAPCRAFT_PART_SRC}/3rd-party
Expand Down
18 changes: 9 additions & 9 deletions src/client/cli/argparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ mp::ParseCode mp::ArgParser::parse()
{
if (!parser_result)
{
cerr << qPrintable(parser.errorText()) << "\n\n";
cerr << qUtf8Printable(parser.errorText()) << "\n\n";
}
cout << qPrintable(generalHelpText());
cout << qUtf8Printable(generalHelpText());
return (help_requested) ? ParseCode::HelpRequested : ParseCode::CommandFail;
}

Expand All @@ -130,12 +130,12 @@ mp::ParseCode mp::ArgParser::parse()

if (help_requested)
{
cout << qPrintable(generalHelpText());
cout << qUtf8Printable(generalHelpText());
return ParseCode::HelpRequested;
}

// Fall through
cout << "Error: Unknown Command '" << qPrintable(requested_command) << "' (try \"multipass help\")\n";
cout << "Error: Unknown Command '" << qUtf8Printable(requested_command) << "' (try \"multipass help\")\n";
return ParseCode::CommandLineError;
}

Expand All @@ -145,13 +145,13 @@ mp::ParseCode mp::ArgParser::commandParse(cmd::Command* command)
const bool parsedOk = parser.parse(arguments);
if (!parsedOk)
{
cerr << qPrintable(parser.errorText()) << '\n';
cerr << qUtf8Printable(parser.errorText()) << '\n';
return ParseCode::CommandLineError;
}

if (help_requested)
{
cout << qPrintable(helpText(command));
cout << qUtf8Printable(helpText(command));
return ParseCode::HelpRequested;
}
return ParseCode::Ok;
Expand Down Expand Up @@ -182,7 +182,7 @@ void mp::ArgParser::forceCommandHelp()

void mp::ArgParser::forceGeneralHelp()
{
cout << qPrintable(generalHelpText());
cout << qUtf8Printable(generalHelpText());
}

// Prints generic help
Expand Down Expand Up @@ -331,9 +331,9 @@ QStringList mp::ArgParser::positionalArguments() const

void mp::ArgParser::setVerbosityLevel(int verbosity)
{
if (verbosity > 3 || verbosity < 0)
if (verbosity > 4 || verbosity < 0)
{
cerr << "Verbosity level is incorrect. Must be between 0 and 3.\n";
cerr << "Verbosity level is incorrect. Must be between 0 and 4.\n";
}
else if (verbosity_level != verbosity)
{
Expand Down
2 changes: 1 addition & 1 deletion src/client/cli/cmd/get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mp::ReturnCode cmd::Get::run(mp::ArgParser* parser)
{
try
{
cout << qPrintable(Settings::instance().get(key)) << "\n";
cout << qUtf8Printable(Settings::instance().get(key)) << "\n";
}
catch (const SettingsException& e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/client/cli/cmd/help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mp::ReturnCode cmd::Help::run(mp::ArgParser* parser)

if (cmd == nullptr)
{
cerr << "Error: Unknown Command: '" << qPrintable(command) << "'\n";
cerr << "Error: Unknown Command: '" << qUtf8Printable(command) << "'\n";
return ReturnCode::CommandLineError;
}

Expand Down
4 changes: 3 additions & 1 deletion src/daemon/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ multipass::logging::Level to_logging_level(const QString& value)
return mpl::Level::info;
if (value == "debug")
return mpl::Level::debug;
if (value == "trace")
return mpl::Level::trace;

throw std::runtime_error("invalid logging verbosity: " + value.toStdString());
}
Expand All @@ -55,7 +57,7 @@ mp::DaemonConfigBuilder mp::cli::parse(const QCoreApplication& app)

QCommandLineOption logger_option{"logger", "specifies which logger to use", "platform|stderr"};
QCommandLineOption verbosity_option{
{"V", "verbosity"}, "specifies the logging verbosity level", "error|warning|info|debug"};
{"V", "verbosity"}, "specifies the logging verbosity level", "error|warning|info|debug|trace"};
QCommandLineOption address_option{"address",
"specifies which address to use for the multipassd service;"
" a socket can be specified using unix:<socket_file>",
Expand Down
4 changes: 2 additions & 2 deletions src/daemon/default_vm_image_vault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ bool mp::DefaultVMImageVault::has_record_for(const std::string& name)
void mp::DefaultVMImageVault::prune_expired_images()
{
std::vector<decltype(prepared_image_records)::key_type> expired_keys;
std::lock_guard lock{fetch_mutex};
std::lock_guard<decltype(fetch_mutex)> lock{fetch_mutex};

for (const auto& record : prepared_image_records)
{
Expand Down Expand Up @@ -582,7 +582,7 @@ void mp::DefaultVMImageVault::update_images(const FetchType& fetch_type, const P
fetch_image(fetch_type, record.query, prepare, monitor);

// Remove old image
std::lock_guard lock{fetch_mutex};
std::lock_guard<decltype(fetch_mutex)> lock{fetch_mutex};
delete_image_dir(record.image.image_path);
prepared_image_records.erase(key);
persist_image_records();
Expand Down
2 changes: 1 addition & 1 deletion src/platform/backends/libvirt/libvirt_virtual_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ std::string mp::LibVirtVirtualMachine::ssh_hostname()
return mp::utils::TimeoutAction::retry;
}
};
auto on_timeout = [] { return std::runtime_error("failed to determine IP address"); };
auto on_timeout = [] { throw std::runtime_error("failed to determine IP address"); };
mp::utils::try_action_for(on_timeout, std::chrono::minutes(2), action);

return ip.value().as_string();
Expand Down
2 changes: 1 addition & 1 deletion src/platform/backends/qemu/qemu_virtual_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ std::string mp::QemuVirtualMachine::ssh_hostname()
return mp::utils::TimeoutAction::retry;
}
};
auto on_timeout = [] { return std::runtime_error("failed to determine IP address"); };
auto on_timeout = [] { throw std::runtime_error("failed to determine IP address"); };
mp::utils::try_action_for(on_timeout, std::chrono::minutes(2), action);
}

Expand Down
5 changes: 3 additions & 2 deletions src/platform/backends/qemu/qemu_virtual_machine_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ void set_ip_forward()
QFile ip_forward("/proc/sys/net/ipv4/ip_forward");
if (!ip_forward.open(QFile::ReadWrite))
{
mpl::log(mpl::Level::warning, "daemon", fmt::format("Unable to open {}", qPrintable(ip_forward.fileName())));
mpl::log(mpl::Level::warning, "daemon",
fmt::format("Unable to open {}", qUtf8Printable(ip_forward.fileName())));
return;
}

if (ip_forward.write("1") < 0)
{
mpl::log(mpl::Level::warning, "daemon",
fmt::format("Failed to write to {}", qPrintable(ip_forward.fileName())));
fmt::format("Failed to write to {}", qUtf8Printable(ip_forward.fileName())));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/platform/backends/shared/basic_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mp::BasicProcess::BasicProcess(std::shared_ptr<mp::ProcessSpec> spec) : process_
process.setReadChannel(QProcess::StandardError);
QByteArray data = process.peek(process.bytesAvailable());
process.setReadChannel(original);
mpl::log(process_spec->error_log_level(), qPrintable(process_spec->program()), qPrintable(data));
mpl::log(process_spec->error_log_level(), qUtf8Printable(process_spec->program()), qUtf8Printable(data));
});
}

Expand Down Expand Up @@ -182,7 +182,7 @@ mp::ProcessState mp::BasicProcess::execute(const int timeout)
if (!process.waitForStarted(timeout) || !process.waitForFinished(timeout) ||
process.exitStatus() != QProcess::NormalExit)
{
mpl::log(mpl::Level::error, qPrintable(process_spec->program()), qPrintable(process.errorString()));
mpl::log(mpl::Level::error, qUtf8Printable(process_spec->program()), qUtf8Printable(process.errorString()));
exit_state.error = mp::ProcessState::Error{process.error(), error_string()};
return exit_state;
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform/backends/shared/linux/apparmor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void mp::AppArmor::load_policy(const QByteArray& aa_policy) const
process.closeWriteChannel();
process.waitForFinished();

mpl::log(mpl::Level::debug, "daemon", fmt::format("Loading AppArmor policy: \n{}", aa_policy));
mpl::log(mpl::Level::trace, "daemon", fmt::format("Loading AppArmor policy: \n{}", aa_policy));

if (process.exitCode() != 0)
{
Expand All @@ -107,7 +107,7 @@ void mp::AppArmor::remove_policy(const QByteArray& aa_policy) const
process.closeWriteChannel();
process.waitForFinished();

mpl::log(mpl::Level::debug, "daemon", fmt::format("Removing AppArmor policy: \n{}", aa_policy));
mpl::log(mpl::Level::trace, "daemon", fmt::format("Removing AppArmor policy: \n{}", aa_policy));

if (process.exitCode() != 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/platform/backends/shared/linux/backend_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ auto virtual_switch_subnet(const QString& bridge_name)
if (subnet.isNull())
{
mpl::log(mpl::Level::info, "daemon",
fmt::format("Unable to determine subnet for the {} subnet", qPrintable(bridge_name)));
fmt::format("Unable to determine subnet for the {} subnet", qUtf8Printable(bridge_name)));
}
return subnet.toStdString();
}
Expand Down
Loading