[PATCH nixpkgs 4/4] crosvm: fix build

Alyssa Ross
2021-06-03T09:12:52Z

* Add new vhost source dependency
* Drop Cargo.lock patch
* Re-enable test on x86_64 (seems to work fine now)
* Drop syslog patch
* Rebase VIRTIO_NET_F_MAC patch -- I renamed TapFdOptions to
TapFdOption for consistency with newly-added similar structs.
---
.../crosvm/Regenerate-Cargo.lock.patch | 681 ------------------
.../chromium-os/crosvm/VIRTIO_NET_F_MAC.patch | 130 ++--
.../linux/chromium-os/crosvm/default.nix | 15 +-
pkgs/os-specific/linux/chromium-os/update.py | 1 +
.../linux/chromium-os/upstream-info.json | 6 +
5 files changed, 88 insertions(+), 745 deletions(-)
delete mode 100644 pkgs/os-specific/linux/chromium-os/crosvm/Regenerate-Cargo.lock.patch

diff --git a/pkgs/os-specific/linux/chromium-os/crosvm/Regenerate-Cargo.lock.patch b/pkgs/os-specific/linux/chromium-os/crosvm/Regenerate-Cargo.lock.patch
deleted file mode 100644
index 07dbd5469e7..00000000000
--- a/pkgs/os-specific/linux/chromium-os/crosvm/Regenerate-Cargo.lock.patch
+++ /dev/null
@@ -1,681 +0,0 @@
-From 972ee713ae8e48c3a99fbddca68018e20bb148c7 Mon Sep 17 00:00:00 2001
-From: Alyssa Ross <hi@alyssa.is>
-Date: Fri, 2 Apr 2021 16:38:28 +0000
-Subject: [PATCH crosvm] Regenerate Cargo.lock
-
----
- Cargo.lock | 327 +++++++++++++++++++++++++++++++++++++++--------------
- 1 file changed, 240 insertions(+), 87 deletions(-)
-
-diff --git a/Cargo.lock b/Cargo.lock
-index 3179b43f5..c82916b06 100644
---- a/Cargo.lock
-+++ b/Cargo.lock
-@@ -26,7 +26,7 @@ name = "acpi_tables"
- version = "0.1.0"
- dependencies = [
- "data_model",
-- "tempfile",
-+ "tempfile 3.0.7",
- ]
-
- [[package]]
-@@ -61,9 +61,9 @@ version = "0.1.0"
-
- [[package]]
- name = "async-trait"
--version = "0.1.36"
-+version = "0.1.48"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "a265e3abeffdce30b2e26b7a11b222fe37c6067404001b434101457d0385eb92"
-+checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf"
- dependencies = [
- "proc-macro2",
- "quote",
-@@ -113,9 +113,9 @@ dependencies = [
-
- [[package]]
- name = "bitflags"
--version = "1.1.0"
-+version = "1.2.1"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"
-+checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
-
- [[package]]
- name = "cc"
-@@ -129,6 +129,12 @@ version = "0.1.10"
- source = "registry+https://github.com/rust-lang/crates.io-index"
- checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
-
-+[[package]]
-+name = "cfg-if"
-+version = "1.0.0"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
-+
- [[package]]
- name = "cras-sys"
- version = "0.1.0"
-@@ -189,7 +195,7 @@ dependencies = [
- "resources",
- "rutabaga_gfx",
- "sync",
-- "tempfile",
-+ "tempfile 3.2.0",
- "thiserror",
- "vhost",
- "vm_control",
-@@ -262,7 +268,7 @@ dependencies = [
- "rutabaga_gfx",
- "sync",
- "syscall_defines",
-- "tempfile",
-+ "tempfile 3.0.7",
- "tpm2",
- "usb_util",
- "vfio_sys",
-@@ -285,7 +291,7 @@ dependencies = [
- "protobuf",
- "protos",
- "remain",
-- "tempfile",
-+ "tempfile 3.2.0",
- "vm_memory",
- ]
-
-@@ -295,6 +301,12 @@ version = "1.2.0"
- source = "registry+https://github.com/rust-lang/crates.io-index"
- checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
-
-+[[package]]
-+name = "either"
-+version = "1.6.1"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
-+
- [[package]]
- name = "enumn"
- version = "0.1.0"
-@@ -318,9 +330,9 @@ dependencies = [
-
- [[package]]
- name = "futures"
--version = "0.3.1"
-+version = "0.3.13"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987"
-+checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1"
- dependencies = [
- "futures-channel",
- "futures-core",
-@@ -333,9 +345,9 @@ dependencies = [
-
- [[package]]
- name = "futures-channel"
--version = "0.3.1"
-+version = "0.3.13"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86"
-+checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939"
- dependencies = [
- "futures-core",
- "futures-sink",
-@@ -343,15 +355,15 @@ dependencies = [
-
- [[package]]
- name = "futures-core"
--version = "0.3.1"
-+version = "0.3.13"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866"
-+checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94"
-
- [[package]]
- name = "futures-executor"
--version = "0.3.1"
-+version = "0.3.13"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231"
-+checksum = "891a4b7b96d84d5940084b2a37632dd65deeae662c114ceaa2c879629c9c0ad1"
- dependencies = [
- "futures-core",
- "futures-task",
-@@ -360,15 +372,15 @@ dependencies = [
-
- [[package]]
- name = "futures-io"
--version = "0.3.1"
-+version = "0.3.13"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff"
-+checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59"
-
- [[package]]
- name = "futures-macro"
--version = "0.3.1"
-+version = "0.3.13"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764"
-+checksum = "ea405816a5139fb39af82c2beb921d52143f556038378d6db21183a5c37fbfb7"
- dependencies = [
- "proc-macro-hack",
- "proc-macro2",
-@@ -378,21 +390,21 @@ dependencies = [
-
- [[package]]
- name = "futures-sink"
--version = "0.3.1"
-+version = "0.3.13"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16"
-+checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3"
-
- [[package]]
- name = "futures-task"
--version = "0.3.1"
-+version = "0.3.13"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9"
-+checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80"
-
- [[package]]
- name = "futures-util"
--version = "0.3.1"
-+version = "0.3.13"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76"
-+checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1"
- dependencies = [
- "futures-channel",
- "futures-core",
-@@ -401,6 +413,7 @@ dependencies = [
- "futures-sink",
- "futures-task",
- "memchr",
-+ "pin-project-lite",
- "pin-utils",
- "proc-macro-hack",
- "proc-macro-nested",
-@@ -409,11 +422,11 @@ dependencies = [
-
- [[package]]
- name = "gdbstub"
--version = "0.4.0"
-+version = "0.4.5"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "347c27d24b8ac4a2bcad3ff3d0695271a0510c020bd8134b53d189e973ed58bf"
-+checksum = "d79a8fc10e9c4a4009deacc1d1e632cc2860c63c5169abc737f838e07534ab1a"
- dependencies = [
-- "cfg-if",
-+ "cfg-if 0.1.10",
- "log",
- "managed",
- "num-traits",
-@@ -422,13 +435,24 @@ dependencies = [
-
- [[package]]
- name = "getopts"
--version = "0.2.18"
-+version = "0.2.21"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797"
-+checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
- dependencies = [
- "unicode-width",
- ]
-
-+[[package]]
-+name = "getrandom"
-+version = "0.2.2"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
-+dependencies = [
-+ "cfg-if 1.0.0",
-+ "libc",
-+ "wasi",
-+]
-+
- [[package]]
- name = "gpu_buffer"
- version = "0.1.0"
-@@ -448,6 +472,15 @@ dependencies = [
- "linux_input_sys",
- ]
-
-+[[package]]
-+name = "hermit-abi"
-+version = "0.1.18"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
-+dependencies = [
-+ "libc",
-+]
-+
- [[package]]
- name = "hypervisor"
- version = "0.1.0"
-@@ -496,7 +529,7 @@ version = "0.1.0"
- dependencies = [
- "base",
- "libc",
-- "tempfile",
-+ "tempfile 3.2.0",
- "vm_memory",
- ]
-
-@@ -524,9 +557,9 @@ dependencies = [
-
- [[package]]
- name = "libc"
--version = "0.2.65"
-+version = "0.2.92"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8"
-+checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714"
-
- [[package]]
- name = "libchromeos"
-@@ -538,6 +571,7 @@ dependencies = [
- "libc",
- "log",
- "protobuf",
-+ "thiserror",
- ]
-
- [[package]]
-@@ -580,11 +614,11 @@ dependencies = [
-
- [[package]]
- name = "log"
--version = "0.4.5"
-+version = "0.4.14"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f"
-+checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
- dependencies = [
-- "cfg-if",
-+ "cfg-if 1.0.0",
- ]
-
- [[package]]
-@@ -595,9 +629,9 @@ checksum = "0ca88d725a0a943b096803bd34e73a4437208b6077654cc4ecb2947a5f91618d"
-
- [[package]]
- name = "memchr"
--version = "2.3.0"
-+version = "2.3.4"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223"
-+checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
-
- [[package]]
- name = "memoffset"
-@@ -666,19 +700,20 @@ dependencies = [
-
- [[package]]
- name = "num-traits"
--version = "0.2.12"
-+version = "0.2.14"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
-+checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
- dependencies = [
- "autocfg",
- ]
-
- [[package]]
- name = "num_cpus"
--version = "1.9.0"
-+version = "1.13.0"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "5a69d464bdc213aaaff628444e99578ede64e9c854025aa43b9796530afa9238"
-+checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
- dependencies = [
-+ "hermit-abi",
- "libc",
- ]
-
-@@ -693,21 +728,27 @@ dependencies = [
-
- [[package]]
- name = "paste"
--version = "1.0.2"
-+version = "1.0.5"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "ba7ae1a2180ed02ddfdb5ab70c70d596a26dd642e097bb6fe78b1bde8588ed97"
-+checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58"
-+
-+[[package]]
-+name = "pin-project-lite"
-+version = "0.2.6"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
-
- [[package]]
- name = "pin-utils"
--version = "0.1.0-alpha.4"
-+version = "0.1.0"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587"
-+checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
-
- [[package]]
- name = "pkg-config"
--version = "0.3.11"
-+version = "0.3.19"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "110d5ee3593dbb73f56294327fe5668bcc997897097cbc76b51e7aed3f52452f"
-+checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
-
- [[package]]
- name = "poll_token_derive"
-@@ -729,65 +770,67 @@ dependencies = [
- ]
-
- [[package]]
--name = "proc-macro-hack"
--version = "0.5.11"
-+name = "ppv-lite86"
-+version = "0.2.10"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5"
--dependencies = [
-- "proc-macro2",
-- "quote",
-- "syn",
--]
-+checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
-+
-+[[package]]
-+name = "proc-macro-hack"
-+version = "0.5.19"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
-
- [[package]]
- name = "proc-macro-nested"
--version = "0.1.3"
-+version = "0.1.7"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e"
-+checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
-
- [[package]]
- name = "proc-macro2"
--version = "1.0.8"
-+version = "1.0.26"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548"
-+checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
- dependencies = [
- "unicode-xid",
- ]
-
- [[package]]
- name = "protobuf"
--version = "2.8.1"
-+version = "2.22.1"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "40361836defdd5871ff7e84096c6f6444af7fc157f8ef1789f54f147687caa20"
-+checksum = "1b7f4a129bb3754c25a4e04032a90173c68f85168f77118ac4cb4936e7f06f92"
-
- [[package]]
- name = "protobuf-codegen"
--version = "2.8.1"
-+version = "2.22.1"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "12c6abd78435445fc86898ebbd0521a68438063d4a73e23527b7134e6bf58b4a"
-+checksum = "e5d2fa3a461857508103b914da60dd7b489c1a834967c2e214ecc1496f0c486a"
- dependencies = [
- "protobuf",
- ]
-
- [[package]]
- name = "protoc"
--version = "2.8.1"
-+version = "2.22.1"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "3998c4bc0af8ccbd3cc68245ee9f72663c5ae2fb78bc48ff7719aef11562edea"
-+checksum = "e6653d384a260fedff0a466e894e05c5b8d75e261a14e9f93e81e43ef86cad23"
- dependencies = [
- "log",
-+ "which",
- ]
-
- [[package]]
- name = "protoc-rust"
--version = "2.8.1"
-+version = "2.22.1"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "234c97039c32bb58a883d0deafa57db37e59428ce536f3bdfe1c46cffec04113"
-+checksum = "e5198afa8fca3f419b36db9a70ede51ff845938ef0386b49f4b02a5a322015a6"
- dependencies = [
- "protobuf",
- "protobuf-codegen",
- "protoc",
-- "tempfile",
-+ "tempfile 3.2.0",
- ]
-
- [[package]]
-@@ -811,28 +854,86 @@ dependencies = [
-
- [[package]]
- name = "quote"
--version = "1.0.2"
-+version = "1.0.9"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
-+checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
- dependencies = [
- "proc-macro2",
- ]
-
-+[[package]]
-+name = "rand"
-+version = "0.8.3"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
-+dependencies = [
-+ "libc",
-+ "rand_chacha",
-+ "rand_core",
-+ "rand_hc",
-+]
-+
-+[[package]]
-+name = "rand_chacha"
-+version = "0.3.0"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
-+dependencies = [
-+ "ppv-lite86",
-+ "rand_core",
-+]
-+
-+[[package]]
-+name = "rand_core"
-+version = "0.6.2"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
-+dependencies = [
-+ "getrandom",
-+]
-+
-+[[package]]
-+name = "rand_hc"
-+version = "0.3.0"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
-+dependencies = [
-+ "rand_core",
-+]
-+
- [[package]]
- name = "rand_ish"
- version = "0.1.0"
-
- [[package]]
--name = "remain"
--version = "0.2.1"
-+name = "redox_syscall"
-+version = "0.2.5"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "99c861227fc40c8da6fdaa3d58144ac84c0537080a43eb1d7d45c28f88dcb888"
-+checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9"
-+dependencies = [
-+ "bitflags",
-+]
-+
-+[[package]]
-+name = "remain"
-+version = "0.2.2"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "70ba1e78fa68412cb93ef642fd4d20b9a941be49ee9333875ebaf13112673ea7"
- dependencies = [
- "proc-macro2",
- "quote",
- "syn",
- ]
-
-+[[package]]
-+name = "remove_dir_all"
-+version = "0.5.3"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
-+dependencies = [
-+ "winapi",
-+]
-+
- [[package]]
- name = "resources"
- version = "0.1.0"
-@@ -860,9 +961,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
-
- [[package]]
- name = "syn"
--version = "1.0.14"
-+version = "1.0.68"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5"
-+checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87"
- dependencies = [
- "proc-macro2",
- "quote",
-@@ -883,7 +984,7 @@ dependencies = [
- "poll_token_derive",
- "sync",
- "syscall_defines",
-- "tempfile",
-+ "tempfile 3.0.7",
- ]
-
- [[package]]
-@@ -898,19 +999,33 @@ dependencies = [
- ]
-
- [[package]]
--name = "thiserror"
--version = "1.0.20"
-+name = "tempfile"
-+version = "3.2.0"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08"
-+checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
-+dependencies = [
-+ "cfg-if 1.0.0",
-+ "libc",
-+ "rand",
-+ "redox_syscall",
-+ "remove_dir_all",
-+ "winapi",
-+]
-+
-+[[package]]
-+name = "thiserror"
-+version = "1.0.24"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e"
- dependencies = [
- "thiserror-impl",
- ]
-
- [[package]]
- name = "thiserror-impl"
--version = "1.0.20"
-+version = "1.0.24"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793"
-+checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
- dependencies = [
- "proc-macro2",
- "quote",
-@@ -934,15 +1049,15 @@ dependencies = [
-
- [[package]]
- name = "unicode-width"
--version = "0.1.5"
-+version = "0.1.8"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
-+checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
-
- [[package]]
- name = "unicode-xid"
--version = "0.2.0"
-+version = "0.2.1"
- source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
-+checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
-
- [[package]]
- name = "usb_sys"
-@@ -1015,6 +1130,44 @@ dependencies = [
- "syscall_defines",
- ]
-
-+[[package]]
-+name = "wasi"
-+version = "0.10.2+wasi-snapshot-preview1"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
-+
-+[[package]]
-+name = "which"
-+version = "4.1.0"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "b55551e42cbdf2ce2bedd2203d0cc08dba002c27510f86dab6d0ce304cba3dfe"
-+dependencies = [
-+ "either",
-+ "libc",
-+]
-+
-+[[package]]
-+name = "winapi"
-+version = "0.3.9"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
-+dependencies = [
-+ "winapi-i686-pc-windows-gnu",
-+ "winapi-x86_64-pc-windows-gnu",
-+]
-+
-+[[package]]
-+name = "winapi-i686-pc-windows-gnu"
-+version = "0.4.0"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
-+
-+[[package]]
-+name = "winapi-x86_64-pc-windows-gnu"
-+version = "0.4.0"
-+source = "registry+https://github.com/rust-lang/crates.io-index"
-+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-+
- [[package]]
- name = "wire_format_derive"
- version = "0.1.0"
---
-2.30.0
-
diff --git a/pkgs/os-specific/linux/chromium-os/crosvm/VIRTIO_NET_F_MAC.patch b/pkgs/os-specific/linux/chromium-os/crosvm/VIRTIO_NET_F_MAC.patch
index 7f79cb90c18..80cab56b1f8 100644
--- a/pkgs/os-specific/linux/chromium-os/crosvm/VIRTIO_NET_F_MAC.patch
+++ b/pkgs/os-specific/linux/chromium-os/crosvm/VIRTIO_NET_F_MAC.patch
@@ -1,7 +1,7 @@
-From 655988f0b66ccf22ce197024d6eb2682f3bbada8 Mon Sep 17 00:00:00 2001
+From 2b5a83bd9e2c1c9642773c1daf785d03f95f33a3 Mon Sep 17 00:00:00 2001
From: Alyssa Ross <hi@alyssa.is>
Date: Sun, 27 Sep 2020 15:34:02 +0000
-Subject: [PATCH crosvm v2] crosvm: support setting guest MAC from tap-fd
+Subject: [PATCH crosvm v3] crosvm: support setting guest MAC from tap-fd

This adds a mac= option to crosvm's --tap-fd option. The virtio-net
driver in the guest will read the desired MAC from virtio
@@ -15,14 +15,14 @@ Thanks-to: Puck Meerburg <puck@puckipedia.com>
Reviewed-by: Cole Helbling <cole.e.helbling@outlook.com>
Message-Id: <20210517185700.3591932-1-hi@alyssa.is>
---
- devices/src/virtio/net.rs | 12 ++++++--
+ devices/src/virtio/net.rs | 20 ++++++++++--
src/crosvm.rs | 8 +++--
- src/linux.rs | 12 ++++----
- src/main.rs | 63 ++++++++++++++++++++++++++++++---------
- 4 files changed, 71 insertions(+), 24 deletions(-)
+ src/linux.rs | 19 +++++++-----
+ src/main.rs | 64 +++++++++++++++++++++++++++++++--------
+ 4 files changed, 88 insertions(+), 23 deletions(-)

diff --git a/devices/src/virtio/net.rs b/devices/src/virtio/net.rs
-index 92368c440..4d0ea1560 100644
+index b88dc44ae..b7489eb2b 100644
--- a/devices/src/virtio/net.rs
+++ b/devices/src/virtio/net.rs
@@ -419,6 +419,7 @@ where
@@ -40,8 +40,8 @@ index 92368c440..4d0ea1560 100644
+ guest_mac_addr: Option<MacAddress>,
vq_pairs: u16,
) -> Result<Net<T>, NetError> {
- let multi_queue = if vq_pairs > 1 { true } else { false };
-@@ -450,12 +452,12 @@ where
+ let multi_queue = vq_pairs > 1;
+@@ -450,12 +452,17 @@ where

tap.enable().map_err(NetError::TapEnable)?;

@@ -52,11 +52,16 @@ index 92368c440..4d0ea1560 100644
/// Creates a new virtio network device from a tap device that has already been
/// configured.
- pub fn from(base_features: u64, tap: T, vq_pairs: u16) -> Result<Net<T>, NetError> {
-+ pub fn with_tap(base_features: u64, tap: T, vq_pairs: u16, mac_address: Option<MacAddress>) -> Result<Net<T>, NetError> {
++ pub fn with_tap(
++ base_features: u64,
++ tap: T,
++ vq_pairs: u16,
++ mac_address: Option<MacAddress>,
++ ) -> Result<Net<T>, NetError> {
let taps = tap.into_mq_taps(vq_pairs).map_err(NetError::TapOpen)?;

// This would also validate a tap created by Self::new(), but that's a good thing as it
-@@ -488,7 +490,12 @@ where
+@@ -488,7 +495,12 @@ where
workers_kill_evt.push(worker_kill_evt);
}

@@ -69,39 +74,42 @@ index 92368c440..4d0ea1560 100644
queue_sizes: vec![QUEUE_SIZE; (vq_pairs * 2 + 1) as usize].into_boxed_slice(),
workers_kill_evt,
kill_evts,
-@@ -503,6 +510,7 @@ where
+@@ -503,6 +515,10 @@ where
let vq_pairs = self.queue_sizes.len() as u16 / 2;

VirtioNetConfig {
-+ mac: self.mac_address.map(|m| m.octets()).unwrap_or_else(Default::default),
++ mac: self
++ .mac_address
++ .map(|m| m.octets())
++ .unwrap_or_else(Default::default),
max_vq_pairs: Le16::from(vq_pairs),
// Other field has meaningful value when the corresponding feature
// is enabled, but all these features aren't supported now.
diff --git a/src/crosvm.rs b/src/crosvm.rs
-index 04e267d6c..1dde7d769 100644
+index eededc02e..62b3019db 100644
--- a/src/crosvm.rs
+++ b/src/crosvm.rs
-@@ -171,6 +171,10 @@ impl Default for SharedDir {
+@@ -191,6 +191,10 @@ impl Default for SharedDir {
}
}

-+pub struct TapFdOptions {
++pub struct TapFdOption {
+ pub mac: Option<net_util::MacAddress>,
+}
+
/// Aggregate of all configurable options for a running VM.
pub struct Config {
- pub vcpu_count: Option<usize>,
-@@ -194,7 +198,7 @@ pub struct Config {
+ pub kvm_device_path: PathBuf,
+@@ -217,7 +221,7 @@ pub struct Config {
pub mac_address: Option<net_util::MacAddress>,
pub net_vq_pairs: Option<u16>,
pub vhost_net: bool,
- pub tap_fd: Vec<RawFd>,
-+ pub tap_fd: BTreeMap<RawFd, TapFdOptions>,
++ pub tap_fd: BTreeMap<RawFd, TapFdOption>,
pub cid: Option<u64>,
pub wayland_socket_paths: BTreeMap<String, PathBuf>,
pub wayland_dmabuf: bool,
-@@ -253,7 +257,7 @@ impl Default for Config {
+@@ -291,7 +295,7 @@ impl Default for Config {
mac_address: None,
net_vq_pairs: None,
vhost_net: false,
@@ -111,37 +119,44 @@ index 04e267d6c..1dde7d769 100644
#[cfg(feature = "gpu")]
gpu_parameters: None,
diff --git a/src/linux.rs b/src/linux.rs
-index f452fef3f..42c07df4f 100644
+index ba2d28f96..e9601478a 100644
--- a/src/linux.rs
+++ b/src/linux.rs
-@@ -75,7 +75,7 @@ use vm_memory::{GuestAddress, GuestMemory};
-
+@@ -60,8 +60,8 @@ use vm_memory::{GuestAddress, GuestMemory};
#[cfg(all(target_arch = "x86_64", feature = "gdb"))]
use crate::gdb::{gdb_thread, GdbStub};
--use crate::{Config, DiskOption, Executable, SharedDir, SharedDirKind, TouchDeviceOption};
-+use crate::{Config, DiskOption, Executable, SharedDir, SharedDirKind, TapFdOptions, TouchDeviceOption};
+ use crate::{
+- Config, DiskOption, Executable, SharedDir, SharedDirKind, TouchDeviceOption, VhostUserFsOption,
+- VhostUserOption,
++ Config, DiskOption, Executable, SharedDir, SharedDirKind, TapFdOption, TouchDeviceOption,
++ VhostUserFsOption, VhostUserOption,
+ };
use arch::{
self, LinuxArch, RunnableLinuxVm, SerialHardware, SerialParameters, VcpuAffinity,
- VirtioDeviceStub, VmComponents, VmImage,
-@@ -675,7 +675,7 @@ fn create_balloon_device(cfg: &Config, socket: BalloonControlResponseSocket) ->
+@@ -763,7 +763,11 @@ fn create_balloon_device(cfg: &Config, tube: Tube) -> DeviceResult {
})
}

-fn create_tap_net_device(cfg: &Config, tap_fd: RawDescriptor) -> DeviceResult {
-+fn create_tap_net_device(cfg: &Config, tap_fd: RawDescriptor, options: &TapFdOptions) -> DeviceResult {
++fn create_tap_net_device(
++ cfg: &Config,
++ tap_fd: RawDescriptor,
++ options: &TapFdOption,
++) -> DeviceResult {
// Safe because we ensure that we get a unique handle to the fd.
let tap = unsafe {
Tap::from_raw_descriptor(
-@@ -691,7 +691,7 @@ fn create_tap_net_device(cfg: &Config, tap_fd: RawDescriptor) -> DeviceResult {
+@@ -779,7 +783,8 @@ fn create_tap_net_device(cfg: &Config, tap_fd: RawDescriptor) -> DeviceResult {
vq_pairs = 1;
}
let features = virtio::base_features(cfg.protected_vm);
- let dev = virtio::Net::from(features, tap, vq_pairs).map_err(Error::NetDeviceNew)?;
-+ let dev = virtio::Net::with_tap(features, tap, vq_pairs, options.mac).map_err(Error::NetDeviceNew)?;
++ let dev =
++ virtio::Net::with_tap(features, tap, vq_pairs, options.mac).map_err(Error::NetDeviceNew)?;

Ok(VirtioDeviceStub {
dev: Box::new(dev),
-@@ -725,7 +725,7 @@ fn create_net_device(
+@@ -814,7 +819,7 @@ fn create_net_device(
.map_err(Error::VhostNetDeviceNew)?;
Box::new(dev) as Box<dyn VirtioDevice>
} else {
@@ -150,8 +165,8 @@ index f452fef3f..42c07df4f 100644
.map_err(Error::NetDeviceNew)?;
Box::new(dev) as Box<dyn VirtioDevice>
};
-@@ -1311,8 +1311,8 @@ fn create_virtio_devices(
- devs.push(create_balloon_device(cfg, balloon_device_socket)?);
+@@ -1445,8 +1450,8 @@ fn create_virtio_devices(
+ devs.push(create_balloon_device(cfg, balloon_device_tube)?);

// We checked above that if the IP is defined, then the netmask is, too.
- for tap_fd in &cfg.tap_fd {
@@ -162,19 +177,29 @@ index f452fef3f..42c07df4f 100644

if let (Some(host_ip), Some(netmask), Some(mac_address)) =
diff --git a/src/main.rs b/src/main.rs
-index 5d02af02f..f8bc0d14e 100644
+index ab62f2543..e1188a86c 100644
--- a/src/main.rs
+++ b/src/main.rs
-@@ -28,7 +28,7 @@ use base::{
+@@ -20,13 +20,15 @@ use arch::{
+ set_default_serial_parameters, Pstore, SerialHardware, SerialParameters, SerialType,
+ VcpuAffinity,
};
+-use base::{debug, error, getpid, info, kill_process_group, reap_child, syslog, warn};
++use base::{
++ debug, error, getpid, info, kill_process_group, reap_child, syslog, warn, RawDescriptor,
++};
+ #[cfg(feature = "direct")]
+ use crosvm::DirectIoOption;
use crosvm::{
argument::{self, print_help, set_arguments, Argument},
- platform, BindMount, Config, DiskOption, Executable, GidMap, SharedDir, TouchDeviceOption,
-+ platform, BindMount, Config, DiskOption, Executable, GidMap, SharedDir, TapFdOptions, TouchDeviceOption,
- DISK_ID_LEN,
+- VhostUserFsOption, VhostUserOption, DISK_ID_LEN,
++ platform, BindMount, Config, DiskOption, Executable, GidMap, SharedDir, TapFdOption,
++ TouchDeviceOption, VhostUserFsOption, VhostUserOption, DISK_ID_LEN,
};
#[cfg(feature = "gpu")]
-@@ -1319,17 +1319,52 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
+ use devices::virtio::gpu::{GpuMode, GpuParameters};
+@@ -1460,17 +1462,55 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
}
"vhost-net" => cfg.vhost_net = true,
"tap-fd" => {
@@ -183,21 +208,20 @@ index 5d02af02f..f8bc0d14e 100644
- .unwrap()
- .parse()
- .map_err(|_| argument::Error::InvalidValue {
-- value: value.unwrap().to_owned(),
-- expected: String::from(
-- "this value for `tap-fd` must be an unsigned integer",
-- ),
-- })?,
-- );
+ let mut components = value.unwrap().split(',');
+
-+ let fd: RawDescriptor = components
-+ .next()
-+ .and_then(|x| x.parse().ok())
-+ .ok_or_else(|| argument::Error::InvalidValue {
-+ value: value.unwrap().to_owned(),
-+ expected: String::from("this value for `tap-fd` must be an unsigned integer"),
-+ })?;
++ let fd: RawDescriptor =
++ components
++ .next()
++ .and_then(|x| x.parse().ok())
++ .ok_or_else(|| argument::Error::InvalidValue {
+ value: value.unwrap().to_owned(),
+ expected: String::from(
+ "this value for `tap-fd` must be an unsigned integer",
+ ),
+- })?,
+- );
++ })?;
+
+ let mut mac = None;
+ for c in components {
@@ -234,11 +258,11 @@ index 5d02af02f..f8bc0d14e 100644
+ name
+ )));
+ }
-+ cfg.tap_fd.insert(fd, TapFdOptions { mac });
++ cfg.tap_fd.insert(fd, TapFdOption { mac });
}
#[cfg(feature = "gpu")]
"gpu" => {
-@@ -1644,8 +1679,8 @@ writeback=BOOL - Indicates whether the VM can use writeback caching (default: fa
+@@ -1907,8 +1947,8 @@ writeback=BOOL - Indicates whether the VM can use writeback caching (default: fa
Argument::value("plugin-gid-map-file", "PATH", "Path to the file listing supplemental GIDs that should be mapped in plugin jail. Can be given more than once."),
Argument::flag("vhost-net", "Use vhost for networking."),
Argument::value("tap-fd",
diff --git a/pkgs/os-specific/linux/chromium-os/crosvm/default.nix b/pkgs/os-specific/linux/chromium-os/crosvm/default.nix
index 681526356ea..f8b6b13e694 100644
--- a/pkgs/os-specific/linux/chromium-os/crosvm/default.nix
+++ b/pkgs/os-specific/linux/chromium-os/crosvm/default.nix
@@ -11,10 +11,11 @@ let

getSrc = path: fetchFromGitiles upstreamInfo.components.${path};
srcs = lib.genAttrs [
- "src/platform/crosvm"
- "src/third_party/adhd"
"src/aosp/external/minijail"
+ "src/platform/crosvm"
"src/platform2"
+ "src/third_party/adhd"
+ "src/third_party/rust-vmm/vhost"
] getSrc;
in

@@ -39,14 +40,12 @@ in

sourceRoot = "src/platform/crosvm";

- cargoPatches = [ ./Regenerate-Cargo.lock.patch ];
-
patches = [
./default-seccomp-policy-dir.diff
./VIRTIO_NET_F_MAC.patch
];

- cargoSha256 = "0rrhgchrf6ac5393rxlkff0kd3xs7xixxshcdpag3lxjgg0j62af";
+ cargoSha256 = "1hw9r7vggvn8p0sy4k0i2ijpyk0yb11qww6s6d6wdfvrl1ksbapl";

nativeBuildInputs = [ pkgconfig wayland ];

@@ -55,9 +54,6 @@ in
postPatch = ''
sed -i "s|/usr/share/policy/crosvm/|$out/share/policy/|g" \
seccomp/*/*.policy
-
- # No /dev/log in the sandbox.
- sed -i '/^[[:space:]]*syslog::init().unwrap();$/d' tests/boot.rs
'';

preBuild = ''
@@ -69,9 +65,6 @@ in
cp seccomp/${arch}/* $out/share/policy/
'';

- # Boot test often hangs on AMD.
- doCheck = !stdenv.buildPlatform.isx86_64;
-
CROSVM_CARGO_TEST_KERNEL_BINARY =
lib.optionalString (stdenv.buildPlatform == stdenv.hostPlatform)
"${linux}/${stdenv.hostPlatform.platform.kernelTarget}";
diff --git a/pkgs/os-specific/linux/chromium-os/update.py b/pkgs/os-specific/linux/chromium-os/update.py
index a2e093c2e9e..5852d4a3069 100755
--- a/pkgs/os-specific/linux/chromium-os/update.py
+++ b/pkgs/os-specific/linux/chromium-os/update.py
@@ -24,6 +24,7 @@ component_paths = [
'src/third_party/libqmi',
'src/third_party/modemmanager-next',
'src/third_party/modp_b64',
+ 'src/third_party/rust-vmm/vhost',
]

git_root = 'https://chromium.googlesource.com/'
diff --git a/pkgs/os-specific/linux/chromium-os/upstream-info.json b/pkgs/os-specific/linux/chromium-os/upstream-info.json
index 4a4101b37d7..f23948d9cb4 100644
--- a/pkgs/os-specific/linux/chromium-os/upstream-info.json
+++ b/pkgs/os-specific/linux/chromium-os/upstream-info.json
@@ -61,6 +61,12 @@
"url": "https://chromium.googlesource.com/aosp/platform/external/modp_b64",
"rev": "269b6fb8401617b85e2dff7ae8a7b0f97613e2cd",
"sha256": "1mc5w70svgj7rq49r6lxkw9ix6q09dxrw0lamx3hn8anq5q8y532"
+ },
+ "src/third_party/rust-vmm/vhost": {
+ "name": "vhost",
+ "url": "https://chromium.googlesource.com/chromiumos/third_party/rust-vmm/vhost",
+ "rev": "98298cb96972c20e05bffed58861456b48328d43",
+ "sha256": "0ym5cmnaifn3ywcidvqmbswmsxqi0zw6gx88gfqfq0p5jis8vjhi"
}
}
}
--
2.31.1