summary refs log tree commit diff
path: root/msg_socket
Commit message (Collapse)AuthorAge
* msg_socket: introduce UnixSeqpacketExtAlyssa Ross2020-06-15
| | | | | | | | | | | | | | | | | | | | | | Occasionally, it is useful to be able to use UnixSeqpacket as a type that can represent any kind of MsgSocket. For example, to keep some MsgSockets of different types in a Vec. In this case, it may be known what type of messages should be sent over a socket, even though that may not be represantable in the type system. To accomodate this situation, this patch introduces send_msg_on_socket and recv_msg_on_socket methods on UnixSeqpacket, that can be used to send or receive any kind of MsgOnSocket. The caller is obviously responsible for ensuring that the messages being sent are of the type expected by the socket. This lack of type safety for message types is not ideal, and so MsgSender and MsgReceiver should still be preferred wherever possible. Message-Id: <20200614114344.22642-2-hi@alyssa.is> Notes: Reviewed-by: Cole Helbling <cole.e.helbling@outlook.com>
* msg_socket: fix broken testsAlyssa Ross2020-06-14
| | | | I must have forgotten to test these after merging with upstream.
* Merge remote-tracking branch 'origin/master'Alyssa Ross2020-06-14
|\
| * msg_socket: implement MsgOnSocket for Vec and tuplesZach Reizner2020-06-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These container types are similar to arrays except tuples have heterogeneous data types and Vec has a dynamic number of elements. BUG=None TEST=cargo test -p msg_socket Change-Id: I2cbbaeb7f13b7700294ac50751530510098ba16d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2168588 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>
* | Merge remote-tracking branch 'origin/master'Alyssa Ross2020-06-14
|\|
| * sys_util: Refactor IntoIovecChirantan Ekbote2020-05-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original stated purpose of this trait was to reduce memory allocations but having the `into_iovec` method return a Vec kind of defeats that purpose. Refactor the trait so that it can either convert a T into an iovec or convert a &[T] into a &[iovec]. Implement the trait for VolatileSlice, IoSlice, and IoSliceMut and update all the callers. BUG=none TEST=unit tests Cq-Depend: chromium:2210272 Change-Id: I9d0d617a23030d241d50411f4a5a16e7cba4bcee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2208527 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Tested-by: Chirantan Ekbote <chirantan@chromium.org>
* | Merge remote-tracking branch 'origin/master'Alyssa Ross2020-05-22
|\|
| * msg_socket: remove MsgOnSocket impl for RawFd, an alias for i32Zach Reizner2020-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implementation makes it impossible to use i32 as ordinary data in a MsgOnSocket implementation. It is also error prone because i32 is the default type for integer literals in Rust, and #[derive(MsgOnSocket)] on structs with an i32 would suddenly be transmitting a RawFd. This change also replaces the uses of RawFd's MsgOnSocket impl for one based on File. TEST=cargo build BUG=None Change-Id: I9da392e34e62fe61f773f24d656dbcbf4716f1a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197777 Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
| * msg_socket: fix MsgOnSocket::msg_size for Option<T>Zach Reizner2020-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This caused None values to be transmitted as zero-bytes, which usually caused not enough buffer space to be allocated for sending. BUG=None TEST=cargo test -p msg_socket Change-Id: If12d2df56689a84054405f2ba15d1c268afad15e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197776 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>
| * Implements the Hypervisor trait for Kvm.Udam Saini2020-05-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the ability for getting both supported/emulated cpuids from the kvm hypervisor. In addition, checking the available capabilities for kvm is now implemented. BUG=chromium:1077058 TEST=Added unit tests for each implemented function. Change-Id: Ide4c2840b7bfa022deae835eb734ea97c1859169 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2177641 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Udam Saini <udam@google.com>
* | msg_socket: impl std::error::Error for MsgErrorAlyssa Ross2020-05-22
| |
* | msg_socket: fmtAlyssa Ross2020-05-10
| |
* | Merge remote-tracking branch 'origin/master'Alyssa Ross2020-05-10
|\|
| * msg_socket: AsyncReceiver doesn't need a mut refDylan Reid2020-05-07
| | | | | | | | | | | | | | | | | | | | | | | | The AsyncReceiver doesn't need to modify the message receiver so let it take a plain old borrow. Change-Id: I07e93d2ed12327dd893fec654d2bdd613a848fe6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2167694 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
| * cros_async: Hide the details of fd_executorDylan Reid2020-05-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The type of the executor leaked from the cros_async crate. That was fine until the desire to add a new executor arose. Hide the fd_executor so that a uring_executor can be substituted on newer kernels. Change-Id: I8dd309fd47e1b4a6e16da274abbb8431c80474af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2182042 Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
| * msg_socket: impl skip helper attributeZach Reizner2020-05-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fields with a default value can be skipped using the `#[msg_on_socket(skip)]` attribute. TEST=cargo test -p msg_socket BUG=None Change-Id: I9fea33e641a7da62b7864ba1847e884b32502491 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2168587 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>
| * msg_socket: impl for Arc and MutexZach Reizner2020-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These types are simple wrappers, and so this change just adds trivial passthroughs. For data sent over a socket, the data is not Arc-ed or Mutex-ed on the other end with the same ref count or lock. Sending over the data is more like a deep copy, rather than a simple ref count increase. TEST=cargo test -p msg_socket BUG=None Change-Id: I519096b0b3b6ab75e79c37addf0d60ce3da4a717 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2168586 Commit-Queue: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
| * msg_socket: AsyncReceiver doesn't need a mut refDylan Reid2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | The mut reference isn't used, an immutable reference is sufficient. Switch to make borrowing the receiver easier for users. Change-Id: Ic8582deb68997de53e5a53730b3909a1c4dcf699 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2159936 Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
| * msg_socket: add specialized error for zero sized recvZach Reizner2020-04-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Receiving no data can be considered a special case for MsgOnSocket. It doesn't necessarily indicate EOF because usually messages are sent over a datagram channel and some fixed sized messages are actually zero sized. This change handles this by adding a specific result for receiving no data when at least some was expected. This will also simplify some error handling that had to unpack the `BadRecvSize` variant. TEST=cargo test -p msg_socket BUG=None Change-Id: I16feeabc1481de93a2b189989d095434b5b417b5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2079178 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Auto-Submit: Zach Reizner <zachr@chromium.org>
| * msg_socket: allow Enum with no variant filed typesChuanxiao Dong2020-04-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to allow the Enum which doesn't have filed type for all its variants to derive the MsgOnSocket. BUG=None TEST=cargo test -p msg_socket Change-Id: Iab9edda777f42e25af40e4ec0e5870401c17572b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2143572 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
* | Remove unnecessary "extern crate" linesAlyssa Ross2020-04-11
| | | | | | | | | | The proc_macro ones have been unnecessary since Rust 1.42, and the rest have been unnecessary since the 2018 edition.
* | crosvm: collapse simple boolean matchesAlyssa Ross2020-04-11
| | | | | | | | | | Rust 1.42 introduces matches!(), which can be used to collapse simple match statements like these.
* | msg_socket: fix derive for unit enumsAlyssa Ross2020-04-10
| |
* | Merge remote-tracking branch 'origin/master'Alyssa Ross2020-04-10
|\|
| * msg_socket: support dynamically sized typesZach Reizner2020-04-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | msg_socket: fix doc typoAlyssa Ross2020-03-25
| |
* | msg_socket: don't force array elements to be cloneAlyssa Ross2020-03-10
| | | | | | | | | | | | | | | | | | | | There didn't seem to be any reason for this restriction. From #crosvm: <qyliss> Why does the implementation of MsgOnSocket for arrays require that elements be Clone? <qyliss> It seems to work just fine if I remove the clone() call and Clone requirement <zachr> I suspect that there is no good reason.
* | msg_socket: SocketMsg -> MsgSocketAlyssa Ross2020-03-10
| | | | | | | | | | | | I suspect this is an old name that had stuck around. The internal functions being named socket_msg_* didn't really matter, but the "derive(SocketMsg)" error message was confusing.
* | Merge remote-tracking branch 'origin/master' into masterAlyssa Ross2020-03-09
|\|
| * msg_socket: Add async receiving of messagesDylan Reid2020-02-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a member to MsgSocket that effectively returns an async iterator over messages received on the socket. This is done by setting the socket as non-blocking and registering with the async infrastructure when the socket would block. This feature will be used by devices that wish to handle messages in an async fn context. Change-Id: I47c6e83922068820cd19ffd9ef604ed8a16b755e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1997243 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org>
* | msg_socket::MsgOnSocket: fix Markdown formattingAlyssa Ross2020-02-11
|/
* sys_util: recv entire UnixSeqpacket packets into VecZach Reizner2020-02-06
| | | | | | | | | | | | | | | | | | This change adds the `recv_*_vec` suite of methods for getting an entire packet into a `Vec` without needing to know the packet size through some other means. TEST=cargo test -p sys_util -p msg_socket BUG=None Change-Id: Ia4f931ccb91f6de6ee2103387fd95dfad3d3d38b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2034025 Commit-Queue: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Update syn, quote, and proc-macro past 1.0Dylan Reid2020-02-06
| | | | | | | | | | | | | | These were pinned at pre-1.0 versions. Update to the stable API to allow new features to be used in the future. Cq-Depend: chromium:2026764 Change-Id: Id2d979525e5210436cbb1cfa61e2b05fafb288f3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2025907 Tested-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* MsgSocket: Don't implement DerefChirantan Ekbote2020-01-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Deref trait is usually only implemented by smart pointers or by trivial wrappers around the underlying type. MsgSocket does not fit into either category because it wraps a `UnixSeqPacket` to provide new functionality. Having it implement can lead to confusing error messages, especially for people who are new to rust and are not familiar with the Deref trait and Deref coercion. For example, calling `sock.send()` on a MsgSocket without first adding `use msg_socket::MsgSender` leads to the compiler complaining about mis-matched types for the `send` method. `UnixSeqPacket::send` expects a `&[u8]` while `MsgSocket::send` expects a `&M`. The compiler also gives no clues that it is implicitly coercing the socket to a `&UnixSeqPacket` and using the `send` method from there. Drop the `Deref` implementation. `MsgSocket` already implements `AsRef<UniqSeqPacket>` so anything that _needs_ to access the underlying `UnixSeqPacket` should just use that. BUG=none TEST=unit tests Change-Id: If02ef7173ae21d85d517e808489ed4d6d09ae90b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2002997 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* msg_socket: Change trait type parameters to associated typesChirantan Ekbote2020-01-12
| | | | | | | | | | | | | | | | | | | | | | The `MsgSender` and `MsgReceiver` traits take a type parameter for the message to be sent / received. However this ends up trickling down to every user of these traits, who need to add these type parameters whenever they want to use the trait. Change the type parameters to associated types instead. The associated types keep the same trait bounds but now users of the traits don't need to care about the exact message being sent / received. BUG=none TEST=cargo test Change-Id: I733a21877cbe49b7904040b8cc6c3436d5e3439f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1993160 Tested-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
* eliminate usage of uninitializedZach Reizner2019-05-23
| | | | | | | | | | | | | | | | | uninitialized is deprecated and considered too dangerous to use for any of the use cases we were using. BUG=None TEST=passes smoke_test Change-Id: I5392cb8ec132f374d9b5590f72eb2cb329a82421 Reviewed-on: https://chromium-review.googlesource.com/1626795 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Extracts BalloonAdjust from VmRequest.Jakub Staron2019-04-25
| | | | | | | | | | | | | | | | | Extracts BalloonAdjust from VmRequest into BalloonControlCommand. BUG=None TEST=cargo test TEST=cargo test --package msg_socket TEST=cargo test --package devices TEST=cargo test --package vm_control TEST=tast -verbose run ${IP} vm.CrostiniStartEverything Change-Id: Ia9f5778c37c8fd4fa560df413134d1b441142f64 Reviewed-on: https://chromium-review.googlesource.com/1565298 Commit-Ready: Jakub StaroĊ„ <jstaron@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* crosvm: add license blurb to all filesStephen Barber2019-04-24
| | | | | | | | | | | | | | A few files were missing license blurbs at the top, so update them all to include them. BUG=none TEST=none Change-Id: Ida101be2e5c255b8cffeb15f5b93f63bfd1b130b Reviewed-on: https://chromium-review.googlesource.com/1577900 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* edition: Eliminate ref keywordDavid Tolnay2019-04-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As described in: https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/default-match-bindings.html which also covers the new mental model that the Rust Book will use for teaching binding modes and has been found to be more friendly for both beginners and experienced users. Before: match *opt { Some(ref v) => ..., None => ..., } After: match opt { Some(v) => ..., None => ..., } TEST=cargo check --all-features TEST=local kokoro Change-Id: I3c5800a9be36aaf5d3290ae3bd3116f699cb00b7 Reviewed-on: https://chromium-review.googlesource.com/1566669 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* msg_socket: Remove redundant supertrait boundDavid Tolnay2019-04-17
| | | | | | | | | | | | | | | | | | | | | | | | | We have: unsafe trait AlignedNew: Sized + DataInit {...} unsafe trait DataInit: Copy + Send + Sync {...} trait Copy: Clone {...} trait Clone: Sized {...} Since Sized is already indirectly a supertrait of DataInit, including it again as a supertrait of AlignedNew has no effect. This CL removes the redundant Sized bound. TEST=cargo check Change-Id: I8ee2a9ee8892c95e6b0dd4bac1b662cd97441984 Reviewed-on: https://chromium-review.googlesource.com/1568077 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Eliminate blocks superseded by NLLDavid Tolnay2019-04-17
| | | | | | | | | | | | | | | | | | | | Before the new borrow checker in the 2018 edition, we sometimes used to have to manually insert curly braced blocks to limit the scope of borrows. These are no longer needed. Details in: https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/non-lexical-lifetimes.html TEST=cargo check --all-features TEST=local kokoro Change-Id: I59f9f98dcc03c8790c53e080a527ad9b68c8d6f3 Reviewed-on: https://chromium-review.googlesource.com/1568075 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Remove extern crate linesDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Rust 2018 edition, `extern crate` is no longer required for importing from other crates. Instead of writing: extern crate dep; use dep::Thing; we write: use dep::Thing; In this approach, macros are imported individually from the declaring crate rather than through #[macro_use]. Before: #[macro_use] extern crate sys_util; After: use sys_util::{debug, error}; The only place that `extern crate` continues to be required is in importing the compiler's proc_macro API into a procedural macro crate. This will hopefully be fixed in a future Rust release. extern crate proc_macro; TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu TEST=local kokoro Change-Id: I0b43768c0d81f2a250b1959fb97ba35cbac56293 Reviewed-on: https://chromium-review.googlesource.com/1565302 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* edition: Fill in macro importsDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | Macros were previously imported through `#[macro_use] extern crate`, which is basically a glob import of all macros from the crate. As of 2018 edition of Rust, `extern crate` is no longer required and macros are imported individually like any other item from a dependency. This CL fills in all the appropriate macro imports that will allow us to remove our use of `extern crate` in a subsequent CL. TEST=cargo check --all-features --tests TEST=kokoro Change-Id: If2ec08b06b743abf5f62677c6a9927c3d5d90a54 Reviewed-on: https://chromium-review.googlesource.com/1565546 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* msg_socket: Simplify derive by removing const namespaceDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The derive(MsgOnSocket) macro used to expand to something like: const __MSG_ON_SOCKET_IMPL_Typename: () = { extern crate msg_socket as _msg_socket; impl _msg_socket::MsgOnSocket for Typename { ... } }; This was helpful in 2015 edition code by allowing callers to invoke the derive without also writing `use msg_socket` at the top of the file to bring the crate into scope. In 2018 edition, paths beginning with a crate name do not need to be otherwise imported, so this derive can simply expand to: impl msg_socket::MsgOnSocket for Typename { ... } TEST=cargo test msg_socket TEST=cargo test msg_on_socket_derive Change-Id: I61b672b64404523f601de1d538ebe554985a0905 Reviewed-on: https://chromium-review.googlesource.com/1565545 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* cargo: Sort all dependency lists in Cargo.tomlDavid Tolnay2019-04-09
| | | | | | | | | | | | | | | This may help reduce cases of conflicts between independent CLs each appending a dependency at the bottom of the list, of which I hit two today rebasing some of my open CLs. TEST=cargo check --all-features Change-Id: Ief10bb004cc7b44b107dc3841ce36c6b23632aed Reviewed-on: https://chromium-review.googlesource.com/1557172 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Update msg_socket to 2018 editionDavid Tolnay2019-04-08
| | | | | | | | | | | | | | | | | | Separated out of CL:1513058 to make it possible to land parts individually while the affected crate has no other significant CLs pending. This avoids repeatedly introducing non-textual conflicts with new code that adds `use` statements. TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: I6d541d6d51498612c82072c64cb78eefcb2abb8c Reviewed-on: https://chromium-review.googlesource.com/1519700 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* msg_socket: derive MsgOnSocket for boolDaniel Prilik2019-04-04
| | | | | | | | | | | BUG=chromium:936567 TEST=cargo test -p msg_socket Change-Id: I5f9228ceaa7a3fcfbe154bf173a76e0ee26b8c50 Reviewed-on: https://chromium-review.googlesource.com/1548694 Commit-Ready: Daniel Prilik <prilik@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* edition: Update absolute paths to 2018 styleDavid Tolnay2019-03-13
| | | | | | | | | | | | | | | | | | | | | | | | | | This is an easy step toward adopting 2018 edition eventually, and will make any future CL that sets `edition = "2018"` this much smaller. The module system changes in Rust 2018 are described here: https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html Generated by running: cargo fix --edition --all in each workspace, followed by bin/fmt. TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: I000ab5e69d69aa222c272fae899464bbaf65f6d8 Reviewed-on: https://chromium-review.googlesource.com/1513054 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* msg_socket: implement MsgOnSocket for Option<MsgOnSocket>Zach Reizner2019-03-08
| | | | | | | | | | | | | | This is convenient for types that embed Option<...>. BUG=chromium:831850 TEST=cargo test Change-Id: I65aa3515f49e4424eff54f17ae18dac8e85b0afa Reviewed-on: https://chromium-review.googlesource.com/1510812 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Jingkui Wang <jkwang@google.com>
* crosvm: use seqpacket rather than datagram socketsZach Reizner2019-02-28
| | | | | | | | | | | | | | | | | | | | The advantage of seqpacket is that they are connection oriented. A listener can be created that accepts new connections, useful for the path based VM control sockets. Previously, the only bidirectional sockets in crosvm were either stream based or made using socketpair. This change also whitelists sendmsg and recvmsg for the common device policy. TEST=cargo test BUG=chromium:848187 Change-Id: I83fd46f54bce105a7730632cd013b5e7047db22b Reviewed-on: https://chromium-review.googlesource.com/1470917 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>