bincompat-memcached - #114
Conversation
9485d32 to
8ed6343
Compare
349ac0c to
c7d533f
Compare
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>
c7d533f to
3ffee83
Compare
There was a problem hiding this comment.
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-netdefconfigs to support Memcached threading requirements. - Add
bincompat-memcachedrootfs 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.
3ffee83 to
6a03a93
Compare
There was a problem hiding this comment.
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>
6a03a93 to
1c16087
Compare
Signed-off-by: Andreea-Ștefania DUMITRACHE <dumitracheandreea155@gmail.com>
1c16087 to
bd920fd
Compare
Add
bincompat-memcached: run Memcached 1.6 in binary-compatibility mode, modeled onbincompat-c-hello, withelfloader-netas base.The rootfs uses the system Memcached binary (
apt install memcached) with its dynamic libraries, plus minimal/etc/passwdand/etc/group(neededby
-u root/getpwnam()).Two options had to be enabled in the
elfloader-netdefconfigs:CONFIG_LIBPOSIX_FUTEX: without itpthread_create()fails with "Unsupported clone flags requested";CONFIG_LIBPOSIX_EVENTFD: Memcached needseventfd2()for its worker threads.Tested on QEMU/x86_64:
set/get/statswork on172.44.0.2:11211, plus automated tests inscripts/test/.The Firecracker scripts are included but not fully verified: the test VM has no
/dev/kvm, and my local CPU hits Unikraft/Firecracker issuesunrelated to this app.