Skip to content
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

Make the utility maybe_open_stdio cross platform #240

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

jsturtevant
Copy link
Contributor

The removes an unused function in wasmtime and also updates maybe_open_stdio to cross-platform helper (part of #49 and #238)

Mossaka
Mossaka previously approved these changes Aug 14, 2023
Copy link
Member

@Mossaka Mossaka left a comment

Choose a reason for hiding this comment

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

LGTM!

@cpuguy83
Copy link
Member

Needs a rebase.

@jsturtevant
Copy link
Contributor Author

/hold going to try #226 (comment)

@jsturtevant
Copy link
Contributor Author

@jprendes the second commit here has your suggestion, Since the merge of #156 stdio is passed to both so I need an additional step

@jsturtevant jsturtevant force-pushed the use-cross-platfrom-file branch from 1e7ffe7 to b1b2a7f Compare August 15, 2023 22:22
@jsturtevant
Copy link
Contributor Author

this is ready for review again
/assign @Mossaka @utam0k @jprendes

Copy link
Collaborator

@jprendes jprendes left a comment

Choose a reason for hiding this comment

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

I'm not a big fan of try_clone-ing the file, since that opens yet another fd for the same file.
But it works, and would unblock you to continue working on windows support.
I am happy for this to be merged as is.

@cpuguy83: I agree with you in #226 (comment) and think that would also improve the file handling here.

io::ErrorKind,
os::fd::{IntoRawFd, RawFd},
os::fd::AsRawFd,
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: Does this build on Windows? I thought AsRawFd was only available on unix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is, will clean it up in #238

@jsturtevant
Copy link
Contributor Author

I'm not a big fan of try_clone-ing the file, since that opens yet another fd for the same file.

I wasn't too happy with this either but wasn't sure how else to handle the ownership here (open to suggestions). Initially, reading the docs I didn't get that it will create a second FD since it says it would use "same underlying file handle" but I see it uses fcntl which will give a new FD.

Will open an issue for #226 (comment) to follow up.

@jprendes
Copy link
Collaborator

Feel free to drop b1b2a7f from the PR as that would be part of the new issue :-)

@jsturtevant
Copy link
Contributor Author

Feel free to drop b1b2a7f from the PR as that would be part of the new issue :-)

done, put it over here for future reference https://github.com/containerd/runwasi/compare/main...jsturtevant:runwasi:use-cross-platfrom-file-backup?expand=1

Copy link
Member

@Mossaka Mossaka left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -13,6 +8,11 @@ use containerd_shim_wasm::sandbox::instance_utils::maybe_open_stdio;
use containerd_shim_wasm::sandbox::{EngineGetter, InstanceConfig};
use nix::unistd::close;
use serde::{Deserialize, Serialize};
use std::fs::File;
Copy link
Member

Choose a reason for hiding this comment

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

Why are these imports moved to here? Did you use a formatter to do it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It think so, I didn't notice but I did run make fix which runs fmt and clippy and looks like it re-ordered them alphabetically

Copy link
Member

Choose a reason for hiding this comment

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

umm rustfmt and clippy won't re-order imports alphabetically IIRC.

@Mossaka Mossaka merged commit 0e94ae4 into containerd:main Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants