All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>, "Greg Kurz" <groug@kaod.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Weiwei Li" <liwei1518@gmail.com>,
	"Daniel Henrique Barboza" <dbarboza@ventanamicro.com>,
	"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	qemu-block@nongnu.org, qemu-riscv@nongnu.org,
	qemu-arm@nongnu.org, "Kohei Tokunaga" <ktokunaga.mail@gmail.com>
Subject: Re: [PATCH 08/10] hw/9pfs: Allow using hw/9pfs with emscripten
Date: Sat, 12 Apr 2025 12:21:47 +0200	[thread overview]
Message-ID: <1881242.gqbg26PhFk@silver> (raw)
In-Reply-To: <2441396.svyq9LpYvz@silver>

On Saturday, April 12, 2025 10:21:47 AM CEST Christian Schoenebeck wrote:
> On Friday, April 11, 2025 12:47:29 PM CEST Kohei Tokunaga wrote:
> > Hi Christian,
> > 
> > > > Emscripten's fiber does not support submitting coroutines to other
> > > > threads. So this commit modifies hw/9pfs/coth.h to disable this behavior
> > > > when compiled with Emscripten.
> > >
> > > The lack of being able to dispatch a coroutine to a worker thread is one
> > > thing, however it would probably still make sense to use fibers in 9pfs as
> > > replacement of its coroutines mechanism.
> > >
> > > In 9pfs coroutines are used to dispatch blocking fs I/O syscalls from main
> > > thread to worker thread(s):
> > >
> > > https://wiki.qemu.org/Documentation/9p#Control_Flow
> > >
> > > If you just remove the coroutine code entirely, 9p server might hang for
> > good,
> > > and with it QEMU's main thread.
> > >
> > > By using fibers instead, it would not hang, as it seems as if I/O
> > syscalls are
> > > emulated in Emscripten, right?
> > 
> > Thank you for the feedback. Yes, it would be great if Emscripten's fiber
> > could be used to address this limitation. Since Emscripten's fiber is
> > cooperative, I believe a blocking code_block can still block the 9pfs server
> > unless an explicit yield occurs within it. I'll continue exploring better
> > solutions for this. Please let me know if I'm missing anything.
> 
> As far as I understand it, the I/O syscalls are emulated, and when being
> called by fibers, blocking syscalls would imply to yield under the hood,
> without explicit yield by application that is.
> 
> If that's true, it would only require little code changes for this to work.
> 
> > > Missing
> > >
> > >     errno = ENOTSUP;
> > 
> > Sure, I'll fix this in the next version of the series.
> > 
> > > Looks like you just copied the macOS errno translation code. That probably
> > > doesn't make sense.
> > 
> > Errno values differ between Emscripten and Linux, so conversion is required
> > here. I've used the same mappings as macOS for now, but I'm happy to add
> > more conversions if needed.
> 
> OK, but why have you chosen macOS errno mapping exactly? Are you testing on a
> macOS host machine? Are errno values of emscripten machine dependent?
> 
> The errno mapping must be correct, otherwise funny things will happen on guest
> side if 9p2000.L client is used, as it blindly expects errno numbers sent by
> 9p server to be in native Linux errno number presentation.

Let my answer my own question: I just checked the wasi sources. The errno
values are hard coded by the wasi API, consistent over systems. So the current
mapping of this patch is wrong. macOS uses a different mapping than the wasi
API.

https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/headers/public/__errno_values.h

https://github.com/emscripten-core/emscripten/blob/4af36cf80647f9a82be617a0ff32f3e56f220e41/system/include/wasi/api.h#L116

So please use a correct mapping as defined in that header file.

/Christian

> Alternatively 9p2000.u protocol variant could be used for Emscripten. Not
> ideal, as this 9p protocol version is somewhat a legacy protocol from QEMU
> perspective, reduced performance, less reliable, but it transmits error
> strings to client which it can map to correct errno values by itself. Linux 9p
> client uses a hash map for this errno translation of 9p2000.u error strings.
> 
> /Christian




  reply	other threads:[~2025-04-12 10:22 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07 14:45 [PATCH 00/10] Enable QEMU to run on browsers Kohei Tokunaga
2025-04-07 14:45 ` [PATCH 01/10] various: Fix type conflict of GLib function pointers Kohei Tokunaga
2025-04-09 10:54   ` Philippe Mathieu-Daudé
2025-04-09 13:43     ` Kohei Tokunaga
2025-04-10 15:58   ` Paolo Bonzini
2025-04-11 10:55     ` Kohei Tokunaga
2025-04-07 14:45 ` [PATCH 02/10] various: Define macros for dependencies on emscripten Kohei Tokunaga
2025-04-10 15:53   ` Paolo Bonzini
2025-04-11 10:59     ` Kohei Tokunaga
2025-04-07 14:45 ` [PATCH 03/10] util/mmap-alloc: Add qemu_ram_mmap implementation for emscripten Kohei Tokunaga
2025-04-07 14:45 ` [PATCH 04/10] util: Add coroutine backend " Kohei Tokunaga
2025-04-07 14:45 ` [PATCH 05/10] meson: Add wasm build in build scripts Kohei Tokunaga
2025-04-09 10:55   ` Philippe Mathieu-Daudé
2025-04-09 13:35     ` Paolo Bonzini
2025-04-10 12:24       ` Kohei Tokunaga
2025-04-10 12:55         ` Paolo Bonzini
2025-04-11 11:23           ` Kohei Tokunaga
2025-04-07 14:45 ` [PATCH 06/10] include/exec: Allow using 64bit guest addresses on emscripten Kohei Tokunaga
2025-04-07 14:45 ` [PATCH 07/10] tcg: Add a TCG backend for WebAssembly Kohei Tokunaga
2025-04-09 10:58   ` Philippe Mathieu-Daudé
2025-04-09 13:53     ` Kohei Tokunaga
2025-04-11 10:50   ` Philippe Mathieu-Daudé
2025-04-12  9:04     ` Kohei Tokunaga
2025-04-12  9:12       ` Kohei Tokunaga
2025-04-07 14:45 ` [PATCH 08/10] hw/9pfs: Allow using hw/9pfs with emscripten Kohei Tokunaga
2025-04-10 11:27   ` Christian Schoenebeck
2025-04-11 10:47     ` Kohei Tokunaga
2025-04-12  8:21       ` Christian Schoenebeck
2025-04-12 10:21         ` Christian Schoenebeck [this message]
2025-04-12 10:38           ` Christian Schoenebeck
2025-04-13  8:12             ` Kohei Tokunaga
2025-04-10 16:29   ` Paolo Bonzini
2025-04-11 14:03     ` Kohei Tokunaga
2025-04-07 14:46 ` [PATCH 09/10] gitlab: Enable CI for wasm build Kohei Tokunaga
2025-04-07 14:46 ` [PATCH 10/10] MAINTAINERS: Update MAINTAINERS file for wasm-related files Kohei Tokunaga
2025-04-09 19:21 ` [PATCH 00/10] Enable QEMU to run on browsers Stefan Hajnoczi
2025-04-10 12:20   ` Philippe Mathieu-Daudé
2025-04-10 13:11     ` Kohei Tokunaga
2025-04-10 13:13       ` Kohei Tokunaga
2025-04-10 21:17         ` Pierrick Bouvier
2025-04-11 14:36           ` Kohei Tokunaga
2025-04-11 15:28             ` Pierrick Bouvier
2025-04-11  9:07         ` Paolo Bonzini
2025-04-11 14:41           ` Kohei Tokunaga
2025-04-11 10:34   ` Daniel P. Berrangé
2025-04-11 15:17     ` Kohei Tokunaga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1881242.gqbg26PhFk@silver \
    --to=qemu_oss@crudebyte.com \
    --cc=alex.bennee@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=berrange@redhat.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=eduardo@habkost.net \
    --cc=groug@kaod.org \
    --cc=hreitz@redhat.com \
    --cc=ktokunaga.mail@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=liwei1518@gmail.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    --cc=zhiwei_liu@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.