summary refs log tree commit diff
path: root/msg_socket
Commit message (Collapse)AuthorAge
* 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>
* error: Print errors using Display implDavid Tolnay2019-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | I have been running into Debug-printed error messages too often and needing to look up in the source code each level of nested errors to find out from the comment on the error variant what the short name of the variant means in human terms. Worse, many errors (like the one shown below) already had error strings written but were being printed from the calling code in the less helpful Debug representation anyway. Before: [ERROR:src/main.rs:705] The architecture failed to build the vm: NoVarEmpty After: [ERROR:src/main.rs:705] The architecture failed to build the vm: /var/empty doesn't exist, can't jail devices. TEST=cargo check --all-features TEST=FEATURES=test emerge-amd64-generic crosvm Change-Id: I77122c7d6861b2d610de2fff718896918ab21e10 Reviewed-on: https://chromium-review.googlesource.com/1469225 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>
* toolchain: Update to Rust 1.31.0David Tolnay2018-12-13
| | | | | | | | | | | | | | | | | | We updated the production toolchain from 1.30 to 1.31 in CL:1366446. This CL does the same upgrade for the local developer toolchain and Kokoro. The relevant changes are in rust-toolchain and kokoro/Dockerfile. The rest are from rustfmt. TEST=cargo fmt --all -- --check TEST=as described in kokoro/README.md Change-Id: I3b4913f3e237baa36c664b4953be360c09efffd4 Reviewed-on: https://chromium-review.googlesource.com/1374376 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* lint: Resolve the easier clippy lintsDavid Tolnay2018-12-03
| | | | | | | | | | | | | | | | | | | | Hopefully the changes are self-explanatory and uncontroversial. This eliminates much of the noise from `cargo clippy` and, for my purposes, gives me a reasonable way to use it as a tool when writing and reviewing code. Here is the Clippy invocation I was using: cargo +nightly clippy -- -W clippy::correctness -A renamed_and_removed_lints -Aclippy::{blacklisted_name,borrowed_box,cast_lossless,cast_ptr_alignment,enum_variant_names,identity_op,if_same_then_else,mut_from_ref,needless_pass_by_value,new_without_default,new_without_default_derive,or_fun_call,ptr_arg,should_implement_trait,single_match,too_many_arguments,trivially_copy_pass_by_ref,unreadable_literal,unsafe_vector_initialization,useless_transmute} TEST=cargo check --features wl-dmabuf,gpu,usb-emulation TEST=boot linux Change-Id: I55eb1b4a72beb2f762480e3333a921909314a0a2 Reviewed-on: https://chromium-review.googlesource.com/1356911 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* msg_socket: reformat with rust fmtDaniel Verkamp2018-11-22
| | | | | | | | | | | TEST=cargo fmt -- --check BUG=None Change-Id: I489def320a27336dd85743f7bf5b944756425c52 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1347009 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Jingkui Wang <jkwang@google.com>
* msg_socket: fix msg_on_socket alignment issueJingkui Wang2018-11-21
| | | | | | | | | | | | | | | Instead of using unaligned memory. Allocate aligned memory and copy into it, we were already doing an clone. There should be no overhead for this new approach. BUG=chromium:900962 TEST=build and run Change-Id: I011d4c93a872d7d285e8898ff332f3ee1ef104a9 Reviewed-on: https://chromium-review.googlesource.com/1344225 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* macros: Format code inside of quote! invocationsDavid Tolnay2018-11-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rustfmt currently does not touch the content of macro invocations. Also it used to have a bug where if it changed indentation of a block of code containing a multi-line macro invocation then the macro input would not get correspondingly indented. That bug was visible across some of the code here. For example: // rustfmt decides to un-indent the surrounding block: let data_size_in_bytes = quote!( ( #( #field_types::FIELD_WIDTH as usize )+* ) / 8 ); // poorly formatted resulting code: let data_size_in_bytes = quote!( ( #( #field_types::FIELD_WIDTH as usize )+* ) / 8 ); // should have been: let data_size_in_bytes = quote!( ( #( #field_types::FIELD_WIDTH as usize )+* ) / 8 ); TEST=cargo check crosvm TEST=cargo test each of the three proc-macro crates CQ-DEPEND=CL:1338507 Change-Id: Id2d456a8d85d719fbc0a65624f153f0f9df6f500 Reviewed-on: https://chromium-review.googlesource.com/1338508 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
* macros: Update syn to 0.15David Tolnay2018-11-21
| | | | | | | | | | | | | | | | | | | | | | | | | This brings us onto the stable API surface area for procedural macros that stabilized in Rust 1.30, rather than the string-based shim on older compilers. https://blog.rust-lang.org/2018/10/25/Rust-1.30.0.html Intervening release notes: - https://github.com/dtolnay/syn/releases/tag/0.13.0 - https://github.com/dtolnay/syn/releases/tag/0.14.0 - https://github.com/dtolnay/syn/releases/tag/0.15.0 TEST=cargo check crosvm TEST=cargo test each of the three proc-macro crates TEST=build_packages CQ-DEPEND=CL:1340766 Change-Id: Idcf14df0225ab41423b9a8639d0bba0a63513712 Reviewed-on: https://chromium-review.googlesource.com/1338507 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
* msg_socket: return io:Error from pair() instead of OptionZach Reizner2018-11-15
| | | | | | | | Change-Id: I8733794bca7a9510d5508941cbe3297a78e9923b Reviewed-on: https://chromium-review.googlesource.com/1314210 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* msg_socket: implement AsRawFd for UnixDatagram wrappersZach Reizner2018-11-15
| | | | | | | | Change-Id: I0589c6b88b4922db422771dc5930ca3f00b91736 Reviewed-on: https://chromium-review.googlesource.com/1314209 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jingkui Wang <jkwang@google.com>
* fix formatting in msg_on_socket_derive.rs unit testZach Reizner2018-11-09
| | | | | | | | | | | | | | | Turns out my cargo-fmt binary was being sourced from ~/.cargo/bin, which was very out of date. Hopefully less formatting issues come out of my chroot now. TEST=cargo fmt --all -- --check BUG=None Change-Id: I50592e2781835840dc5d589c681b3438d6de3370 Reviewed-on: https://chromium-review.googlesource.com/1324669 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* msg_socket_on_derive: use fully qualified typesZach Reizner2018-11-07
| | | | | | | | | | | | | | | | | | | | | | The types from msg_socket were assumed to be in scope for the custom derive implementation, which would cause mysterious compiler errors if the custom derive was invoked in a module without msg_socket types in scope. This CL uses fully qualified types in the generated output to avoid these errors. This change also uses `extern crate msg_socket` in case the call site doesn't have it in scope. BUG=None TEST=cargo test -p msg_on_socket_derive Change-Id: Ie6443cd4ffc070d27e71de123090a58f19846472 Reviewed-on: https://chromium-review.googlesource.com/1314208 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jingkui Wang <jkwang@google.com>
* msg_socket: avoid send_msg/recv_msg call if it's not necessaryJingkui Wang2018-11-02
| | | | | | | | | | | | | This patch avoids sendmsg/recvmsg if there is no fd. BUG=chromium:900962 TEST=build local image and test Change-Id: I3a5fd52232dc7d98dacd78aa0b383a436056ffb7 Reviewed-on: https://chromium-review.googlesource.com/1313656 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: add msg_sock.Jingkui Wang2018-10-09
MsgSock wraps UnixDatagram and provides simple macro to define Messages that could be send through sock easily. TEST=cargo test BUG=None Change-Id: I296fabc41893ad6a3ec42ef82dd29c3b752be8b8 Reviewed-on: https://chromium-review.googlesource.com/1255548 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>