Skip to content

bincompat-memcached - #114

Open
andreea110 wants to merge 4 commits into
unikraft:scriptsfrom
andreea110:add-bincompat-memcached
Open

bincompat-memcached#114
andreea110 wants to merge 4 commits into
unikraft:scriptsfrom
andreea110:add-bincompat-memcached

Conversation

@andreea110

@andreea110 andreea110 commented Jul 9, 2026

Copy link
Copy Markdown

Add bincompat-memcached: run Memcached 1.6 in binary-compatibility mode, modeled on bincompat-c-hello, with elfloader-net as base.

The rootfs uses the system Memcached binary (apt install memcached) with its dynamic libraries, plus minimal /etc/passwd and /etc/group (needed
by -u root / getpwnam()).

Two options had to be enabled in the elfloader-net defconfigs:

  • CONFIG_LIBPOSIX_FUTEX: without it pthread_create() fails with "Unsupported clone flags requested";
  • CONFIG_LIBPOSIX_EVENTFD: Memcached needs eventfd2() for its worker threads.

Tested on QEMU/x86_64: set/get/stats work on 172.44.0.2:11211, plus automated tests in scripts/test/.
The Firecracker scripts are included but not fully verified: the test VM has no /dev/kvm, and my local CPU hits Unikraft/Firecracker issues
unrelated to this app.

@andreea110
andreea110 force-pushed the add-bincompat-memcached branch 4 times, most recently from 9485d32 to 8ed6343 Compare July 9, 2026 14:25
@andreea110 andreea110 changed the title bincompat-memcached: add initial rootfs Makefile and setup.sh bincompat-memcached Jul 10, 2026
@andreea110
andreea110 force-pushed the add-bincompat-memcached branch from 349ac0c to c7d533f Compare July 11, 2026 08:39
Apps that use threads fail with "Unsupported clone flags requested".
pthread_create() asks for the CLONE_SYSVSEM and CLONE_CHILD_CLEARTID
flags, but the handlers for them come from uklock semaphores and from
posix-futex, and LIBPOSIX_FUTEX is not enabled by anything.

Enable it in the QEMU and Firecracker defconfigs. It also selects
LIBUKLOCK, whose semaphores handle CLONE_SYSVSEM. The futex syscall
is needed by pthreads anyway.

With this change memcached can start its worker threads.

Signed-off-by: Andreea-Ștefania DUMITRACHE <dumitracheandreea155@gmail.com>
memcached needs eventfd2() for its worker threads. Without it the
syscall returns ENOSYS and memcached exits at startup.

Signed-off-by: Andreea-Ștefania DUMITRACHE <dumitracheandreea155@gmail.com>

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 bincompat-memcached application that runs the system Memcached (1.6) as a Linux ELF under Unikraft’s binary-compatibility layer, using elfloader-net as the base and providing build/run/test automation for QEMU and Firecracker.

Changes:

  • Enable futex + eventfd support in elfloader-net defconfigs to support Memcached threading requirements.
  • Add bincompat-memcached rootfs build that bundles /usr/bin/memcached, required shared libraries, dynamic loader, and minimal passwd/group.
  • Add build/run/test scripts (including a Firecracker config) plus companion documentation for running and testing.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
elfloader-net/scripts/defconfig/qemu.x86_64 Enables additional POSIX features (futex/eventfd) needed by Memcached.
elfloader-net/scripts/defconfig/fc.x86_64 Enables additional POSIX features (futex/eventfd) needed by Memcached.
bincompat-memcached/setup.sh Creates workdir/ layout and links required repos (modeled on other bincompat apps).
bincompat-memcached/scripts/test/wrapper.sh Starts an instance and validates Memcached set/get behavior.
bincompat-memcached/scripts/test/README.md Documents how to run the test scripts.
bincompat-memcached/scripts/test/common.sh Shared test helpers for starting/stopping instances and probing services.
bincompat-memcached/scripts/test/all.sh Builds and runs QEMU/FC test flows, capturing logs.
bincompat-memcached/scripts/test/.gitignore Ignores test log output directory.
bincompat-memcached/scripts/run/qemu.x86_64 QEMU run wrapper configuring networking and boot args for memcached.
bincompat-memcached/scripts/run/fc.x86_64 Firecracker run wrapper configuring tap networking and VM config.
bincompat-memcached/scripts/README.md Documents build/run/test script entrypoints.
bincompat-memcached/scripts/common.sh Shared build helpers; builds the elfloader-net base for the chosen target.
bincompat-memcached/scripts/build/rootfs.x86_64 Builds the rootfs and packs it into initrd.cpio.
bincompat-memcached/scripts/build/qemu.x86_64 Builds rootfs + QEMU kernel.
bincompat-memcached/scripts/build/kernel.qemu.x86_64 Builds the elfloader-net base kernel for QEMU.
bincompat-memcached/scripts/build/kernel.fc.x86_64 Builds the elfloader-net base kernel for Firecracker.
bincompat-memcached/scripts/build/fc.x86_64 Builds rootfs + Firecracker kernel.
bincompat-memcached/rootfs/Makefile Copies system memcached + shared libs and generates minimal /etc/passwd and /etc/group.
bincompat-memcached/rootfs/.gitignore Ignores generated rootfs artifacts.
bincompat-memcached/README.md Main app documentation for setup, build, run, and test.
bincompat-memcached/fc.x86_64.json Firecracker VM configuration (boot args, initrd, networking).
bincompat-memcached/.gitignore Ignores workdir/ and generated initrd.

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

Comment thread elfloader-net/scripts/defconfig/qemu.x86_64 Outdated
Comment thread elfloader-net/scripts/defconfig/fc.x86_64 Outdated
Comment thread bincompat-memcached/scripts/test/common.sh Outdated
Comment thread bincompat-memcached/scripts/test/common.sh
Comment thread bincompat-memcached/scripts/test/common.sh Outdated
Comment thread bincompat-memcached/scripts/test/all.sh Outdated
Comment thread bincompat-memcached/scripts/test/wrapper.sh Outdated
Comment thread bincompat-memcached/scripts/README.md Outdated
@razvand razvand self-assigned this Jul 11, 2026
@razvand razvand added the enhancement New feature or request label Jul 11, 2026
@andreea110
andreea110 force-pushed the add-bincompat-memcached branch from 3ffee83 to 6a03a93 Compare July 11, 2026 12:38
@andreea110
andreea110 marked this pull request as ready for review July 11, 2026 14:16
@razvand
razvand requested a review from Copilot July 11, 2026 19:56

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 22 out of 22 changed files in this pull request and generated 3 comments.

Comment thread bincompat-memcached/scripts/test/common.sh Outdated
Comment thread bincompat-memcached/scripts/test/all.sh Outdated
Comment thread bincompat-memcached/rootfs/Makefile Outdated

@razvand razvand left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The rootfs/ directory must contain a Dockerfile and a Makefile that builds and extracts the required root filesystem. The Dockerfile should be actually the one from the examples/memcached1.6-base/ directory in the unikraft/catalog repository.

The Makefile would run the docker and extract the root filesystem. The Makefile here is a good starting point.

The current way to do a Makefile relies on local filesystem files that may or may not be present. The Dockerfile is the best way for that.

Run the unmodified Linux Memcached 1.6 binary on Unikraft through
app-elfloader, with networking, on QEMU and Firecracker. The layout
follows bincompat-c-hello, with elfloader-net as the base kernel.

The rootfs is built from the system Memcached binary (apt) together
with its dynamic libraries and minimal /etc/passwd and /etc/group
files, needed because Memcached runs with "-u root" and looks up
the user with getpwnam(). The tests follow the structure from unikraft#112.

Signed-off-by: Andreea-Ștefania DUMITRACHE <dumitracheandreea155@gmail.com>
@andreea110
andreea110 force-pushed the add-bincompat-memcached branch from 6a03a93 to 1c16087 Compare July 12, 2026 12:46
Signed-off-by: Andreea-Ștefania DUMITRACHE <dumitracheandreea155@gmail.com>
@andreea110
andreea110 force-pushed the add-bincompat-memcached branch from 1c16087 to bd920fd Compare July 12, 2026 13:09
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

None yet

Development

Successfully merging this pull request may close these issues.

3 participants