Skip to content

Mosquitto : Adds Eclipse Mosquitto broker - #96

Open
vTusharr wants to merge 1 commit into
unikraft:mainfrom
vTusharr:mosquitto-port
Open

Mosquitto : Adds Eclipse Mosquitto broker#96
vTusharr wants to merge 1 commit into
unikraft:mainfrom
vTusharr:mosquitto-port

Conversation

@vTusharr

@vTusharr vTusharr commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

This pr adds the Eclipse Mosquitto (Version 2.1.2) MQTT broker to the Unikraft catalog-core. Mosquitto is a lightweight message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1.

features supported

  • MQTT publish/subscribe over TCP (IPv4 only)
  • In-memory persistence to /data in the initrd,(can also configure 9pfs)

related pr

testing

Builds cleanly for qemu and fc on x86_64 and arm64 via
./.scripts/build/<plat>.<arch>. Verified booting under qemu-system-x86_64
with bridged networking, and bidirectional messaging from the host with
mosquitto_pub/mosquitto_sub; ./test.sh automates that round trip.

@vTusharr

vTusharr commented Mar 16, 2026

Copy link
Copy Markdown
Contributor Author

Maybe i should add dfifferent config options in mosquitto.conf in readme ?

@razvand
razvand self-requested a review May 9, 2026 15:57
@razvand razvand self-assigned this May 9, 2026
@razvand razvand added the enhancement New feature or request label May 9, 2026
@razvand
razvand requested a review from Copilot August 2, 2026 12:32
@razvand
razvand requested a review from AndreiRV1 August 2, 2026 12:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Mosquitto MQTT broker application to the Unikraft catalog-core, including build/run scaffolding and platform configs for QEMU, Firecracker, and Xen, plus rootfs configuration.

Changes:

  • Adds a new mosquitto/ app directory with Kconfig (Config.uk), build wrapper (Makefile), setup script, and documentation.
  • Introduces platform run configurations (Firecracker JSON, Xen cfg) and defconfig presets (QEMU x86_64/arm64).
  • Updates the top-level setup.sh to fetch the required lib-mosquitto dependency.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
setup.sh Clones lib-mosquitto into the standard repos layout.
mosquitto/xen.x86_64.cfg Adds Xen PV config to boot Mosquitto with initrd-based rootfs.
mosquitto/xen.arm64.cfg Adds Xen arm64 config (currently uses type = "pvh").
mosquitto/setup.sh Creates workdir/ and symlinks required repos for the Mosquitto app.
mosquitto/scripts/defconfig/qemu.x86_64 Adds x86_64 QEMU defconfig (currently missing explicit Mosquitto enablement).
mosquitto/scripts/defconfig/qemu.arm64 Adds arm64 QEMU defconfig with virtio/net/9p and Mosquitto symbols enabled.
mosquitto/rootfs/etc/mosquitto/mosquitto.conf Provides broker config (listener, anonymous access, persistence settings).
mosquitto/README.md Documents setup/build/run/test steps for QEMU/Firecracker/Xen.
mosquitto/Makefile.uk Added (empty, consistent with some other catalog apps).
mosquitto/Makefile Build wrapper invoking Unikraft with required libs and build dir.
mosquitto/fc.x86_64.json Firecracker x86_64 boot config.
mosquitto/fc.arm64.json Firecracker arm64 boot config.
mosquitto/Config.uk Kconfig selecting Mosquitto + networking + filesystem dependencies.
mosquitto/.gitignore Ignores generated build artifacts and runtime files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mosquitto/scripts/defconfig/qemu.x86_64 Outdated
Comment thread mosquitto/xen.arm64.cfg Outdated
Comment thread mosquitto/rootfs/etc/mosquitto/mosquitto.conf Outdated
Comment thread mosquitto/README.md Outdated
This adds the Unikraft port of the Eclipse Mosquitto MQTT broker
that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1.

Signed-off-by: Tushar Verma <tusharVermaiota@proton.me>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 26 changed files in this pull request and generated no new comments.

Suppressed comments (10)

mosquitto/test.sh:16

  • mosquitto_sub | grep -qx treats the expected message as a regular expression; use fixed-string matching so the test can’t fail if the message ever contains regex metacharacters.
mosquitto_sub -h "$HOST" -p "$PORT" -t "$TOPIC" -C 1 -W 5 | grep -qx "$MSG"

mosquitto/rootfs/etc/mosquitto/mosquitto.conf:12

  • There’s trailing whitespace and an extra leading space in the persistence comment, which makes the shipped config look sloppy and can trip whitespace-sensitive tooling.
# Set to "none" to silence the broker. 
log_dest stdout
# /data/ lives in the in-memory root filesystem, so the database survives a
#  restart 
persistence true

mosquitto/.scripts/run/qemu.x86_64:15

  • This script continues even if network setup or initrd packing fails; add set -e so failures stop early. If you do that, the best-effort cleanup block should be explicitly ignored (|| true) so missing interfaces don’t abort the run.
#!/bin/sh

if test ! -f "workdir/build/mosquitto_qemu-x86_64"; then
    echo "No kernel file workdir/build/mosquitto_qemu-x86_64." 1>&2
    echo "Did you run ./.scripts/build/qemu.x86_64 ?" 1>&2

mosquitto/.scripts/run/qemu.arm64:15

  • This script continues even if network setup or initrd packing fails; add set -e so failures stop early. If you do that, the best-effort cleanup block should be explicitly ignored (|| true) so missing interfaces don’t abort the run.
#!/bin/sh

if test ! -f "workdir/build/mosquitto_qemu-arm64"; then
    echo "No kernel file workdir/build/mosquitto_qemu-arm64." 1>&2
    echo "Did you run ./.scripts/build/qemu.arm64 ?" 1>&2

mosquitto/.scripts/run/fc.x86_64:15

  • This script continues even if network setup or initrd packing fails; add set -e so failures stop early. If you do that, the best-effort cleanup block should be explicitly ignored (|| true) so missing interfaces don’t abort the run.
#!/bin/sh

if test ! -f "workdir/build/mosquitto_fc-x86_64"; then
    echo "No kernel file workdir/build/mosquitto_fc-x86_64." 1>&2
    echo "Did you run ./.scripts/build/fc.x86_64 ?" 1>&2

mosquitto/.scripts/run/fc.arm64:15

  • This script continues even if network setup or initrd packing fails; add set -e so failures stop early. If you do that, the best-effort cleanup block should be explicitly ignored (|| true) so missing interfaces don’t abort the run.
#!/bin/sh

if test ! -f "workdir/build/mosquitto_fc-arm64"; then
    echo "No kernel file workdir/build/mosquitto_fc-arm64." 1>&2
    echo "Did you run ./.scripts/build/fc.arm64 ?" 1>&2

mosquitto/.scripts/build/qemu.x86_64:4

  • Defaulting to -w suppresses all compiler warnings, which can hide real build issues. Also consider set -e so a failing make step stops the script immediately.
#!/bin/sh
export UK_CFLAGS="${UK_CFLAGS:--std=gnu17 -w}"

make distclean

mosquitto/.scripts/build/qemu.arm64:4

  • Defaulting to -w suppresses all compiler warnings, which can hide real build issues. Also consider set -e so a failing make step stops the script immediately.
#!/bin/sh
export UK_CFLAGS="${UK_CFLAGS:--std=gnu17 -w}"

make distclean

mosquitto/.scripts/build/fc.x86_64:4

  • Defaulting to -w suppresses all compiler warnings, which can hide real build issues. Also consider set -e so a failing make step stops the script immediately.
#!/bin/sh
export UK_CFLAGS="${UK_CFLAGS:--std=gnu17 -w}"

make distclean

mosquitto/.scripts/build/fc.arm64:4

  • Defaulting to -w suppresses all compiler warnings, which can hide real build issues. Also consider set -e so a failing make step stops the script immediately.
#!/bin/sh
export UK_CFLAGS="${UK_CFLAGS:--std=gnu17 -w}"

make distclean

@AndreiRV1 AndreiRV1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good overall, but the build script currently fails to complete because several required dependencies are missing.

Please ensure LIBVFSCORE and LIBSYSCALL_SHIM are explicitly selected in the configuration so the full dependency chain is satisfied and the project builds without errors.

@vTusharr

Copy link
Copy Markdown
Contributor Author

Looks good overall, but the build script currently fails to complete because several required dependencies are missing.

Please ensure LIBVFSCORE and LIBSYSCALL_SHIM are explicitly selected in the configuration so the full dependency chain is satisfied and the project builds without errors.

Vfscore should be set to imply as per this
, I am using the newer posix-vfs stack so i set that to n & syscall-shim is auto selected by musl . Adding it wont have any effect so for documentation purposes we can add it + Can you please share the logs of the build errors you got upon using the script.

@vTusharr

Copy link
Copy Markdown
Contributor Author

Also @AndreiRV1 can you also review this at your covenience ?
Thanks

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 26 changed files in this pull request and generated 3 comments.

Suppressed comments (4)

mosquitto/README.md:14

  • This quick-setup snippet assumes /etc/qemu already exists, but the listed requirements do not guarantee that; on a clean host tee fails and the subsequent bridge-backed QEMU launch cannot work. Add the directory creation step used by the top-level README (README.md:74) before writing bridge.conf.
echo "allow all" | sudo tee /etc/qemu/bridge.conf

mosquitto/README.md:67

  • xl create is not sufficient with these configs: both Xen files require a virbr0 bridge with the guest gateway at 172.44.0.1, but this section never creates/configures that bridge, and it also omits the mkcpio command needed to produce initrd.cpio. On a clean Xen host the command therefore fails or boots an unreachable broker. Add the network and initrd setup steps before the xl command, as in redis/README.md:302-319.
Xen has no scripts. Build it by passing [.scripts/defconfig/](.scripts/defconfig/)
style options to `make menuconfig`, pack the initrd yourself, then boot it with
`sudo xl create -c xen.x86_64.cfg` on a system with Xen installed.

mosquitto/README.md:28

  • These quick-start commands invoke the host mosquitto_sub/mosquitto_pub clients, but the referenced shared requirements and CI base dependency list do not install mosquitto-clients. On a clean setup following this README, the commands fail with command not found; document or install that app-specific prerequisite.
mosquitto_sub -h 172.44.0.2 -t test/unikraft

mosquitto/test.sh:16

  • grep -qx interprets MSG as a basic regular expression, so the . in Unikraft! matches any character and a corrupted response such as UnikraftX would still make this round-trip test pass. Use fixed-string matching (grep -Fqx) so the assertion checks the exact payload.
mosquitto_sub -h "$HOST" -p "$PORT" -t "$TOPIC" -C 1 -W 5 | grep -qx "$MSG"

# Remove previously created files.
rm -f firecracker.socket

firecracker-arm64 \
Comment thread mosquitto/Config.uk
Comment on lines +14 to +18
select LIBUKCPIO
select LIBLWIP
select LWIP_IPV4
select LWIP_UDP
select LWIP_DHCP
Comment thread setup.sh
test -d repos/libs/redis || git clone https://github.com/unikraft/lib-redis repos/libs/redis
test -d repos/libs/wamr || git clone https://github.com/unikraft/lib-wamr repos/libs/wamr
test -d repos/libs/sqlite || git clone https://github.com/unikraft/lib-sqlite repos/libs/sqlite
test -d repos/libs/mosquitto || git clone https://github.com/unikraft/lib-mosquitto repos/libs/mosquitto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants