Skip to content

Analysis: Qt dependency removal requires multi-month phased approach#4489

Closed
Copilot wants to merge 1 commit intomainfrom
copilot/fix-53057619-114128199-7579b5fe-a1fc-4405-8bfd-d1f83b193d21
Closed

Analysis: Qt dependency removal requires multi-month phased approach#4489
Copilot wants to merge 1 commit intomainfrom
copilot/fix-53057619-114128199-7579b5fe-a1fc-4405-8bfd-d1f83b193d21

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 3, 2025

The issue requests complete removal of Qt6 dependencies from Multipass. This analysis documents why this cannot be accomplished in a single PR.

Scope Assessment

Qt is deeply embedded across the codebase:

  • 2,481 occurrences across 274 source files
  • Core infrastructure (strings, file I/O, JSON, process management)
  • Networking layer (HTTP client, URL parsing, TLS)
  • Architectural foundation (signals/slots, event loop, threading)
  • Platform integration (D-Bus on Linux)

Required Work Breakdown

Phase 1 (4-6 weeks): Core utilities

  • QString → std::string, QFile/QDir → std::filesystem, QJson → nlohmann/json, QProcess → reproc

Phase 2 (2-3 weeks): Networking

  • QNetworkAccessManager → libcurl, QUrl → curl parser

Phase 3 (6-8 weeks): Async architecture

  • Refactor signals/slots to callbacks, replace QTimer/QFuture/QEventLoop with STL equivalents

Phase 4 (1-2 weeks): Platform-specific

  • QDBus → sd-bus/dbus-cxx

Recommendation

This requires multiple PRs over 3-5 months with testing between phases. Attempting atomic replacement risks:

  • Introducing subtle behavioral regressions
  • Breaking platform-specific code paths
  • Destabilizing the async architecture

Next step: Clarify which phase/component to prioritize for incremental migration.

Original prompt

This section details on the original issue you should resolve

<issue_title>Remove Qt dependency from Multipass codebase</issue_title>
<issue_description>## Overview

Multipass currently has a heavy dependency on Qt6 (Core, Network, Concurrent) throughout the codebase for functionality that could be replaced with standard C++ or well-established third-party libraries. This creates a significant maintenance burden, increases build complexity, and introduces a large dependency footprint that's not necessary for a backend service and CLI tool.

Current Qt Usage

Qt is currently used extensively across the codebase in the following areas:

1. Core Utilities (Qt6::Core)

  • String handling: QString, QStringList
  • File I/O: QFile, QDir, QFileInfo, QSaveFile, QTemporaryFile, QLockFile
  • JSON parsing: QJsonDocument, QJsonObject, QJsonArray, QJsonParseError
  • Process management: QProcess, QProcessEnvironment
  • System information: QSysInfo, QStorageInfo, QTimeZone, QOperatingSystemVersion
  • Regular expressions: QRegularExpression
  • Data structures: QHash
  • UUIDs: QUuid
  • Event loop: QEventLoop, QCoreApplication

2. Networking (Qt6::Network)

  • HTTP/HTTPS downloads: QNetworkAccessManager, QNetworkReply, QNetworkDiskCache, QNetworkProxy
  • URL handling: QUrl
  • TLS support: QTlsBackendCertOnlyPlugin
  • TCP sockets: QTcpServer (VirtualBox backend)

3. Async/Threading (Qt6::Concurrent)

  • Signals & Slots: Used extensively for inter-component communication between daemon and RPC handlers
  • Async operations: QFuture, QFutureWatcher, QFutureSynchronizer, QtConcurrent
  • Timers: QTimer (downloads, delayed shutdown)
  • File system monitoring: QFileSystemWatcher (settings monitoring)

4. Platform-Specific (Qt6::DBus - Linux only)

  • D-Bus integration: QDBus* classes for Linux backend utilities

5. Meta-Object System

  • QObject inheritance: Daemon RPC uses Qt signals/slots pattern
  • Qt macros: Q_OBJECT, Q_MOC_RUN, signals:, slots:
  • Type registration: qRegisterMetaType

Key Problem Areas

Signals & Slots Architecture

The daemon uses Qt's signals/slots for RPC communication:

class DaemonRpc : public QObject, public multipass::Rpc::Service
{
    Q_OBJECT
signals:
    void on_launch(const LaunchRequest*, grpc::ServerReaderWriter<...>*, std::promise<grpc::Status>*);
    // ... 20+ signal definitions
};

// Connected in daemon.cpp
QObject::connect(&rpc, &DaemonRpc::on_launch, &daemon, &Daemon::launch);

This could be replaced with direct function calls or a lightweight callback system.

Process Management

Heavy use of QProcess throughout backends (QEMU, VirtualBox, Hyper-V):

QObject::connect(vm_process.get(), &Process::started, [this]() { on_started(); });
QObject::connect(vm_process.get(), &Process::finished, [this](ProcessState state) { /*...*/ });

Network Downloads

QNetworkAccessManager for image fetching with event loop integration:

QEventLoop event_loop;
QObject::connect(reply, &QNetworkReply::finished, &event_loop, &QEventLoop::quit);
event_loop.exec();

Proposed Replacement Strategy

Phase 1: Core Utilities Replacement

Target: Remove Qt6::Core dependency

Qt Component Replacement Notes
QString, QStringList std::string, std::vector<std::string> Already using STL strings in interfaces
QFile, QDir, QFileInfo std::filesystem (C++17) Native platform support
QTemporaryFile std::filesystem::temp_directory_path() + custom RAII Simple implementation
QSaveFile Custom atomic write wrapper Small utility class
QLockFile std::filesystem + platform file locking POSIX flock(), Windows LockFileEx()
QJsonDocument, QJsonObject nlohmann/json or simdjson Industry standard, already in vcpkg
QProcess reproc or subprocess.h Cross-platform process management
QRegularExpression std::regex (C++11) or PCRE2 STL sufficient for current usage
QSysInfo, QStorageInfo Platform-specific APIs Already abstracted in src/platform/
QUuid stduuid or boost::uuid Lightweight alternative
QHash std::unordered_map STL equivalent

Phase 2: Networking Replacement

Target: Remove Qt6::Network dependency

Qt Component Replacement Notes
QNetworkAccessManager libcurl (already a gRPC dep) or cpr Battle-tested HTTP client
QUrl [curl URL parser](https://curl.se/libcurl/c/l...

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Remove Qt dependency from Multipass codebase Analysis: Qt dependency removal requires multi-month phased approach Nov 3, 2025
Copilot AI requested a review from sharder996 November 3, 2025 13:42
@sharder996 sharder996 closed this Nov 3, 2025
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.

Remove Qt dependency from Multipass codebase

2 participants