Adding arbitrary files not possible when compiled with Emscripten.
I followed this guide in attempting to add some files into the wasm container and it doesn't seem to work in this example here: https://github.com/ktock/qemu-wasm/tree/master/examples/virtfs when compiling the container with emscripten.
After building the container and adding the -virtfs flag, I always get this error in the emulator when running the container with the flag:
this.program: -virtfs local,path=/share,mount_tag=share0,security_model=passthrough,id=share0: cannot initialize fsdev 'share0': failed to open '/share': No such file or directory
Even when using the modules.js to attempt to modify the existing /pack folder to write a file into that patch as shown in the example, I don't see the files in the emulator when I write a file to the directory.
Is there a way to add files to the container when compiled with Emscripten so that they appear in the emulator?
Is there a solution to this? @ktock
@pateljoel
it doesn't seem to work in this example here: https://github.com/ktock/qemu-wasm/tree/master/examples/virtfs
I've just tried this step but coudn't reproduce the error. Can you provide steps to reproduce this error so that I can debug the problem?
@ktock Yeah sure, I used these following steps below, but managed to get past the initial error but still could not access the file system / mount or write a new file before booting the VM:
-
I followed this guide to build for emscripten: https://github.com/container2wasm/container2wasm/tree/main/examples/emscripten#step-1-converting-an-image-to-wasm
-
After it was built, I then modified the module.js file it created to create a mounted directory before booting the container as shown in: https://github.com/ktock/qemu-wasm/tree/master/examples/virtfs
I added this line into the Module['arguments'] array in module.js
Module['arguments'] = [
....
'-virtfs', 'local,path=/share,mount_tag=share0,security_model=passthrough,id=share0',
];
- My index.html adds this code to write to the share folder:
Module['preRun'].push((mod) => {
mod.FS.mkdir('/share');
mod.FS.writeFile('/share/file', 'test');
});
- Finally I refreshed and booted the VM without the
-incomingflag and it booted to the shell, but still could not access the mounted path even after attempting to mount the path.
Here is the log of this here: https://gist.github.com/pateljoel/bd27a4f73422a301b3bdf2d8944ee493
@ktock Any luck reproducing this issue with these steps?