Add Module::deserialize_open_file#9571
Conversation
Add an API to deserialize a `Module` from an already opened file. This can be useful in situations where `wasmtime` is running in a sandboxed environment with limited access to the file system. Then another process can handle opening the files and passing them to `wasmtime`.
ccc946e to
cac7bb3
Compare
Module::from_trusted_open_fileModule::deserialize_open_file
fitzgen
left a comment
There was a problem hiding this comment.
LGTM, but I am not sure I understand what you are getting at with regards to windows, so we should resolve that before merging. Thanks!
|
Not necessarily obvious to find but the failure is a Windows-specific one |
|
Yeah @alexcrichton is right - it looks like a simple Also ran the full CI on the branch now, so the previous windows failure should be good. |
fitzgen
left a comment
There was a problem hiding this comment.
I think there is a writable vs readable swaparoo in the docs. AFAICT, it is readable and executable, not writable and executable, and if that is true then this is good to merge with that doc comment fixed.
If my understanding is off, and we are actually mapping as writable and executable, then I think we want to revisit what we're doing here, since that is a pretty scary widget to expose!
| /// Note that the corresponding will be mapped as private writeable | ||
| /// (copy-on-write) and executable. For `windows` this means the file needs | ||
| /// to be opened with at least `FILE_GENERIC_READ | FILE_GENERIC_EXECUTE` | ||
| /// [`access_mode`]. |
There was a problem hiding this comment.
Does it need to be writable? Seems like it should be (and maybe actually is?) readable and executable?
There was a problem hiding this comment.
In windows we create the mapping with protection PAGE_EXECUTE_WRITECOPY which only requires the file handle was created with FILE_GENERIC_READ and FILE_GENERIC_EXECUTE access (docs here). It looks like write access would only be required if writes were being persisted to the file, but since we use copy-on-write it's not needed. Maybe I should add a link to these windows docs in comment for further clarity?
|
Ah I think Nick is on vacation right now so I'll take this over and flag for merge. I think the last doc bit is fine for now and we can always update it as necessary later on. |
Add an API to deserialize a
Modulefrom an already opened file. This can be useful in situations wherewasmtimeis running in a sandboxed environment with limited access to the file system. Then another process can handle opening the files and passing them towasmtime.