Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
543cb94
wasmtime: extract running module into function
t4chib4ne Sep 10, 2025
d878baf
wasmtime: Implement basic WASIp2 components support
t4chib4ne Sep 10, 2025
c05cf2e
wasmtime: Check functions after manual loading
t4chib4ne Sep 10, 2025
ce7d656
wasmtime: Add argv to wasm components; Change CMD to ENTRYPOINT in wa…
t4chib4ne Sep 10, 2025
dc2e2e1
wasmtime: have wasip2 inherit env
t4chib4ne Sep 11, 2025
b1c4da5
wasmtime: Fix wat to wasm compiling
t4chib4ne Sep 11, 2025
9a073f6
wasmtime: misc code cleanup
t4chib4ne Sep 12, 2025
e8cbc72
wasmtime: expand reading entrypoint error message
t4chib4ne Sep 19, 2025
741045a
wasmtime: Fix and Add preopen_dir for modules & components
t4chib4ne Sep 11, 2025
cf36a28
wasmtime: properly check wat file extension
t4chib4ne Sep 21, 2025
877ca9a
wasmtime: Add helper for wasm header interpretation
t4chib4ne Sep 21, 2025
d6b9778
wasmtime: branch execution path after wasm header interpretation
t4chib4ne Sep 21, 2025
49f0f42
wasmtime: fix typo in errmsg
t4chib4ne Sep 26, 2025
6b5a217
wasmtime: harden wasm_interpret_header func
t4chib4ne Oct 1, 2025
c08bb45
wasmtime: avoid NULL pointer after wasm compilation
t4chib4ne Oct 1, 2025
fbc799c
wasmtime: share common symbol loading
t4chib4ne Oct 8, 2025
b86db3c
wasmtime: use symbol loading helper everywhere
t4chib4ne Oct 8, 2025
0f89f34
wasmtime: ftell error handling
t4chib4ne Oct 10, 2025
1a5e2c2
wasmtime: use unified wasi api
t4chib4ne Nov 6, 2025
b2aeb51
wasmtime: compat for wasmtime < 39
t4chib4ne Nov 7, 2025
73df8d8
wasmtime: refactor libwasmtime_vm compat
t4chib4ne Nov 7, 2025
13377c7
wasmtime: add proper exit status handling
t4chib4ne Nov 7, 2025
c88c048
wasmtime: misc improvements
t4chib4ne Nov 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/wasm-wasi-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This is from a main function from a wasm module
```Containerfile
FROM scratch
COPY hello.wasm /
CMD ["/hello.wasm"]
ENTRYPOINT ["/hello.wasm"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you write it in commit message or here, about why is this change needed ?

Copy link
Author

Choose a reason for hiding this comment

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

Oh, sorry forgot to mention it ...

After adding the pass through of argv to the component I wanted to try it out. Upon running podman run mywasm-image:latest arg1 arg2 podman would replace CMD (the wasm binary) with arg1 which of course does not work. Changing to ENTRYPOINT resolves this.

Copy link
Collaborator

@flouthoc flouthoc Sep 12, 2025

Choose a reason for hiding this comment

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

This looks like a breaking change. I think adding this message to commit logs can help us revisit this and fix this if needed.

cc @giuseppe

Copy link
Author

Choose a reason for hiding this comment

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

Adding this to the commit logs should be possible but I don't really see where this is a breaking change? Without the changes of this PR a wasm module runs into the same problem. IIRC this is also the same behavior a non-wasm container would show.

Copy link
Author

Choose a reason for hiding this comment

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

Is the message in ce7d656 OK?

```
* Build wasm image using buildah
```console
Expand Down
23 changes: 23 additions & 0 deletions src/libcrun/handlers/handler-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define _GNU_SOURCE

#include <config.h>
#include <string.h>
#include "../container.h"
#include "../utils.h"
#include "handler-utils.h"
Expand Down Expand Up @@ -69,3 +70,25 @@ wasm_can_handle_container (libcrun_container_t *container, libcrun_error_t *err

return 0;
}

wasm_encoding_t
wasm_interpete_header (const char *header)
{
// Check for the WebAssembly magic bytes
// See: https://webassembly.github.io/spec/core/binary/modules.html#binary-module
if (strncmp (header, "\0asm", 4))
return WASM_ENC_INVALID;

/* The next four bytes are the WebAssembly version.
We don't care for the specific WebAssembly version
so we only read the value of the `layer` field which
was defined by the component spec.
See: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Binary.md#component-definitions
*/
if (header[6] == '\0' && header[7] == '\0')
return WASM_ENC_MODULE;

// `layer` does not equal `0x00 0x00` so we are working
// with a component.
return WASM_ENC_COMPONENT;
}
9 changes: 9 additions & 0 deletions src/libcrun/handlers/handler-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
#include "../container.h"
#include <unistd.h>

typedef enum
{
WASM_ENC_INVALID,
WASM_ENC_MODULE,
WASM_ENC_COMPONENT
} wasm_encoding_t;

int wasm_can_handle_container (libcrun_container_t *container, libcrun_error_t *err);

wasm_encoding_t wasm_interpete_header (const char *header);

#endif
Loading
Loading