diff options
author | Zach Reizner <zachr@google.com> | 2020-01-28 13:18:09 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-05 15:10:47 +0000 |
commit | 146450b4569e86657d1d8c4ffe17524781aae7e3 (patch) | |
tree | def385d4cf3e5c0e5f96169f8f9555800a9daadd /vm_control | |
parent | 773c70740e98c1aaf73a7b02e65eadaeab33c9d8 (diff) | |
download | crosvm-146450b4569e86657d1d8c4ffe17524781aae7e3.tar crosvm-146450b4569e86657d1d8c4ffe17524781aae7e3.tar.gz crosvm-146450b4569e86657d1d8c4ffe17524781aae7e3.tar.bz2 crosvm-146450b4569e86657d1d8c4ffe17524781aae7e3.tar.lz crosvm-146450b4569e86657d1d8c4ffe17524781aae7e3.tar.xz crosvm-146450b4569e86657d1d8c4ffe17524781aae7e3.tar.zst crosvm-146450b4569e86657d1d8c4ffe17524781aae7e3.zip |
msg_socket: support dynamically sized types
This change is a major shift in how the MsgOnSocket trait works to allow `self` to be used to determine the result `msg_size()`. This is to support data structures with `Vec` or other dynamically sized type. TEST=./build_test cargo test -p msg_socket tast run <DUT> crostini.CopyPaste.* BUG=None Cq-Depend: chromium:2025907 Change-Id: Ibdb51b377b2a2a77892f6c75e1a9f30b2f8b0240 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2029930 Tested-by: Zach Reizner <zachr@chromium.org> Auto-Submit: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'vm_control')
-rw-r--r-- | vm_control/src/lib.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/vm_control/src/lib.rs b/vm_control/src/lib.rs index 92af2c6..cb836be 100644 --- a/vm_control/src/lib.rs +++ b/vm_control/src/lib.rs @@ -43,10 +43,13 @@ impl AsRawFd for MaybeOwnedFd { // When sent, it could be owned or borrowed. On the receiver end, it always owned. impl MsgOnSocket for MaybeOwnedFd { - fn msg_size() -> usize { - 0usize + fn uses_fd() -> bool { + true } - fn max_fd_count() -> usize { + fn fixed_size() -> Option<usize> { + Some(0) + } + fn fd_count(&self) -> usize { 1usize } unsafe fn read_from_buffer(buffer: &[u8], fds: &[RawFd]) -> MsgResult<(Self, usize)> { |