Introduce C HTTP server in bincompat mode - #112
Draft
razvand wants to merge 1 commit into
Draft
Conversation
Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Merged
andreea110
added a commit
to andreea110/catalog-core
that referenced
this pull request
Jul 11, 2026
Use the all.sh / common.sh / wrapper.sh layout from unikraft#112, with a new test_memcached_set_get check. Signed-off-by: Andreea-Ștefania DUMITRACHE <dumitracheandreea155@gmail.com>
andreea110
added a commit
to andreea110/catalog-core
that referenced
this pull request
Jul 11, 2026
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>
There was a problem hiding this comment.
Pull request overview
Adds a new bincompat-c-http example application that builds a Linux ELF HTTP server (static PIE) and runs it via Unikraft’s ELF loader, including helper scripts for setup/build/run/testing on QEMU and Firecracker.
Changes:
- Introduces a minimal C HTTP server ELF and rootfs build system for packaging into an initrd.
- Adds run configurations for QEMU/Firecracker plus build/run/test helper scripts.
- Documents manual and scripted workflows for building and running the example.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| bincompat-c-http/setup.sh | Creates the local workdir and symlinks required repo(s). |
| bincompat-c-http/rootfs/Makefile | Builds the static PIE Linux ELF HTTP server for inclusion in initrd. |
| bincompat-c-http/rootfs/http_server.c | Implements a minimal single-threaded HTTP server that replies with a fixed response. |
| bincompat-c-http/rootfs/.gitignore | Ignores the compiled ELF binary in rootfs. |
| bincompat-c-http/README.md | Documents setup/build/run steps and expected output. |
| bincompat-c-http/fc.x86_64.json | Firecracker config for booting the ELF loader and running /http_server. |
| bincompat-c-http/.scripts/common.sh | Shared build helper wiring this app to the chosen ELF loader base. |
| bincompat-c-http/.scripts/README.md | Documents the build/run helper scripts for this app. |
| bincompat-c-http/.scripts/build/rootfs.x86_64 | Builds rootfs ELF and packs it into initrd.cpio. |
| bincompat-c-http/.scripts/build/kernel.qemu.x86_64 | Builds the base ELF loader kernel for QEMU. |
| bincompat-c-http/.scripts/build/kernel.fc.x86_64 | Builds the base ELF loader kernel for Firecracker. |
| bincompat-c-http/.scripts/build/qemu.x86_64 | Convenience build for QEMU: rootfs + kernel. |
| bincompat-c-http/.scripts/build/fc.x86_64 | Convenience build for Firecracker: rootfs + kernel. |
| bincompat-c-http/.scripts/run/qemu.x86_64 | Runs QEMU with bridge networking and the generated initrd. |
| bincompat-c-http/.scripts/run/fc.x86_64 | Runs Firecracker using the provided JSON config. |
| bincompat-c-http/.scripts/test/common.sh | Shared test utilities (ping/curl/netcat/etc.) used by wrappers. |
| bincompat-c-http/.scripts/test/wrapper.sh | Test wrapper intended to boot and validate the instance. |
| bincompat-c-http/.scripts/test/all.sh | Runs build+run tests for QEMU and Firecracker and stores logs. |
| bincompat-c-http/.scripts/test/.gitignore | Ignores test logs directory. |
| bincompat-c-http/.scripts/test/README.md | Documents how to run the scripted tests. |
| bincompat-c-http/.gitignore | Ignores workdir/ and initrd.cpio artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,21 @@ | |||
| { | |||
| "boot-source": { | |||
| "kernel_image_path": "../elfloader-basic/workdir/build/elfloader_fc-x86_64", | |||
| # Linux Binary-Compatible C HTTP server on Unikraft | ||
|
|
||
| Build and run a simple C HTTP server compiled as a Linux ELF using the [Unikraft binary-compatibility layer](https://unikraft.org/docs/concepts/compatibility). | ||
| This application makes use of `elfloader-basic` as its base, make sure to check its [README](../elfloader-basic/README.md) for more information. |
| Note that you still need to install the [requirements](../README.md#requirements). | ||
| Before everything, make sure you run the [top-level `setup.sh` script](../setup.sh). | ||
|
|
||
| To build and run the HTTP server Linux ELF using the Unikraft ELF Loader, first you will have to follow the [instructions](../elfloader-net/README.md#set-up) for configuring and building `elfloader-basic` - follow those instructions within the `../elfloader-net` directory normally. |
Comment on lines
+1
to
+4
| # Testing C Hello on Unikraft | ||
|
|
||
| These are companion instructions to the main instructions in the [`README`](../../README.md) and to the scripted run instructions in the [`.scripts/README`](../README.md). | ||
| Use these scripts to test C Hello on Unikraft. |
Comment on lines
+5
to
+24
| if test $# -ne 1; then | ||
| echo "Unknown arguments." 1>&2 | ||
| echo "Usage: $0 <start_command>" 1>&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Clean up previous instances. | ||
| clean_up | ||
|
|
||
| # Start instance. | ||
| start_instance 2>&1 | grep "Hello from Unikraft!" 1>&2 | ||
| if test $? -ne 0; then | ||
| echo "Wrong message printed." 1>&2 | ||
| echo "FAILED" | ||
| clean_up | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Stop instance. | ||
| end_with_success |
Comment on lines
+29
to
+31
| ssize_t n; | ||
| struct sockaddr_in srv_addr; | ||
|
|
Comment on lines
+42
to
+46
| rc = bind(srv, (struct sockaddr *) &srv_addr, sizeof(srv_addr)); | ||
| if (rc < 0) { | ||
| fprintf(stderr, "Failed to bind socket: %d\n", errno); | ||
| goto out; | ||
| } |
Comment on lines
+49
to
+53
| rc = listen(srv, 1); | ||
| if (rc < 0) { | ||
| fprintf(stderr, "Failed to listen on socket: %d\n", errno); | ||
| goto out; | ||
| } |
|
|
||
| ### Run on Firecracker/x86_64 | ||
|
|
||
| Note that you must build the `elfloader-basic` Firecracker kernel before this step. |
andreea110
added a commit
to andreea110/catalog-core
that referenced
this pull request
Jul 11, 2026
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
added a commit
to andreea110/catalog-core
that referenced
this pull request
Jul 12, 2026
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
added a commit
to andreea110/catalog-core
that referenced
this pull request
Aug 21, 2026
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>
razvand
pushed a commit
that referenced
this pull request
Aug 22, 2026
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 #112. Signed-off-by: Andreea-Ștefania DUMITRACHE <dumitracheandreea155@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.