-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exporting dec_ciovec_slice and ciovec_to_host in wasi-common #939
Comments
Does #701 help with your use case? |
Not exactly. I have an unusual use case but at a high level, the idea is to asynchronously stream a transformed version of stdout and stderr over a network call. Virtual files are better than physical files but it's still an unnecessary abstraction for what I intend to implement. |
@kubkon and I are in the middle of a major renovation to wasi-common (starting with https://github.com/kubkon/wiggle, a new code generator that will take care of all marshalling and validation to and from guest memory) that will eliminate dec_ciovec_slice and ciovec_to_host in the library. Instead, new types and methods will take care of the transformation from the scattered iovecs in guest memory into Therefore, exporting those funcs wouldn't help much for more than a couple of weeks. You could just copy their implementation into whatever code you need, but if the representation of iovecs ever changes, that will be brittle. So, if possible, I'd try building on top of the VirtualFile trait, and using the IoSlice types as the basis of your transformations. If there's something about using that abstraction that is too costly, we should look into that deeper, but I'd like to hold off on that until 701 and the wiggle renovations land. |
Sorry, I missed the public |
Glad to see #701 has been merged. Unfortunately I can't seem to figure out how to use the new How do I map stdout and stderr to a custom implementation of |
Is there anything on the roadmap for supporting what I've proposed above? Another option is if we could get access to the pre-opened file descriptors in the WASI context, then we could wrap |
Sorry for the delay. I think @kubkon is currently working on that aspect of the code. I haven't kept up with every change that has landed & is underway over there. |
Hi @jeffcharles! I haven't read into your issue here in too much detail, but I think what you might be looking for, I'm just now trying to bake in into |
Almost, I want to attach our own virtual files to stdout and stderr. Attaching our own virtualfs to stdio would accomplish that. Really I just want some sort of interface that gives us byte arrays or io slices that we can operate on when an |
@jeffcharles Cool! Let me see what I can conjure up! If I have any questions, is it OK if I ping you now and then? Also, if it's any more convenient for you, we can sync up on BA's zulip chat as well. Let me know what works best! |
@pchickey @jeffcharles ok, I've now created a draft PR (#1600) that hopefully addresses your requirements. With this PR, you should now be able to pass in any implementor of the |
It looks like that draft PR does. Just to confirm my understanding of how this would work as a consumer, I should be able to define a custom implementation for |
If I read it right, then yeah, that's the basic idea. In fact, in that draft PR, anything that conforms to the let virt_stdout = InMemoryFile::new(Box::new(custom_file_contents));
let ctx: WasiCtx = WasiCtxBuilder::new().stdout(virt_stdout).build()?; While we're here, you'll note that you have to provide an instance that implements the |
I have a use-case where I'd like to perform some operations on the data being sent through an
fd_write
call on the host rather than sending it through to an underlying file descriptor. The existingfd_write
call doesn't appear to offer the ability to work with the input data on the host.What I think I want (and feel free to correct me if it isn't) is something that would convert the scatter gather IO vectors passed into
fd_write
to a u8 slice. I think combiningdec_ciovec_slice
andciovec_to_host
and flattening the resulting IO slices should do that. Would there be any interest in either exporting these functions or exporting a function that would use these two functions to return a slice of the data provided as input tofd_write
?The text was updated successfully, but these errors were encountered: