Skip to content

Move QEMU to vcpkg#4799

Open
xmkg wants to merge 52 commits intomainfrom
enhancement/move-qemu-to-vcpkg
Open

Move QEMU to vcpkg#4799
xmkg wants to merge 52 commits intomainfrom
enhancement/move-qemu-to-vcpkg

Conversation

@xmkg
Copy link
Copy Markdown
Member

@xmkg xmkg commented Apr 7, 2026

Description

What does this PR do?

Move QEMU dependency to vcpkg:

  • Move multipass-specific patches to the multipass-patches/ folder
  • Ensure static linkage of QEMU and QEMU tools by listing them as vcpkg dependencies
  • Prune unneeded QEMU features to reduce both build time and the amount of runtime dependencies:
    • "--disable-xkbcommon"
    • "--disable-gtk"
    • "--disable-opengl"
    • "--disable-libudev"
    • "--disable-af-xdp"
    • "--disable-rust"
    • "--disable-slirp"
  • Remove system package reliance at all levels
  • Force Multipass to use vendored QEMU instead of the system one
  • Reduce build disparity between snap and non-snap builds
  • Remove redundant firmware files
    • keymaps (VNC/GTK keyboard layouts)
    • bios-256k.bin -> We're using UEFI boot
  • Better snap & macOS build times since QEMU is now vcpkg-cached
  • Enable MSYS/MinGW build in Windows to build qemu-img
  • One QEMU recipe for all platforms!

Why is this change needed?

Streamlining dependencies, consistency across platforms, and simplifying QEMU provisioning.

MULTI-2339

@xmkg xmkg force-pushed the enhancement/move-qemu-to-vcpkg branch 5 times, most recently from 00a7b09 to 3863db5 Compare April 9, 2026 15:36
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.47%. Comparing base (03a6685) to head (a8464d4).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
.../platform/backends/qemu/qemu_base_process_spec.cpp 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4799      +/-   ##
==========================================
+ Coverage   87.45%   87.47%   +0.02%     
==========================================
  Files         258      258              
  Lines       14094    14100       +6     
==========================================
+ Hits        12324    12332       +8     
+ Misses       1770     1768       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xmkg xmkg force-pushed the enhancement/move-qemu-to-vcpkg branch 2 times, most recently from 03021b4 to 2871cf4 Compare April 10, 2026 13:50
Comment thread .github/workflows/windows-macos.yml Outdated
run: |
python3 -m pip install --user --upgrade distlib

- name: Install specific QEMU from Choco
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed since we're bundling our own qemu-img

@@ -0,0 +1,14 @@
#!/bin/sh
args=""
for arg in "$@"; do
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QEMU's configure is not like a traditional configure and it fails when some of the conventional configure flags are passed by vcpkg_configure_make(). This wrapper is here to strip those (we don't need them anyway).


vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO qemu/QEMU
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulling upstream and applying our patches. Ditched the test option patch since we're now able to null out the test's meson file directly, achieving the same outcome.


file(WRITE "${SOURCE_PATH}/tests/meson.build" "")

if("system" IN_LIST FEATURES)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

system builds the emulator too. Non-system build is tool-only.

endif()

set(QEMU_COMMON_OPTIONS
"--disable-bochs"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Derived from the old QEMU CMake + snapcraft.yaml. Has a couple of extra ones at the end, listed in PR description.


# binary and its libs
%4/usr/bin/%5 ixr,
%5 ixr,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, the program() is the full path to the executable. We no longer need to prefix it with anything.

QString mp::QemuImgProcessSpec::program() const
{
return "qemu-img";
return QDir(QCoreApplication::applicationDirPath()).filePath("qemu-img");
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as qemu-system.

)

add_executable(qemu-img
add_executable(mock-qemu-img
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name collision with qemu-img target declared before. This one is the mock, so the real one gets the "real" name.

Comment thread BUILD.linux.md
```
sudo apt update
sudo apt install libgl1 libpng16-16 libxml2 dnsmasq-base \
dnsmasq-utils qemu-utils libslang2 iproute2 iptables \
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need to install anything-QEMU now.

Comment thread CMakeLists.txt

option(MULTIPASS_VCPKG_BUILD_DEFAULT "Enable or disable building the dependencies in the default configuration, which includes both debug and release variants." OFF)
option(MULTIPASS_ENABLE_TESTS "Build tests" ON)
cmake_dependent_option(FORCE_ENABLE_VIRTUALBOX "Enable VirtualBox" ON UNIX OFF)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this closer to the other options.

@xmkg xmkg marked this pull request as ready for review April 10, 2026 21:18
@xmkg xmkg requested review from a team and ricab and removed request for a team and ricab April 10, 2026 21:19
@xmkg
Copy link
Copy Markdown
Member Author

xmkg commented Apr 13, 2026

Unassigned @ricab to better distribute review load.

xmkg added 15 commits April 20, 2026 16:11
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Also list zlib, zstd and ncurses as dependencies.

Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
-static causes everything to be linked statically, which is not we want

Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
We're now building our own QEMU, and it's auto-copied to build/, and it
is also install() able. We no longer need to rely on system's QEMU.

Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
xmkg added 25 commits April 20, 2026 16:11
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Some of the triplets are passing -NDEBUG in CFLAGS which makes QEMU
unhappy.

Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
MSVC var is defined after the project() call, whereas WIN32 is present
from the start.

Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
We can simply null out the tests meson file in portfile.

Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
@xmkg xmkg force-pushed the enhancement/move-qemu-to-vcpkg branch from 65f8bfd to a8464d4 Compare April 20, 2026 13:12
@xmkg
Copy link
Copy Markdown
Member Author

xmkg commented Apr 21, 2026

Let's try round-robin for another time... aaand we have a winner! @tobe2098

@xmkg xmkg requested review from a team and tobe2098 and removed request for a team April 21, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant