diff --git a/Cargo.lock b/Cargo.lock index 332c3457d..c06ed4052 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,9 +18,9 @@ dependencies = [ [[package]] name = "adler" -version = "0.2.3" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +checksum = "bedc89c5c7b5550ffb9372eb5c5ffc7f9f705cc3f4a128bd4669b9745f555093" [[package]] name = "aho-corasick" @@ -172,9 +172,9 @@ dependencies = [ [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "cc" @@ -265,14 +265,13 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae8f328835f8f5a6ceb6a7842a7f2d0c03692adb5c889347235d59194731fe3" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" dependencies = [ "autocfg", "cfg-if 1.0.0", "lazy_static", - "loom", ] [[package]] @@ -380,19 +379,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "generator" -version = "0.6.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9fed24fd1e18827652b4d55652899a1e9da8e54d91624dc3437a5bc3a9f9a9c" -dependencies = [ - "cc", - "libc", - "log 0.4.14", - "rustversion", - "winapi 0.3.9", -] - [[package]] name = "getrandom" version = "0.1.16" @@ -512,8 +498,8 @@ dependencies = [ [[package]] name = "kvm-bindings" -version = "0.2.0" -source = "git+https://github.com/cloud-hypervisor/kvm-bindings?branch=ch#2164129ff03bb4d7a4243de5e2078845064d922c" +version = "0.3.0" +source = "git+https://github.com/cloud-hypervisor/kvm-bindings?branch=ch-v0.3.0#e9340b35fbd81b98c007c3272727734657e12ea5" dependencies = [ "serde", "serde_derive", @@ -522,8 +508,9 @@ dependencies = [ [[package]] name = "kvm-ioctls" -version = "0.6.0" -source = "git+https://github.com/cloud-hypervisor/kvm-ioctls?branch=ch#b7f21758bf8e46ac55a28a1b2ed008b5732bbb44" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c23a352d6371d3d651e2103abd6479b245cb0f19e9cc94ea55e9b53da9b5069" dependencies = [ "kvm-bindings", "libc", @@ -570,8 +557,9 @@ dependencies = [ [[package]] name = "linux-loader" -version = "0.2.0" -source = "git+https://github.com/rust-vmm/linux-loader#4ab9dade2cbe6cf2c8707d386aa3fa4e3528511e" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c819cc8275b0f2c1ed9feec455ca288b45d82932384a6a5f7a86812ee3427459" dependencies = [ "vm-memory", ] @@ -603,17 +591,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "loom" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d44c73b4636e497b4917eb21c33539efa3816741a2d3ff26c6316f1b529481a4" -dependencies = [ - "cfg-if 1.0.0", - "generator", - "scoped-tls", -] - [[package]] name = "matches" version = "0.1.8" @@ -636,9 +613,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", "autocfg", @@ -647,7 +624,7 @@ dependencies = [ [[package]] name = "mshv-bindings" version = "0.1.0" -source = "git+https://github.com/cloud-hypervisor/mshv?branch=master#3a7d7ba07e12409a3b23794c72c30b5052d221d9" +source = "git+https://github.com/cloud-hypervisor/mshv?branch=master#547b86e74096a51ca7b9ec6737f5ec1baf5bbdea" dependencies = [ "libc", "serde", @@ -659,7 +636,7 @@ dependencies = [ [[package]] name = "mshv-ioctls" version = "0.1.0" -source = "git+https://github.com/cloud-hypervisor/mshv?branch=master#3a7d7ba07e12409a3b23794c72c30b5052d221d9" +source = "git+https://github.com/cloud-hypervisor/mshv?branch=master#547b86e74096a51ca7b9ec6737f5ec1baf5bbdea" dependencies = [ "libc", "mshv-bindings", @@ -973,24 +950,12 @@ dependencies = [ "semver", ] -[[package]] -name = "rustversion" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd" - [[package]] name = "ryu" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" - [[package]] name = "scopeguard" version = "1.1.0" @@ -1324,7 +1289,7 @@ dependencies = [ [[package]] name = "vfio-ioctls" version = "0.1.0" -source = "git+https://github.com/rust-vmm/vfio-ioctls?branch=master#95e70655e34ad942f5ca8d3bc450d7dec4964514" +source = "git+https://github.com/rust-vmm/vfio-ioctls?branch=master#0903c222fa027ce2783e3d7a6d4676574d0e5200" dependencies = [ "byteorder", "kvm-bindings", @@ -1532,9 +1497,9 @@ dependencies = [ [[package]] name = "vmm-sys-util" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cdd1d72e262bbfb014de65ada24c1ac50e10a2e3b1e8ec052df188c2ee5dfa" +checksum = "01cf11afbc4ebc0d5c7a7748a77d19e2042677fc15faa2f4ccccb27c18a60605" dependencies = [ "bitflags 1.2.1", "libc", diff --git a/Cargo.toml b/Cargo.toml index 084bfffc6..1d0bd4b30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,10 +13,10 @@ homepage = "https://github.com/cloud-hypervisor/cloud-hypervisor" lto = true [dependencies] -anyhow = "1.0" +anyhow = "1.0.38" api_client = { path = "api_client" } clap = { version = "2.33.3", features = ["wrap_help"] } -epoll = ">=4.0.1" +epoll = "4.3.1" event_monitor = { path = "event_monitor" } hypervisor = { path = "hypervisor" } libc = "0.2.86" @@ -25,9 +25,9 @@ option_parser = { path = "option_parser" } seccomp = { git = "https://github.com/firecracker-microvm/firecracker", tag = "v0.22.0" } serde_json = "1.0.62" signal-hook = "0.3.6" -thiserror = "1.0" +thiserror = "1.0.24" vmm = { path = "vmm" } -vmm-sys-util = "0.7.0" +vmm-sys-util = "0.8.0" vm-memory = "0.5.0" [build-dependencies] @@ -35,8 +35,7 @@ clap = { version = "2.33.3", features = ["wrap_help"] } # List of patched crates [patch.crates-io] -kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch", features = ["with-serde", "fam-wrappers"] } -kvm-ioctls = { git = "https://github.com/cloud-hypervisor/kvm-ioctls", branch = "ch" } +kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch-v0.3.0", features = ["with-serde", "fam-wrappers"] } [dev-dependencies] credibility = "0.1.3" diff --git a/arch/Cargo.toml b/arch/Cargo.toml index b0d571f9c..cd382e677 100644 --- a/arch/Cargo.toml +++ b/arch/Cargo.toml @@ -14,6 +14,7 @@ arch_gen = { path = "../arch_gen" } byteorder = "1.3.4" hypervisor = { path = "../hypervisor" } libc = "0.2.86" +linux-loader = { version = "0.3.0", features = ["elf", "bzimage", "pe"] } log = "0.4.14" serde = {version = ">=1.0.27", features = ["rc"] } serde_derive = ">=1.0.27" @@ -22,7 +23,3 @@ thiserror = "1.0" vm-memory = { version = "0.5.0", features = ["backend-mmap"] } vm-migration = { path = "../vm-migration" } -[dependencies.linux-loader] -git = "https://github.com/rust-vmm/linux-loader" -features = ["elf", "bzimage"] - diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock new file mode 100644 index 000000000..0c18f8bec --- /dev/null +++ b/fuzz/Cargo.lock @@ -0,0 +1,869 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "acpi_tables" +version = "0.1.0" +dependencies = [ + "vm-memory", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" + +[[package]] +name = "api_client" +version = "0.1.0" + +[[package]] +name = "arbitrary" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db55d72333851e17d572bec876e390cd3b11eb1ef53ae821dd9f3b653d2b4569" + +[[package]] +name = "arc-swap" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d7d63395147b81a9e570bcc6243aaf71c017bd666d4909cfef0085bdda8d73" + +[[package]] +name = "arch" +version = "0.1.0" +dependencies = [ + "acpi_tables", + "anyhow", + "arch_gen", + "byteorder", + "hypervisor", + "libc", + "linux-loader", + "log", + "serde", + "serde_derive", + "serde_json", + "thiserror", + "vm-memory", + "vm-migration", +] + +[[package]] +name = "arch_gen" +version = "0.1.0" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "block_util" +version = "0.1.0" +dependencies = [ + "io-uring", + "libc", + "log", + "qcow", + "serde", + "serde_derive", + "serde_json", + "thiserror", + "virtio-bindings", + "vm-memory", + "vm-virtio", + "vmm-sys-util", +] + +[[package]] +name = "byteorder" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" + +[[package]] +name = "cc" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "term_size", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "cloud-hypervisor" +version = "0.13.0" +dependencies = [ + "anyhow", + "api_client", + "clap", + "epoll", + "event_monitor", + "hypervisor", + "libc", + "log", + "option_parser", + "seccomp", + "serde_json", + "signal-hook", + "thiserror", + "vm-memory", + "vmm", + "vmm-sys-util", +] + +[[package]] +name = "cloud-hypervisor-fuzz" +version = "0.0.0" +dependencies = [ + "block_util", + "cloud-hypervisor", + "libc", + "libfuzzer-sys", + "qcow", + "seccomp", + "virtio-devices", + "vm-memory", + "vm-virtio", + "vmm-sys-util", +] + +[[package]] +name = "devices" +version = "0.1.0" +dependencies = [ + "acpi_tables", + "anyhow", + "bitflags", + "byteorder", + "epoll", + "libc", + "log", + "serde", + "serde_derive", + "serde_json", + "vm-device", + "vm-memory", + "vm-migration", + "vmm-sys-util", +] + +[[package]] +name = "epoll" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20df693c700404f7e19d4d6fae6b15215d2913c27955d2b9d6f2c0f537511cd0" +dependencies = [ + "bitflags", + "libc", +] + +[[package]] +name = "event_monitor" +version = "0.1.0" +dependencies = [ + "libc", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[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" +dependencies = [ + "anyhow", + "epoll", + "iced-x86", + "kvm-bindings", + "kvm-ioctls", + "libc", + "log", + "serde", + "serde_derive", + "serde_json", + "thiserror", + "vm-memory", + "vmm-sys-util", +] + +[[package]] +name = "iced-x86" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "644fd8d7e49d1ccae568a8fbb873a7ee7fcb3bc9214a474a5e55c03b6d1fa5ac" +dependencies = [ + "lazy_static", + "rustc_version", + "static_assertions", +] + +[[package]] +name = "idna" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89829a5d69c23d348314a7ac337fe39173b61149a9864deabd260983aed48c21" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "io-uring" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f7589adca0ddd74f56ed83a5098b45e3abf264dc27e150a8bec3397fcc34338" +dependencies = [ + "bitflags", + "libc", +] + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[package]] +name = "kvm-bindings" +version = "0.3.0" +source = "git+https://github.com/cloud-hypervisor/kvm-bindings?branch=ch-v0.3.0#e9340b35fbd81b98c007c3272727734657e12ea5" +dependencies = [ + "serde", + "serde_derive", + "vmm-sys-util", +] + +[[package]] +name = "kvm-ioctls" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c23a352d6371d3d651e2103abd6479b245cb0f19e9cc94ea55e9b53da9b5069" +dependencies = [ + "kvm-bindings", + "libc", + "vmm-sys-util", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" + +[[package]] +name = "libfuzzer-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcf184a4b6b274f82a5df6b357da6055d3e82272327bba281c28bbba6f1664ef" +dependencies = [ + "arbitrary", + "cc", +] + +[[package]] +name = "linux-loader" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c819cc8275b0f2c1ed9feec455ca288b45d82932384a6a5f7a86812ee3427459" +dependencies = [ + "vm-memory", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "micro_http" +version = "0.1.0" +source = "git+https://github.com/firecracker-microvm/micro-http?branch=master#59ab64440a95f7b16253fef67b5201c2ec4adaf7" +dependencies = [ + "epoll", +] + +[[package]] +name = "net_gen" +version = "0.1.0" +dependencies = [ + "vmm-sys-util", +] + +[[package]] +name = "net_util" +version = "0.1.0" +dependencies = [ + "epoll", + "libc", + "log", + "net_gen", + "serde", + "virtio-bindings", + "vm-memory", + "vm-virtio", + "vmm-sys-util", +] + +[[package]] +name = "option_parser" +version = "0.1.0" + +[[package]] +name = "pci" +version = "0.1.0" +dependencies = [ + "anyhow", + "byteorder", + "hypervisor", + "libc", + "log", + "serde", + "serde_derive", + "serde_json", + "vfio-bindings", + "vfio-ioctls", + "vm-allocator", + "vm-device", + "vm-memory", + "vm-migration", + "vmm-sys-util", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "qcow" +version = "0.1.0" +dependencies = [ + "byteorder", + "libc", + "log", + "remain", + "vmm-sys-util", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[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 = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "seccomp" +version = "0.1.0" +source = "git+https://github.com/firecracker-microvm/firecracker?tag=v0.22.0#cc5387637c132e500b4857b80b5a239d8d732b77" +dependencies = [ + "libc", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.123" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" + +[[package]] +name = "serde_derive" +version = "1.0.123" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43535db9747a4ba938c0ce0a98cc631a46ebf943c9e1d604e091df6007620bf6" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "signal-hook" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7f3f92a1da3d6b1d32245d0cbcbbab0cfc45996d8df619c42bccfa6d2bbb5f" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-registry" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +dependencies = [ + "libc", +] + +[[package]] +name = "static_assertions" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "syn" +version = "1.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "term_size" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "term_size", + "unicode-width", +] + +[[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.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "url" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "vfio-bindings" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a21f546f2bda37f5a8cfb138c87f95b8e34d2d78d6a7a92ba3785f4e08604a7" +dependencies = [ + "vmm-sys-util", +] + +[[package]] +name = "vfio-ioctls" +version = "0.1.0" +source = "git+https://github.com/rust-vmm/vfio-ioctls?branch=master#0903c222fa027ce2783e3d7a6d4676574d0e5200" +dependencies = [ + "byteorder", + "kvm-bindings", + "kvm-ioctls", + "log", + "vfio-bindings", + "vm-memory", + "vmm-sys-util", +] + +[[package]] +name = "vhost" +version = "0.1.0" +source = "git+https://github.com/rust-vmm/vhost?branch=master#8c6919bf60bd641398ddd53864fbc74d75548837" +dependencies = [ + "bitflags", + "libc", + "vmm-sys-util", +] + +[[package]] +name = "virtio-bindings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff512178285488516ed85f15b5d0113a7cdb89e9e8a760b269ae4f02b84bd6b" + +[[package]] +name = "virtio-devices" +version = "0.1.0" +dependencies = [ + "anyhow", + "arc-swap", + "block_util", + "byteorder", + "epoll", + "event_monitor", + "io-uring", + "libc", + "log", + "net_gen", + "net_util", + "pci", + "seccomp", + "serde", + "serde_derive", + "serde_json", + "vhost", + "virtio-bindings", + "vm-allocator", + "vm-device", + "vm-memory", + "vm-migration", + "vm-virtio", + "vmm-sys-util", +] + +[[package]] +name = "vm-allocator" +version = "0.1.0" +dependencies = [ + "arch", + "libc", + "vm-memory", +] + +[[package]] +name = "vm-device" +version = "0.1.0" +dependencies = [ + "anyhow", + "serde", + "serde_derive", + "serde_json", + "thiserror", + "vfio-ioctls", + "vm-memory", + "vmm-sys-util", +] + +[[package]] +name = "vm-memory" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625f401b1b8b3ac3d43f53903cd138cfe840bd985f8581e553027b31d2bb8ae8" +dependencies = [ + "arc-swap", + "libc", + "winapi", +] + +[[package]] +name = "vm-migration" +version = "0.1.0" +dependencies = [ + "anyhow", + "serde", + "serde_derive", + "serde_json", + "thiserror", + "vm-memory", +] + +[[package]] +name = "vm-virtio" +version = "0.1.0" +dependencies = [ + "log", + "serde", + "serde_derive", + "serde_json", + "virtio-bindings", + "vm-memory", +] + +[[package]] +name = "vmm" +version = "0.1.0" +dependencies = [ + "acpi_tables", + "anyhow", + "arc-swap", + "arch", + "bitflags", + "block_util", + "clap", + "devices", + "epoll", + "event_monitor", + "hypervisor", + "lazy_static", + "libc", + "linux-loader", + "log", + "micro_http", + "net_util", + "option_parser", + "pci", + "qcow", + "seccomp", + "serde", + "serde_derive", + "serde_json", + "signal-hook", + "thiserror", + "url", + "vfio-ioctls", + "virtio-devices", + "vm-allocator", + "vm-device", + "vm-memory", + "vm-migration", + "vm-virtio", + "vmm-sys-util", +] + +[[package]] +name = "vmm-sys-util" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cf11afbc4ebc0d5c7a7748a77d19e2042677fc15faa2f4ccccb27c18a60605" +dependencies = [ + "bitflags", + "libc", + "serde", + "serde_derive", +] + +[[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" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index a8ab1b39c..252f84bf9 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -15,10 +15,13 @@ libfuzzer-sys = "0.3" qcow = { path = "../qcow" } seccomp = { git = "https://github.com/firecracker-microvm/firecracker", tag = "v0.22.0" } virtio-devices = { path = "../virtio-devices" } -vmm-sys-util = ">=0.3.1" +vmm-sys-util = "0.8.0" vm-virtio = { path = "../vm-virtio" } vm-memory = "0.5.0" +[patch.crates-io] +kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch-v0.3.0", features = ["with-serde", "fam-wrappers"] } + [dependencies.cloud-hypervisor] path = ".." diff --git a/hypervisor/Cargo.toml b/hypervisor/Cargo.toml index 87a3dc44f..772c0a4a8 100644 --- a/hypervisor/Cargo.toml +++ b/hypervisor/Cargo.toml @@ -15,8 +15,8 @@ epoll = ">=4.0.1" thiserror = "1.0" libc = "0.2.86" log = "0.4.14" -kvm-ioctls = { git = "https://github.com/cloud-hypervisor/kvm-ioctls", branch = "ch", optional = true } -kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch", features = ["with-serde", "fam-wrappers"], optional = true } +kvm-ioctls = { version = "0.7.0", optional = true } +kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch-v0.3.0", features = ["with-serde", "fam-wrappers"], optional = true } mshv-bindings = {git = "https://github.com/cloud-hypervisor/mshv", branch = "master", features = ["with-serde", "fam-wrappers"], optional = true } mshv-ioctls = { git = "https://github.com/cloud-hypervisor/mshv", branch = "master", optional = true} serde = {version = ">=1.0.27", features = ["rc"] } diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index b653cd811..6307ab868 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -433,7 +433,7 @@ impl hypervisor::Hypervisor for KvmHypervisor { { let msr_list = self.get_msr_list()?; let num_msrs = msr_list.as_fam_struct_ref().nmsrs as usize; - let mut msrs = MsrEntries::new(num_msrs); + let mut msrs = MsrEntries::new(num_msrs).unwrap(); let indices = msr_list.as_slice(); let msr_entries = msrs.as_mut_slice(); for (pos, index) in indices.iter().enumerate() { @@ -1036,7 +1036,7 @@ impl cpu::Vcpu for KvmVcpu { fn system_registers(&self, state: &mut Vec) -> cpu::Result<()> { // Call KVM_GET_REG_LIST to get all registers available to the guest. For ArmV8 there are // around 500 registers. - let mut reg_list = RegList::new(512); + let mut reg_list = RegList::new(500).unwrap(); self.fd .get_reg_list(&mut reg_list) .map_err(|e| cpu::HypervisorCpuError::GetRegList(e.into()))?; @@ -1170,7 +1170,7 @@ impl cpu::Vcpu for KvmVcpu { let msrs = if num_msrs != expected_num_msrs { let mut faulty_msr_index = num_msrs; let mut msr_entries_tmp = - MsrEntries::from_entries(&msr_entries.as_slice()[..faulty_msr_index]); + MsrEntries::from_entries(&msr_entries.as_slice()[..faulty_msr_index]).unwrap(); loop { warn!( @@ -1180,7 +1180,7 @@ impl cpu::Vcpu for KvmVcpu { let start_pos = faulty_msr_index + 1; let mut sub_msr_entries = - MsrEntries::from_entries(&msr_entries.as_slice()[start_pos..]); + MsrEntries::from_entries(&msr_entries.as_slice()[start_pos..]).unwrap(); let expected_num_msrs = sub_msr_entries.as_fam_struct_ref().nmsrs as usize; let num_msrs = self.get_msrs(&mut sub_msr_entries)?; @@ -1304,7 +1304,8 @@ impl cpu::Vcpu for KvmVcpu { ); let start_pos = faulty_msr_index + 1; - let sub_msr_entries = MsrEntries::from_entries(&state.msrs.as_slice()[start_pos..]); + let sub_msr_entries = + MsrEntries::from_entries(&state.msrs.as_slice()[start_pos..]).unwrap(); let expected_num_msrs = sub_msr_entries.as_fam_struct_ref().nmsrs as usize; let num_msrs = self.set_msrs(&sub_msr_entries)?; diff --git a/hypervisor/src/kvm/x86_64/mod.rs b/hypervisor/src/kvm/x86_64/mod.rs index 00ad27060..aa8840d52 100644 --- a/hypervisor/src/kvm/x86_64/mod.rs +++ b/hypervisor/src/kvm/x86_64/mod.rs @@ -111,6 +111,7 @@ pub fn boot_msr_entries() -> MsrEntries { ), msr_data!(msr_index::MSR_MTRRdefType, MTRR_ENABLE | MTRR_MEM_TYPE_WB), ]) + .unwrap() } /// diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index ffc77b3c5..6e4d60389 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -93,7 +93,7 @@ impl hypervisor::Hypervisor for MshvHypervisor { let msr_list = self.get_msr_list()?; let num_msrs = msr_list.as_fam_struct_ref().nmsrs as usize; - let mut msrs = MsrEntries::new(num_msrs); + let mut msrs = MsrEntries::new(num_msrs).unwrap(); let indices = msr_list.as_slice(); let msr_entries = msrs.as_mut_slice(); for (pos, index) in indices.iter().enumerate() { @@ -115,7 +115,7 @@ impl hypervisor::Hypervisor for MshvHypervisor { /// Get the supported CpuID /// fn get_cpuid(&self) -> hypervisor::Result { - Ok(CpuId::new(1)) + Ok(CpuId::new(1).unwrap()) } #[cfg(target_arch = "x86_64")] /// @@ -759,7 +759,7 @@ impl vm::Vm for MshvVm { let vcpu = MshvVcpu { fd: vcpu_fd, vp_index: id, - cpuid: CpuId::new(1), + cpuid: CpuId::new(1).unwrap(), msrs: self.msrs.clone(), gsi_routes: self.gsi_routes.clone(), hv_state: self.hv_state.clone(), diff --git a/hypervisor/src/mshv/x86_64/mod.rs b/hypervisor/src/mshv/x86_64/mod.rs index c1f5cfdda..d072e9a13 100644 --- a/hypervisor/src/mshv/x86_64/mod.rs +++ b/hypervisor/src/mshv/x86_64/mod.rs @@ -119,4 +119,5 @@ pub fn boot_msr_entries() -> MsrEntries { msr!(msr_index::MSR_SYSCALL_MASK), msr!(msr_index::MSR_IA32_TSC), ]) + .unwrap() } diff --git a/qcow/src/qcow.rs b/qcow/src/qcow.rs index 8e4ab20a4..f29d83c40 100644 --- a/qcow/src/qcow.rs +++ b/qcow/src/qcow.rs @@ -22,7 +22,7 @@ use std::io::{self, Read, Seek, SeekFrom, Write}; use std::mem::size_of; use vmm_sys_util::{ file_traits::FileSetLen, file_traits::FileSync, seek_hole::SeekHole, write_zeroes::PunchHole, - write_zeroes::WriteZeroes, + write_zeroes::WriteZeroesAt, }; pub use crate::raw_file::RawFile; @@ -1274,8 +1274,7 @@ impl QcowFile { // unallocated clusters already read back as zeroes. if let Some(offset) = self.file_offset_read(curr_addr)? { // Partial cluster - zero it out. - self.raw_file.file_mut().seek(SeekFrom::Start(offset))?; - self.raw_file.file_mut().write_zeroes(count)?; + self.raw_file.file_mut().write_zeroes_at(offset, count)?; } } @@ -1528,6 +1527,13 @@ impl PunchHole for QcowFile { } } +impl WriteZeroesAt for QcowFile { + fn write_zeroes_at(&mut self, offset: u64, length: usize) -> io::Result { + self.punch_hole(offset, length as u64)?; + Ok(length) + } +} + impl SeekHole for QcowFile { fn seek_hole(&mut self, offset: u64) -> io::Result> { match self.find_allocated_cluster(offset, false) { @@ -1705,6 +1711,7 @@ mod tests { use super::*; use std::io::{Read, Seek, SeekFrom, Write}; use vmm_sys_util::tempfile::TempFile; + use vmm_sys_util::write_zeroes::WriteZeroes; fn valid_header_v3() -> Vec { vec![ diff --git a/qcow/src/raw_file.rs b/qcow/src/raw_file.rs index 1dc9e9166..971431052 100644 --- a/qcow/src/raw_file.rs +++ b/qcow/src/raw_file.rs @@ -15,7 +15,7 @@ use std::fs::{File, Metadata}; use std::io::{self, Read, Seek, SeekFrom, Write}; use std::os::unix::io::{AsRawFd, RawFd}; use std::slice; -use vmm_sys_util::{seek_hole::SeekHole, write_zeroes::PunchHole}; +use vmm_sys_util::{seek_hole::SeekHole, write_zeroes::PunchHole, write_zeroes::WriteZeroesAt}; #[derive(Debug)] pub struct RawFile { @@ -281,6 +281,12 @@ impl Seek for RawFile { } } +impl WriteZeroesAt for RawFile { + fn write_zeroes_at(&mut self, offset: u64, length: usize) -> std::io::Result { + self.file.write_zeroes_at(offset, length) + } +} + impl PunchHole for RawFile { fn punch_hole(&mut self, offset: u64, length: u64) -> std::io::Result<()> { self.file.punch_hole(offset, length) diff --git a/virtio-devices/src/seccomp_filters.rs b/virtio-devices/src/seccomp_filters.rs index 31b74950b..a4a591c51 100644 --- a/virtio-devices/src/seccomp_filters.rs +++ b/virtio-devices/src/seccomp_filters.rs @@ -108,6 +108,7 @@ fn virtio_block_thread_rules() -> Vec { allow_syscall(libc::SYS_pread64), allow_syscall(libc::SYS_preadv), allow_syscall(libc::SYS_pwritev), + allow_syscall(libc::SYS_pwrite64), allow_syscall(libc::SYS_read), allow_syscall(libc::SYS_rt_sigprocmask), allow_syscall(libc::SYS_sched_getaffinity), diff --git a/vmm/Cargo.toml b/vmm/Cargo.toml index 4d90d7676..b3b6b15c0 100644 --- a/vmm/Cargo.toml +++ b/vmm/Cargo.toml @@ -27,6 +27,7 @@ event_monitor = { path = "../event_monitor" } hypervisor = { path = "../hypervisor" } lazy_static = "1.4.0" libc = "0.2.86" +linux-loader = { version = "0.3.0", features = ["elf", "bzimage", "pe"] } log = "0.4.14" micro_http = { git = "https://github.com/firecracker-microvm/micro-http", branch = "master" } net_util = { path = "../net_util" } @@ -49,10 +50,5 @@ vm-migration = { path = "../vm-migration" } vm-virtio = { path = "../vm-virtio" } vmm-sys-util = { version = ">=0.5.0", features = ["with-serde"] } - -[dependencies.linux-loader] -git = "https://github.com/rust-vmm/linux-loader" -features = ["elf", "bzimage", "pe"] - [dev-dependencies] credibility = "0.1.3" diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index b6c8cd6d3..d87c67491 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -1611,7 +1611,8 @@ mod tests { let mut msrs = MsrEntries::from_entries(&[MsrEntry { index: msr_index::MSR_IA32_MISC_ENABLE, ..Default::default() - }]); + }]) + .unwrap(); // get_msrs returns the number of msrs that it succeed in reading. We only want to read 1 // in this test case scenario.