mewz-project / mewz Goto Github PK
View Code? Open in Web Editor NEWA unikernel designed specifically for running Wasm applications and compatible with WASI
License: GNU General Public License v3.0
A unikernel designed specifically for running Wasm applications and compatible with WASI
License: GNU General Public License v3.0
The maximum number of TCP connections are now hard-coded.
We may need to enable to specify it by something like options.
To change the number, we need to tune these variables: #6
But we're not familiar with lwIP's parameters in lwipopts.h
. We've arbitrarily determined them. The settings of Unikraft may be helpful as a reference.
The support status for WASI functions is as follows:
We need a test for reading a file.
path_open
to open a filefd_read
to read the file content, and compare it with the expected contentfd_close
to close the file$ docker pull ghcr.io/mewz-project/mewz
Using default tag: latest
latest: Pulling from mewz-project/mewz
af107e978371: Pulling fs layer
4278792552db: Pulling fs layer
9c01b7de78bf: Pulling fs layer
3245434c345b: Waiting
e438c664582f: Waiting
1f89fd20aea9: Waiting
3aff96a866aa: Waiting
45bc183e102b: Waiting
7a8408419b6b: Waiting
7070c6497c75: Waiting
error pulling image configuration: download failed after attempts=1: unknown blob
Some blobs such as sha256:96eb8313ddf564d2d66a262eaa10266ab06aa5933da279021aa3623ce5e740f3
(application/vnd.docker.container.image.v1+json
) seems missing
https://explore.ggcr.dev/?image=ghcr.io%2Fmewz-project%2Fmewz%40sha256%3A8039c6107729564632b502735086f8d27357e4630e67d665068bb2663e2abab7
File descriptors are handled as i32
in WASI functions arguments, like this.
pub export fn fd_close(fd: i32) callconv(.C) WasiError
We pass them around as i32
. But indices must be usize in Zig, so we must cast them every time we index the file descriptor table.
pub fn get(self: *Self, fd: i32) ?*Stream {
const streams = self.streams.acquire();
defer self.streams.release();
const s = &streams.*[@as(usize, @intCast(fd))];
if (s.* == null) {
return null;
}
return @as(*Stream, @ptrCast(s));
}
To avoid it, we want to cast fd
to usize
in WASI functions, and handle it as usize
in stream
module.
Now we use Waiter
(https://github.com/mewz-project/mewz/blob/main/src/sync.zig#L36) to wait for interruption and data.
But we could replace it with simply hlt
, because it stops until an interruption occurs.
To do so, we would avoid exclusion control and save CPU time of host.
Mewz now only supports TCP sockets. We may need UDP sockets with DNS and so on.
Just like TCP sockets, we'll use lwIP's raw API.
https://github.com/Mewz-project/Mewz/blob/main/src/util.zig#L34
If data.len > self.buffer.len
, it causes panic.
We're roughly handling the errors returned by lwIP functions, like this.
https://github.com/Mewz-project/Mewz/blob/main/src/tcpip.zig#L67
We need to respond appropriately depending on the type of error. The error types are defined here.
I am a zig newbie and would like to try to learn.
I'm having problems compiling mewz
, I run zig build
with the following error. Can you help me with this? Thanks for the help.
root ➜ /workspaces/mewz (main) $ zig build
++ git rev-parse --show-toplevel
++ git rev-parse --show-toplevel
+ REPO_ROOT=/workspaces/mewz
+ cd /workspaces/mewz
+ REPO_ROOT=/workspaces/mewz
+ cd /workspaces/mewz
+ ls build/newlib/libc.a
+ mkdir -p build/lwip
ls: cannot access 'build/newlib/libc.a': No such file or directory
+ mkdir -p build/newlib
+ cd build/lwip
+ cmake ../../lwip-wrapper
+ cd build/newlib
+ ../../submodules/newlib/newlib/configure --target=x86_64-elf --disable-multilib --prefix=/usr/local/newlib-x86_64-elf
./scripts/build-newlib.sh: line 12: ../../submodules/newlib/newlib/configure: No such file or directory
run ./scripts/build-newlib.sh: error: the following command exited with error code 127:
./scripts/build-newlib.sh
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as
project(ProjectName)
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at CMakeLists.txt:15 (include):
include could not find requested file:
/workspaces/mewz/lwip-wrapper/../submodules/lwip/src/Filelists.cmake
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.25)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring incomplete, errors occurred!
See also "/workspaces/mewz/build/lwip/CMakeFiles/CMakeOutput.log".
run ./scripts/build-lwip.sh: error: the following command exited with error code 1:
./scripts/build-lwip.sh
Build Summary: 1/6 steps succeeded; 2 failed (disable with --summary none)
install transitive failure
└─ install mewz.elf transitive failure
└─ zig build-exe mewz.elf Debug x86_64-freestanding transitive failure
├─ run ./scripts/build-newlib.sh failure
└─ run ./scripts/build-lwip.sh failure
error: the following build command failed with exit code 1:
/workspaces/mewz/zig-cache/o/7c36e40cbb2402eb80e289dd70bd7100/build /usr/bin/zig/zig /workspaces/mewz /workspaces/mewz/zig-cache /root/.cache/zig --seed 0xd3f16844
zig build -Dtest=true -Doptimize=ReleaseFast -Dlog-level=debug run
[LOG INFO]: available memory: 14495000 - 1ffe0000
[LOG INFO]: pci: found device at bus 0, slot 0, func 0
[LOG INFO]: pci: vendor id: 8086
[LOG INFO]: pci: device id: 1237
[LOG INFO]: pci: found device at bus 0, slot 1, func 0
[LOG INFO]: pci: vendor id: 8086
[LOG INFO]: pci: device id: 7000
[LOG INFO]: pci: found device at bus 0, slot 1, func 1
[LOG INFO]: pci: vendor id: 8086
[LOG INFO]: pci: device id: 7010
[LOG INFO]: pci: found device at bus 0, slot 1, func 3
[LOG INFO]: pci: vendor id: 8086
[LOG INFO]: pci: device id: 7113
[LOG INFO]: pci: found device at bus 0, slot 2, func 0
[LOG INFO]: pci: vendor id: 1234
[LOG INFO]: pci: device id: 1111
[LOG INFO]: pci: found device at bus 0, slot 3, func 0
[LOG INFO]: pci: vendor id: 1af4
[LOG INFO]: pci: device id: 1041
[LOG DEBUG]: offset: 0
[LOG DEBUG]: offset: 12288
[LOG DEBUG]: notify_off_multiplier: 4
[LOG DEBUG]: offset: 8192
[LOG DEBUG]: offset: 4096
[LOG DEBUG]: offset: 0
[LOG INFO]: mac: 52:54:0:12:34:56
[LOG DEBUG]: FILES_MAX: 200
[LOG DEBUG]: directory: ./
[LOG DEBUG]: regular file: ./output.txt
[LOG DEBUG]: regular file: ./test.txt
[LOG DEBUG]: root directory: fd=3, path=./
[LOG DEBUG]: WASI memory_grow: 1
[LOG INFO]: base: 0
[LOG DEBUG]: WASI sock_open: 1 2 0
[LOG INFO]: client socket test: sock_open succeeded
[LOG DEBUG]: WASI sock_connect: 4 4 80
[LOG DEBUG]: interrupt
[LOG DEBUG]: interrupt
[LOG INFO]: client socket test: sock_connect succeeded
[LOG DEBUG]: WASI fd_write: 4 12 2 52
[LOG INFO]: client socket t[LOG DEBUG]: interrupt
est: fd_write succeeded
[LOG DEBUG]: WASI sock_getlocaladdr: 4 4 40 44
[LOG DEBUG]: interrupt
[LOG DEBUG]: interrupt
[LOG DEBUG]: interrupt
[LOG INFO]: sock_getlocaladdr failed: 80.161.56.4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.