diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-12-20 02:22:17 +0100 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-12-20 12:21:35 +0100 |
commit | a17f5d4abf9c4f49098cb65868f26c28d348ab0e (patch) | |
tree | fbae9fefaed81fd135825806431aafbc60a11abd | |
parent | 4738d6c8000704aa6f84ecd83cb4a9efb6ae47b8 (diff) | |
download | spectrum-a17f5d4abf9c4f49098cb65868f26c28d348ab0e.tar spectrum-a17f5d4abf9c4f49098cb65868f26c28d348ab0e.tar.gz spectrum-a17f5d4abf9c4f49098cb65868f26c28d348ab0e.tar.bz2 spectrum-a17f5d4abf9c4f49098cb65868f26c28d348ab0e.tar.lz spectrum-a17f5d4abf9c4f49098cb65868f26c28d348ab0e.tar.xz spectrum-a17f5d4abf9c4f49098cb65868f26c28d348ab0e.tar.zst spectrum-a17f5d4abf9c4f49098cb65868f26c28d348ab0e.zip |
lib/nixpkgs.default.nix: update to nixos-unstable
Signed-off-by: Alyssa Ross <hi@alyssa.is>
9 files changed, 378 insertions, 333 deletions
diff --git a/lib/nixpkgs.default.nix b/lib/nixpkgs.default.nix index 5c3f541..bbdf34a 100644 --- a/lib/nixpkgs.default.nix +++ b/lib/nixpkgs.default.nix @@ -4,6 +4,6 @@ # Generated by scripts/update-nixpkgs.sh. import (builtins.fetchTarball { - url = "https://github.com/NixOS/nixpkgs/archive/a9bf124c46ef298113270b1f84a164865987a91c.tar.gz"; - sha256 = "0wdjv548d84s74wrncqqj5pdzfq7nj8xn97l0v7r82jl6124jil2"; + url = "https://github.com/NixOS/nixpkgs/archive/91a00709aebb3602f172a0bf47ba1ef013e34835.tar.gz"; + sha256 = "10p8abhcmqdg5wnqkcyq05qkk0ybhx564vmlrphf513hyhi71y4n"; }) diff --git a/pkgs/cloud-hypervisor/0001-build-use-local-vhost.patch b/pkgs/cloud-hypervisor/0001-build-use-local-vhost.patch index cf8077b..e6d81e9 100644 --- a/pkgs/cloud-hypervisor/0001-build-use-local-vhost.patch +++ b/pkgs/cloud-hypervisor/0001-build-use-local-vhost.patch @@ -1,4 +1,4 @@ -From d70541c471be5d21bc840f0588759d88a7d6ec78 Mon Sep 17 00:00:00 2001 +From cb9d39048282bc28d0a5be01be268dd74fbd3408 Mon Sep 17 00:00:00 2001 From: Alyssa Ross <alyssa.ross@unikie.com> Date: Wed, 28 Sep 2022 12:18:19 +0000 Subject: [PATCH 1/2] build: use local vhost @@ -14,29 +14,29 @@ Signed-off-by: Alyssa Ross <hi@alyssa.is> 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock -index f40fbc0f..fbab2e1d 100644 +index 52afc0d1..bef28e85 100644 --- a/Cargo.lock +++ b/Cargo.lock -@@ -2331,8 +2331,6 @@ dependencies = [ +@@ -2371,8 +2371,6 @@ dependencies = [ [[package]] name = "vhost" - version = "0.8.1" + version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "61957aeb36daf0b00b87fff9c10dd28a161bd35ab157553d340d183b3d8756e6" +-checksum = "289adfce099c71f8310f895932ccd978f352ca494ea47496dbe20d4241888b82" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "libc", -@@ -2343,8 +2341,6 @@ dependencies = [ +@@ -2383,8 +2381,6 @@ dependencies = [ [[package]] name = "vhost-user-backend" - version = "0.10.1" + version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "ab069cdedaf18a0673766eb0a07a0f4ee3ed1b8e17fbfe4aafe5b988e2de1d01" +-checksum = "61255322e3ebe93fb77d9f6d99577eca7089bbea4174076c5353a8024a463061" dependencies = [ "libc", "log", diff --git a/Cargo.toml b/Cargo.toml -index 547bccc2..248ff07c 100644 +index ceb1fc67..5d750eba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,8 @@ zbus = { version = "3.11.1", optional = true } diff --git a/pkgs/cloud-hypervisor/0002-virtio-devices-add-a-GPU-device.patch b/pkgs/cloud-hypervisor/0002-virtio-devices-add-a-GPU-device.patch index e879fc2..9840627 100644 --- a/pkgs/cloud-hypervisor/0002-virtio-devices-add-a-GPU-device.patch +++ b/pkgs/cloud-hypervisor/0002-virtio-devices-add-a-GPU-device.patch @@ -1,4 +1,4 @@ -From 81a571032de71665d97ca8579249d91225e77ec0 Mon Sep 17 00:00:00 2001 +From 24ef519720ced73b7fe75bc0d0c5171f67e3edb7 Mon Sep 17 00:00:00 2001 From: Alyssa Ross <alyssa.ross@unikie.com> Date: Wed, 7 Sep 2022 14:16:29 +0000 Subject: [PATCH 2/2] virtio-devices: add a GPU device @@ -44,7 +44,7 @@ Signed-off-by: Alyssa Ross <hi@alyssa.is> create mode 100644 virtio-devices/src/vhost_user/gpu.rs diff --git a/src/main.rs b/src/main.rs -index 426d154c..82ee6821 100644 +index 2edd116a..3970de2c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -277,6 +277,13 @@ fn create_app(default_vcpus: String, default_memory: String, default_rng: String @@ -61,7 +61,7 @@ index 426d154c..82ee6821 100644 .arg( Arg::new("pmem") .long("pmem") -@@ -843,6 +850,7 @@ mod unit_tests { +@@ -850,6 +857,7 @@ mod unit_tests { }, balloon: None, fs: None, @@ -155,10 +155,10 @@ index 41585e77..1c7fc1bc 100644 Thread::VirtioVhostNetCtl => virtio_vhost_net_ctl_thread_rules(), Thread::VirtioVsock => virtio_vsock_thread_rules(), diff --git a/virtio-devices/src/transport/pci_device.rs b/virtio-devices/src/transport/pci_device.rs -index 60979573..0348b53a 100644 +index 2f711c80..246b6497 100644 --- a/virtio-devices/src/transport/pci_device.rs +++ b/virtio-devices/src/transport/pci_device.rs -@@ -1054,11 +1054,11 @@ impl PciDevice for VirtioPciDevice { +@@ -1053,11 +1053,11 @@ impl PciDevice for VirtioPciDevice { PciDeviceError::IoRegistrationFailed(shm_list.addr.raw_value(), e) })?; @@ -174,7 +174,7 @@ index 60979573..0348b53a 100644 ); diff --git a/virtio-devices/src/vhost_user/gpu.rs b/virtio-devices/src/vhost_user/gpu.rs new file mode 100644 -index 00000000..ab8e6b48 +index 00000000..0dd06f73 --- /dev/null +++ b/virtio-devices/src/vhost_user/gpu.rs @@ -0,0 +1,415 @@ @@ -204,7 +204,7 @@ index 00000000..ab8e6b48 + VhostUserShmemUnmapMsg, VhostUserVirtioFeatures, +}; +use vhost::vhost_user::{ -+ HandlerResult, MasterReqHandler, VhostUserMaster, VhostUserMasterReqHandler, ++ FrontendReqHandler, HandlerResult, VhostUserFrontend, VhostUserFrontendReqHandler, +}; +use virtio_bindings::virtio_gpu::{ + VIRTIO_GPU_F_CONTEXT_INIT, VIRTIO_GPU_F_RESOURCE_BLOB, VIRTIO_GPU_F_RESOURCE_UUID, @@ -218,12 +218,12 @@ index 00000000..ab8e6b48 +const QUEUE_SIZES: &[u16] = &[256, 16]; +const NUM_QUEUES: u16 = QUEUE_SIZES.len() as _; + -+struct SlaveReqHandler { ++struct BackendReqHandler { + cache_size: u64, + mmap_cache_addr: u64, +} + -+impl SlaveReqHandler { ++impl BackendReqHandler { + // Make sure request is within cache range + fn is_req_valid(&self, offset: u64, len: u64) -> bool { + let end = match offset.checked_add(len) { @@ -235,7 +235,7 @@ index 00000000..ab8e6b48 + } +} + -+impl VhostUserMasterReqHandler for SlaveReqHandler { ++impl VhostUserFrontendReqHandler for BackendReqHandler { + fn shmem_map(&self, req: &VhostUserShmemMapMsg, fd: &dyn AsRawFd) -> HandlerResult<u64> { + if !self.is_req_valid(req.shm_offset, req.len) { + return Err(io::Error::from_raw_os_error(libc::EINVAL)); @@ -305,7 +305,7 @@ index 00000000..ab8e6b48 + // Hold ownership of the memory that is allocated for the device + // which will be automatically dropped when the device is dropped + cache: Option<(VirtioSharedMemoryList, MmapRegion)>, -+ slave_req_support: bool, ++ backend_req_support: bool, + seccomp_action: SeccompAction, + guest_memory: Option<GuestMemoryAtomic<GuestMemoryMmap>>, + epoll_thread: Option<thread::JoinHandle<()>>, @@ -333,7 +333,7 @@ index 00000000..ab8e6b48 + | VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits(); + + let avail_protocol_features = VhostUserProtocolFeatures::CONFIG -+ | VhostUserProtocolFeatures::SLAVE_REQ ++ | VhostUserProtocolFeatures::BACKEND_REQ + | VhostUserProtocolFeatures::SHARED_MEMORY_REGIONS; + + let (acked_features, acked_protocol_features) = @@ -373,8 +373,8 @@ index 00000000..ab8e6b48 + }, + id, + cache: None, -+ slave_req_support: acked_protocol_features -+ & VhostUserProtocolFeatures::SLAVE_REQ.bits() ++ backend_req_support: acked_protocol_features ++ & VhostUserProtocolFeatures::BACKEND_REQ.bits() + != 0, + seccomp_action, + guest_memory: None, @@ -450,17 +450,17 @@ index 00000000..ab8e6b48 + self.common.activate(&queues, &interrupt_cb)?; + self.guest_memory = Some(mem.clone()); + -+ // Initialize slave communication. -+ let slave_req_handler = if self.slave_req_support { ++ // Initialize backend communication. ++ let backend_req_handler = if self.backend_req_support { + if let Some(cache) = self.cache.as_ref() { -+ let vu_master_req_handler = Arc::new(SlaveReqHandler { ++ let vu_frontend_req_handler = Arc::new(BackendReqHandler { + cache_size: cache.0.len, + mmap_cache_addr: cache.0.host_addr, + }); + + let mut req_handler = -+ MasterReqHandler::new(vu_master_req_handler).map_err(|e| { -+ ActivateError::VhostUserGpuSetup(Error::MasterReqHandlerCreation(e)) ++ FrontendReqHandler::new(vu_frontend_req_handler).map_err(|e| { ++ ActivateError::VhostUserGpuSetup(Error::FrontendReqHandlerCreation(e)) + })?; + + if self.vu_common.acked_protocol_features @@ -487,7 +487,7 @@ index 00000000..ab8e6b48 + queues, + interrupt_cb, + self.common.acked_features, -+ slave_req_handler, ++ backend_req_handler, + kill_evt, + pause_evt, + )?; @@ -594,7 +594,7 @@ index 00000000..ab8e6b48 + } +} diff --git a/virtio-devices/src/vhost_user/mod.rs b/virtio-devices/src/vhost_user/mod.rs -index 2dee7324..803db659 100644 +index a4f56c31..fe10b144 100644 --- a/virtio-devices/src/vhost_user/mod.rs +++ b/virtio-devices/src/vhost_user/mod.rs @@ -31,11 +31,13 @@ use vu_common_ctrl::VhostUserHandle; @@ -630,10 +630,10 @@ index 2dee7324..803db659 100644 UsedAddress, #[error("Invalid features provided from vhost-user backend")] diff --git a/virtio-devices/src/vhost_user/vu_common_ctrl.rs b/virtio-devices/src/vhost_user/vu_common_ctrl.rs -index 7bbf936c..b804084b 100644 +index 6f980f23..54511c52 100644 --- a/virtio-devices/src/vhost_user/vu_common_ctrl.rs +++ b/virtio-devices/src/vhost_user/vu_common_ctrl.rs -@@ -19,7 +19,8 @@ use std::time::{Duration, Instant}; +@@ -18,7 +18,8 @@ use std::time::{Duration, Instant}; use std::vec::Vec; use vhost::vhost_kern::vhost_binding::{VHOST_F_LOG_ALL, VHOST_VRING_F_LOG}; use vhost::vhost_user::message::{ @@ -641,9 +641,9 @@ index 7bbf936c..b804084b 100644 + VhostSharedMemoryRegion, VhostUserHeaderFlag, VhostUserInflight, VhostUserProtocolFeatures, + VhostUserVirtioFeatures, }; - use vhost::vhost_user::{Master, MasterReqHandler, VhostUserMaster, VhostUserMasterReqHandler}; - use vhost::{VhostBackend, VhostUserDirtyLogRegion, VhostUserMemoryRegionInfo, VringConfigData}; -@@ -103,6 +104,12 @@ impl VhostUserHandle { + use vhost::vhost_user::{ + Frontend, FrontendReqHandler, VhostUserFrontend, VhostUserFrontendReqHandler, +@@ -104,6 +105,12 @@ impl VhostUserHandle { .map_err(Error::VhostUserAddMemReg) } @@ -692,7 +692,7 @@ index aaae8ee3..9433ee07 100644 VmAddPmem(Arc<PmemConfig>, Sender<ApiResponse>), diff --git a/vmm/src/config.rs b/vmm/src/config.rs -index 3bac721a..277e2408 100644 +index 7ed48e0d..97086516 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -27,6 +27,8 @@ pub enum Error { @@ -713,7 +713,7 @@ index 3bac721a..277e2408 100644 /// Error parsing persistent memory parameters ParsePersistentMemory(OptionParserError), /// Failed parsing console -@@ -321,6 +325,8 @@ impl fmt::Display for Error { +@@ -318,6 +322,8 @@ impl fmt::Display for Error { ParseFileSystem(o) => write!(f, "Error parsing --fs: {o}"), ParseFsSockMissing => write!(f, "Error parsing --fs: socket missing"), ParseFsTagMissing => write!(f, "Error parsing --fs: tag missing"), @@ -722,7 +722,7 @@ index 3bac721a..277e2408 100644 ParsePersistentMemory(o) => write!(f, "Error parsing --pmem: {o}"), ParsePmemFileMissing => write!(f, "Error parsing --pmem: file missing"), ParseVsock(o) => write!(f, "Error parsing --vsock: {o}"), -@@ -385,6 +391,7 @@ pub struct VmParams<'a> { +@@ -382,6 +388,7 @@ pub struct VmParams<'a> { pub rng: &'a str, pub balloon: Option<&'a str>, pub fs: Option<Vec<&'a str>>, @@ -730,7 +730,7 @@ index 3bac721a..277e2408 100644 pub pmem: Option<Vec<&'a str>>, pub serial: &'a str, pub console: &'a str, -@@ -428,6 +435,9 @@ impl<'a> VmParams<'a> { +@@ -427,6 +434,9 @@ impl<'a> VmParams<'a> { let fs: Option<Vec<&str>> = args .get_many::<String>("fs") .map(|x| x.map(|y| y as &str).collect()); @@ -740,7 +740,7 @@ index 3bac721a..277e2408 100644 let pmem: Option<Vec<&str>> = args .get_many::<String>("pmem") .map(|x| x.map(|y| y as &str).collect()); -@@ -467,6 +477,7 @@ impl<'a> VmParams<'a> { +@@ -468,6 +478,7 @@ impl<'a> VmParams<'a> { rng, balloon, fs, @@ -748,7 +748,7 @@ index 3bac721a..277e2408 100644 pmem, serial, console, -@@ -1404,6 +1415,49 @@ impl FsConfig { +@@ -1407,6 +1418,49 @@ impl FsConfig { } } @@ -798,7 +798,7 @@ index 3bac721a..277e2408 100644 impl PmemConfig { pub const SYNTAX: &'static str = "Persistent memory parameters \ \"file=<backing_file_path>,size=<persistent_memory_size>,iommu=on|off,\ -@@ -1988,6 +2042,17 @@ impl VmConfig { +@@ -2000,6 +2054,17 @@ impl VmConfig { } } @@ -816,7 +816,7 @@ index 3bac721a..277e2408 100644 if let Some(pmems) = &self.pmem { for pmem in pmems { pmem.validate(self)?; -@@ -2202,6 +2267,15 @@ impl VmConfig { +@@ -2214,6 +2279,15 @@ impl VmConfig { fs = Some(fs_config_list); } @@ -832,7 +832,7 @@ index 3bac721a..277e2408 100644 let mut pmem: Option<Vec<PmemConfig>> = None; if let Some(pmem_list) = &vm_params.pmem { let mut pmem_config_list = Vec::new(); -@@ -2308,6 +2382,7 @@ impl VmConfig { +@@ -2329,6 +2403,7 @@ impl VmConfig { rng, balloon, fs, @@ -840,7 +840,7 @@ index 3bac721a..277e2408 100644 pmem, serial, console, -@@ -2362,6 +2437,13 @@ impl VmConfig { +@@ -2383,6 +2458,13 @@ impl VmConfig { removed |= fs.len() != len; } @@ -854,7 +854,7 @@ index 3bac721a..277e2408 100644 // Remove if net device if let Some(net) = self.net.as_mut() { let len = net.len(); -@@ -2431,6 +2513,7 @@ impl Clone for VmConfig { +@@ -2452,6 +2534,7 @@ impl Clone for VmConfig { rng: self.rng.clone(), balloon: self.balloon.clone(), fs: self.fs.clone(), @@ -862,7 +862,7 @@ index 3bac721a..277e2408 100644 pmem: self.pmem.clone(), serial: self.serial.clone(), console: self.console.clone(), -@@ -2825,6 +2908,21 @@ mod tests { +@@ -2846,6 +2929,21 @@ mod tests { Ok(()) } @@ -884,7 +884,7 @@ index 3bac721a..277e2408 100644 #[test] fn test_pmem_parsing() -> Result<()> { // Must always give a file and size -@@ -3075,6 +3173,7 @@ mod tests { +@@ -3096,6 +3194,7 @@ mod tests { }, balloon: None, fs: None, @@ -892,7 +892,7 @@ index 3bac721a..277e2408 100644 pmem: None, serial: ConsoleConfig { file: None, -@@ -3242,6 +3341,15 @@ mod tests { +@@ -3260,6 +3359,15 @@ mod tests { Err(ValidationError::VhostUserRequiresSharedMemory) ); @@ -909,7 +909,7 @@ index 3bac721a..277e2408 100644 still_valid_config.memory.shared = true; assert!(still_valid_config.validate().is_ok()); diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs -index 24900e78..4aa6a676 100644 +index 883f0c04..847aea72 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -10,8 +10,8 @@ @@ -973,7 +973,7 @@ index 24900e78..4aa6a676 100644 /// Error creating serial output file SerialOutputFileOpen(io::Error), -@@ -2155,6 +2167,9 @@ impl DeviceManager { +@@ -2156,6 +2168,9 @@ impl DeviceManager { // Add virtio-fs if required devices.append(&mut self.make_virtio_fs_devices()?); @@ -983,7 +983,7 @@ index 24900e78..4aa6a676 100644 // Add virtio-pmem if required devices.append(&mut self.make_virtio_pmem_devices()?); -@@ -2684,6 +2699,114 @@ impl DeviceManager { +@@ -2685,6 +2700,114 @@ impl DeviceManager { Ok(devices) } @@ -1017,7 +1017,7 @@ index 24900e78..4aa6a676 100644 + + // In crosvm, the 8 GiB bar is 8 GiB-aligned. + let cache_base = self.pci_segments[gpu_cfg.pci_segment as usize] -+ .allocator ++ .mem64_allocator + .lock() + .unwrap() + .allocate(None, region.length as GuestUsize, Some(region.length)) @@ -1098,7 +1098,7 @@ index 24900e78..4aa6a676 100644 fn make_virtio_pmem_device( &mut self, pmem_cfg: &mut PmemConfig, -@@ -3943,6 +4066,7 @@ impl DeviceManager { +@@ -3948,6 +4071,7 @@ impl DeviceManager { | VirtioDeviceType::Block | VirtioDeviceType::Pmem | VirtioDeviceType::Fs @@ -1106,7 +1106,7 @@ index 24900e78..4aa6a676 100644 | VirtioDeviceType::Vsock => {} _ => return Err(DeviceManagerError::RemovalNotAllowed(device_type)), } -@@ -4211,6 +4335,13 @@ impl DeviceManager { +@@ -4220,6 +4344,13 @@ impl DeviceManager { self.hotplug_virtio_pci_device(device) } @@ -1121,7 +1121,7 @@ index 24900e78..4aa6a676 100644 self.validate_identifier(&pmem_cfg.id)?; diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs -index 96425b59..6490cdb8 100644 +index 23cd36d0..38ae9a2b 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -13,8 +13,8 @@ use crate::api::{ @@ -1135,7 +1135,7 @@ index 96425b59..6490cdb8 100644 }; #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))] use crate::coredump::GuestDebuggable; -@@ -1171,6 +1171,32 @@ impl Vmm { +@@ -1176,6 +1176,32 @@ impl Vmm { } } @@ -1168,7 +1168,7 @@ index 96425b59..6490cdb8 100644 fn vm_add_pmem(&mut self, pmem_cfg: PmemConfig) -> result::Result<Option<Vec<u8>>, VmError> { self.vm_config.as_ref().ok_or(VmError::VmNotCreated)?; -@@ -2111,6 +2137,13 @@ impl Vmm { +@@ -2128,6 +2154,13 @@ impl Vmm { .map(ApiResponsePayload::VmAction); sender.send(response).map_err(Error::ApiResponseSend)?; } @@ -1182,7 +1182,7 @@ index 96425b59..6490cdb8 100644 ApiRequest::VmAddPmem(add_pmem_data, sender) => { let response = self .vm_add_pmem(add_pmem_data.as_ref().clone()) -@@ -2276,6 +2309,7 @@ mod unit_tests { +@@ -2293,6 +2326,7 @@ mod unit_tests { }, balloon: None, fs: None, @@ -1190,7 +1190,7 @@ index 96425b59..6490cdb8 100644 pmem: None, serial: ConsoleConfig { file: None, -@@ -2505,6 +2539,54 @@ mod unit_tests { +@@ -2522,6 +2556,54 @@ mod unit_tests { ); } @@ -1246,7 +1246,7 @@ index 96425b59..6490cdb8 100644 fn test_vmm_vm_cold_add_pmem() { let mut vmm = create_dummy_vmm(); diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs -index c6a0bec9..e8617d46 100644 +index fc42202e..d70318d3 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -12,8 +12,8 @@ @@ -1260,7 +1260,7 @@ index c6a0bec9..e8617d46 100644 }; use crate::config::{NumaConfig, PayloadConfig}; #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))] -@@ -1504,6 +1504,30 @@ impl Vm { +@@ -1560,6 +1560,30 @@ impl Vm { Ok(pci_device_info) } @@ -1292,7 +1292,7 @@ index c6a0bec9..e8617d46 100644 let pci_device_info = self .device_manager diff --git a/vmm/src/vm_config.rs b/vmm/src/vm_config.rs -index dc028d89..3bc41dc7 100644 +index 100a4898..c4af5851 100644 --- a/vmm/src/vm_config.rs +++ b/vmm/src/vm_config.rs @@ -423,6 +423,15 @@ impl Default for FsConfig { @@ -1311,7 +1311,7 @@ index dc028d89..3bc41dc7 100644 #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)] pub struct PmemConfig { pub file: PathBuf, -@@ -594,6 +603,7 @@ pub struct VmConfig { +@@ -597,6 +606,7 @@ pub struct VmConfig { pub rng: RngConfig, pub balloon: Option<BalloonConfig>, pub fs: Option<Vec<FsConfig>>, diff --git a/pkgs/cloud-hypervisor/Cargo.lock b/pkgs/cloud-hypervisor/Cargo.lock index fbab2e1..bef28e8 100644 --- a/pkgs/cloud-hypervisor/Cargo.lock +++ b/pkgs/cloud-hypervisor/Cargo.lock @@ -36,16 +36,15 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] @@ -75,9 +74,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.2" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -147,15 +146,15 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.5.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" dependencies = [ - "async-lock", + "async-lock 3.2.0", "async-task", "concurrent-queue", - "fastrand 1.9.0", - "futures-lite", + "fastrand 2.0.0", + "futures-lite 2.1.0", "slab", ] @@ -165,10 +164,10 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" dependencies = [ - "async-lock", + "async-lock 2.7.0", "autocfg", "blocking", - "futures-lite", + "futures-lite 1.13.0", ] [[package]] @@ -177,15 +176,15 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ - "async-lock", + "async-lock 2.7.0", "autocfg", "cfg-if", "concurrent-queue", - "futures-lite", + "futures-lite 1.13.0", "log", "parking", "polling", - "rustix 0.37.25", + "rustix 0.37.27", "slab", "socket2", "waker-fn", @@ -201,27 +200,38 @@ dependencies = [ ] [[package]] +name = "async-lock" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +dependencies = [ + "event-listener 4.0.0", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] name = "async-process" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf012553ce51eb7aa6dc2143804cc8252bd1cb681a1c5cb7fa94ca88682dee1d" dependencies = [ "async-io", - "async-lock", + "async-lock 2.7.0", "async-signal", "blocking", "cfg-if", "event-listener 3.0.0", - "futures-lite", + "futures-lite 1.13.0", "rustix 0.38.8", "windows-sys 0.48.0", ] [[package]] name = "async-recursion" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" +checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", @@ -235,7 +245,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c99f3cb3f9ff89f7d718fbb942c9eb91bedff12e396adf09a622dfe7ffec2bc2" dependencies = [ "async-io", - "async-lock", + "async-lock 2.7.0", "atomic-waker", "cfg-if", "concurrent-queue", @@ -249,9 +259,9 @@ dependencies = [ [[package]] name = "async-task" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" +checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" [[package]] name = "async-trait" @@ -361,11 +371,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" dependencies = [ "async-channel", - "async-lock", + "async-lock 2.7.0", "async-task", "atomic-waker", "fastrand 1.9.0", - "futures-lite", + "futures-lite 1.13.0", "log", ] @@ -398,36 +408,35 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.3.11" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" +checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.3.11" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" +checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" dependencies = [ "anstream", "anstyle", "clap_lex", - "once_cell", "strsim", "terminal_size", ] [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "cloud-hypervisor" -version = "36.0.0" +version = "37.0.0" dependencies = [ "anyhow", "api_client", @@ -464,9 +473,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "concurrent-queue" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" +checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" dependencies = [ "crossbeam-utils", ] @@ -719,6 +728,27 @@ dependencies = [ ] [[package]] +name = "event-listener" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.0", + "pin-project-lite", +] + +[[package]] name = "event_monitor" version = "0.1.0" dependencies = [ @@ -796,9 +826,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" @@ -833,6 +863,19 @@ dependencies = [ ] [[package]] +name = "futures-lite" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" +dependencies = [ + "fastrand 2.0.0", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] name = "futures-macro" version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -851,9 +894,9 @@ checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" @@ -875,11 +918,11 @@ dependencies = [ [[package]] name = "gdbstub" -version = "0.6.6" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4e02bf1b1a624d96925c608f1b268d82a76cbc587ce9e59f7c755e9ea11c75c" +checksum = "09a8b954f9d02b74fe8e89a1c77bd9a6b8206713ebf1b272bfad9573b4a86f88" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "cfg-if", "log", "managed", @@ -889,9 +932,9 @@ dependencies = [ [[package]] name = "gdbstub_arch" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eecb536c55c43593a00dde9074dbbdb0e81ce5f20dbca921400f8779c21dea9c" +checksum = "4e3b1357bd3203fc09a6601327ae0ab38865d14231d0b65d3143f5762cc7977d" dependencies = [ "gdbstub", "num-traits", @@ -1024,9 +1067,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown", @@ -1054,9 +1097,9 @@ dependencies = [ [[package]] name = "io-uring" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "141a0f4546a50b2ed637c7a6df0d7dff45c9f41523254996764461c8ae0d9424" +checksum = "460648e47a07a43110fbfa2e0b14afb2be920093c31e5dccc50e49568e099762" dependencies = [ "bitflags 1.3.2", "libc", @@ -1157,9 +1200,9 @@ dependencies = [ [[package]] name = "linux-loader" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1db6a725c8000971f83fa93ed7ee1b600e55a1471a2a653379d3c84f72effdcf" +checksum = "132a531b85b3a164012ab682c72f8f2cce7757f187be5f60782fd2b4cda9cb34" dependencies = [ "vm-memory", ] @@ -1188,12 +1231,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "managed" @@ -1219,7 +1259,7 @@ dependencies = [ [[package]] name = "micro_http" version = "0.1.0" -source = "git+https://github.com/firecracker-microvm/micro-http?branch=main#0d0fdcd50ea10c1b4777f9a958873fc848a5b7bb" +source = "git+https://github.com/firecracker-microvm/micro-http?branch=main#a4d632f2c5ea45712c0d2002dc909a63879e85c3" dependencies = [ "libc", "vmm-sys-util", @@ -1247,7 +1287,7 @@ dependencies = [ [[package]] name = "mshv-bindings" version = "0.1.1" -source = "git+https://github.com/rust-vmm/mshv?branch=main#af397ea8514303d3a19d21d33730e867f7415ba9" +source = "git+https://github.com/rust-vmm/mshv?branch=main#0dd4d3452a7f2e95199f4b58380acc41458474de" dependencies = [ "libc", "serde", @@ -1259,7 +1299,7 @@ dependencies = [ [[package]] name = "mshv-ioctls" version = "0.1.1" -source = "git+https://github.com/rust-vmm/mshv?branch=main#af397ea8514303d3a19d21d33730e867f7415ba9" +source = "git+https://github.com/rust-vmm/mshv?branch=main#0dd4d3452a7f2e95199f4b58380acc41458474de" dependencies = [ "libc", "mshv-bindings", @@ -1327,18 +1367,18 @@ checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65" [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] [[package]] name = "object" -version = "0.30.3" +version = "0.30.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "memchr", ] @@ -1413,9 +1453,9 @@ dependencies = [ [[package]] name = "parking" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e52c774a4c39359c1d1c52e43f73dd91a75a614652c825408eec30c95a9b2067" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" @@ -1509,18 +1549,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", @@ -1670,9 +1710,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -1823,9 +1863,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.25" +version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4eb579851244c2c03e7c24f501c3432bed80b8f720af1d6e5b0e0f01555a035" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", "errno", @@ -1908,9 +1948,9 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.12" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" +checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", @@ -2087,11 +2127,11 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.37.25", + "rustix 0.38.8", "windows-sys 0.48.0", ] @@ -2138,9 +2178,9 @@ checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" @@ -2227,9 +2267,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "utf8parse" @@ -2288,7 +2328,7 @@ dependencies = [ [[package]] name = "vfio-bindings" version = "0.4.0" -source = "git+https://github.com/rust-vmm/vfio?branch=main#847b0aa504ac6367efe42ba7e96a2d050737d4f0" +source = "git+https://github.com/rust-vmm/vfio?branch=main#59c604fa6e42080f0a47c124ba29454fe4cb7475" dependencies = [ "vmm-sys-util", ] @@ -2296,7 +2336,7 @@ dependencies = [ [[package]] name = "vfio-ioctls" version = "0.2.0" -source = "git+https://github.com/rust-vmm/vfio?branch=main#847b0aa504ac6367efe42ba7e96a2d050737d4f0" +source = "git+https://github.com/rust-vmm/vfio?branch=main#59c604fa6e42080f0a47c124ba29454fe4cb7475" dependencies = [ "byteorder", "kvm-bindings", @@ -2314,7 +2354,7 @@ dependencies = [ [[package]] name = "vfio_user" version = "0.1.0" -source = "git+https://github.com/rust-vmm/vfio-user?branch=main#2d96b90a7279547356ad8f83aaa3115ad5497302" +source = "git+https://github.com/rust-vmm/vfio-user?branch=main#6c72e997e61d9e84b8ee691ad63ece6c717cf5aa" dependencies = [ "bitflags 1.3.2", "libc", @@ -2330,9 +2370,9 @@ dependencies = [ [[package]] name = "vhost" -version = "0.8.1" +version = "0.9.0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "libc", "vm-memory", "vmm-sys-util", @@ -2340,7 +2380,7 @@ dependencies = [ [[package]] name = "vhost-user-backend" -version = "0.10.1" +version = "0.11.0" dependencies = [ "libc", "log", @@ -2390,9 +2430,9 @@ dependencies = [ [[package]] name = "virtio-bindings" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c18d7b74098a946470ea265b5bacbbf877abc3373021388454de0d47735a5b98" +checksum = "878bcb1b2812a10c30d53b0ed054999de3d98f25ece91fc173973f9c57aaae86" [[package]] name = "virtio-devices" @@ -2430,9 +2470,9 @@ dependencies = [ [[package]] name = "virtio-queue" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35aca00da06841bd99162c381ec65893cace23ca0fb89254302cfe4bec4c300f" +checksum = "73a01db2cfb6c4b9bc20608b1336263d16714ea8db05de9fec2a254e076f9385" dependencies = [ "log", "virtio-bindings", @@ -2469,9 +2509,9 @@ source = "git+https://github.com/rust-vmm/vm-fdt?branch=main#77212bd0d62913e445c [[package]] name = "vm-memory" -version = "0.12.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dc276f0d00c17b9aeb584da0f1e1c673df0d183cc2539e3636ec8cbc5eae99b" +checksum = "5376c9ee5ebe2103a310d8241936cfb93c946734b0479a4fa5bdf7a64abbacd8" dependencies = [ "arc-swap", "libc", @@ -2521,15 +2561,20 @@ dependencies = [ "futures", "gdbstub", "gdbstub_arch", + "hex", "hypervisor", + "igvm", + "igvm_defs", "libc", "linux-loader", "log", "micro_http", + "mshv-bindings", "net_util", "once_cell", "option_parser", "pci", + "range_map_vec", "seccompiler", "serde", "serde_json", @@ -2833,7 +2878,7 @@ dependencies = [ "async-executor", "async-fs", "async-io", - "async-lock", + "async-lock 2.7.0", "async-process", "async-recursion", "async-task", diff --git a/pkgs/cloud-hypervisor/default.nix b/pkgs/cloud-hypervisor/default.nix index f7b82c3..194e4f3 100644 --- a/pkgs/cloud-hypervisor/default.nix +++ b/pkgs/cloud-hypervisor/default.nix @@ -16,11 +16,11 @@ final.rustPlatform.buildRustPackage { "igvm-0.1.0" = "sha256-l+Qyhdy3b8h8hPLHg5M0os8aSkjM55hAP5nqi0AGmjo="; "kvm-bindings-0.6.0" = "sha256-wGdAuPwsgRIqx9dh0m+hC9A/Akz9qg9BM+p06Fi5ACM="; "kvm-ioctls-0.13.0" = "sha256-jHnFGwBWnAa2lRu4a5eRNy1Y26NX5MV8alJ86VR++QE="; - "micro_http-0.1.0" = "sha256-wX35VsrO1vxQcGbOrP+yZm9vG0gcTZLe7gH7xuAa12w="; - "mshv-bindings-0.1.1" = "sha256-vyNaKp89THzZ/UpfocEwaCUzCuQnBMyv/icuZEghZEQ="; + "micro_http-0.1.0" = "sha256-Ov75Gs+wSmsxOHJu024nWtOJp0cKpS8bkxJJGW6jiKw="; + "mshv-bindings-0.1.1" = "sha256-4ADpLvi9hmHsMyGtqDQ2Msa3aMZmJsi4BPW7B5ZfAMw="; "versionize_derive-0.1.4" = "sha256-oGuREJ5+FDs8ihmv99WmjIPpL2oPdOr4REk6+7cV/7o="; - "vfio-bindings-0.4.0" = "sha256-hGhfOE9q9sf/tzPuaAHOca+JKCutcm1Myu1Tt9spaIQ="; - "vfio_user-0.1.0" = "sha256-fAqvy3YTDKXQqtJR+R2nBCWIYe89zTwtbgvJfPLqs1Q="; + "vfio-bindings-0.4.0" = "sha256-grOV+7W1tB4YDRAFbDNQp5nQ1WaivH+N+qHTIj4WA+E="; + "vfio_user-0.1.0" = "sha256-Vi6dBu1mUwyWh7ryKDOBS6GeUD2sqqIrt/bth/LDW6s="; "vm-fdt-0.2.0" = "sha256-lKW4ZUraHomSDyxgNlD5qTaBTZqM0Fwhhh/08yhrjyE="; }; }; @@ -29,8 +29,8 @@ final.rustPlatform.buildRustPackage { name = "vhost"; owner = "rust-vmm"; repo = "vhost"; - rev = "vhost-user-backend-v0.10.1"; - hash = "sha256-pq545s7sqE0GFFkEkAvKwFKLuRArNThmRFqEYS3nNVo="; + rev = "vhost-user-backend-v0.11.0"; + hash = "sha256-VLKlvyHUrMrwJALUP7OeVeHIogu8rfoP4sgyUMCIBzU="; }; cargoPatches = super.cloud-hypervisor.cargoPatches or [] ++ [ diff --git a/pkgs/cloud-hypervisor/vhost/0001-vhost-fix-receiving-reply-payloads.patch b/pkgs/cloud-hypervisor/vhost/0001-vhost-fix-receiving-reply-payloads.patch index 2ac5e59..e7a4aa8 100644 --- a/pkgs/cloud-hypervisor/vhost/0001-vhost-fix-receiving-reply-payloads.patch +++ b/pkgs/cloud-hypervisor/vhost/0001-vhost-fix-receiving-reply-payloads.patch @@ -1,4 +1,4 @@ -From dc7bfffa0601317e41c011f0f468fca9bc21a6c8 Mon Sep 17 00:00:00 2001 +From 9bf26d1815042e652c77249da973b7e8277010b5 Mon Sep 17 00:00:00 2001 From: David Stevens <stevensd@chromium.org> Date: Wed, 15 Jun 2022 15:56:18 +0900 Subject: [PATCH 1/4] vhost: fix receiving reply payloads @@ -18,11 +18,11 @@ Co-authored-by: Alyssa Ross <hi@alyssa.is> Signed-off-by: Alyssa Ross <hi@alyssa.is> --- crates/vhost/src/vhost_user/connection.rs | 29 ++++++++++------------- - crates/vhost/src/vhost_user/master.rs | 16 +++---------- + crates/vhost/src/vhost_user/frontend.rs | 16 +++---------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/crates/vhost/src/vhost_user/connection.rs b/crates/vhost/src/vhost_user/connection.rs -index 4a62e12..3c308a8 100644 +index 3733584..5eca461 100644 --- a/crates/vhost/src/vhost_user/connection.rs +++ b/crates/vhost/src/vhost_user/connection.rs @@ -551,7 +551,7 @@ impl<R: Req> Endpoint<R> { @@ -81,13 +81,13 @@ index 4a62e12..3c308a8 100644 } } -diff --git a/crates/vhost/src/vhost_user/master.rs b/crates/vhost/src/vhost_user/master.rs -index feeb984..89aec20 100644 ---- a/crates/vhost/src/vhost_user/master.rs -+++ b/crates/vhost/src/vhost_user/master.rs -@@ -673,23 +673,13 @@ impl MasterInternal { +diff --git a/crates/vhost/src/vhost_user/frontend.rs b/crates/vhost/src/vhost_user/frontend.rs +index db6d37e..4068dd6 100644 +--- a/crates/vhost/src/vhost_user/frontend.rs ++++ b/crates/vhost/src/vhost_user/frontend.rs +@@ -677,23 +677,13 @@ impl FrontendInternal { &mut self, - hdr: &VhostUserMsgHeader<MasterReq>, + hdr: &VhostUserMsgHeader<FrontendReq>, ) -> VhostUserResult<(T, Vec<u8>, Option<Vec<File>>)> { - if mem::size_of::<T>() > MAX_MSG_SIZE - || hdr.get_size() as usize <= mem::size_of::<T>() diff --git a/pkgs/cloud-hypervisor/vhost/0002-vhost_user-add-shared-memory-region-support.patch b/pkgs/cloud-hypervisor/vhost/0002-vhost_user-add-shared-memory-region-support.patch index 6448006..6b0bb39 100644 --- a/pkgs/cloud-hypervisor/vhost/0002-vhost_user-add-shared-memory-region-support.patch +++ b/pkgs/cloud-hypervisor/vhost/0002-vhost_user-add-shared-memory-region-support.patch @@ -1,4 +1,4 @@ -From d639bc15129a07a2844b417cb8ead155bf714368 Mon Sep 17 00:00:00 2001 +From 09cbe50dc01c46522f19bf3ab880e978a64a17a3 Mon Sep 17 00:00:00 2001 From: David Stevens <stevensd@chromium.org> Date: Wed, 15 Jun 2022 16:45:12 +0900 Subject: [PATCH 2/4] vhost_user: add shared memory region support @@ -29,16 +29,16 @@ Tested-by: kokoro <noreply+kokoro@google.com> Signed-off-by: Alyssa Ross <alyssa.ross@unikie.com> --- crates/vhost-user-backend/src/handler.rs | 10 +- - crates/vhost/src/vhost_user/dummy_slave.rs | 4 + - crates/vhost/src/vhost_user/master.rs | 25 ++++ - .../src/vhost_user/master_req_handler.rs | 57 ++++++-- + crates/vhost/src/vhost_user/backend_req.rs | 20 ++- + .../src/vhost_user/backend_req_handler.rs | 15 ++ + crates/vhost/src/vhost_user/dummy_backend.rs | 4 + + crates/vhost/src/vhost_user/frontend.rs | 25 ++++ + .../src/vhost_user/frontend_req_handler.rs | 53 ++++++- crates/vhost/src/vhost_user/message.rs | 136 +++++++++++++++++- - crates/vhost/src/vhost_user/slave_req.rs | 20 ++- - .../vhost/src/vhost_user/slave_req_handler.rs | 15 ++ - 7 files changed, 247 insertions(+), 20 deletions(-) + 7 files changed, 247 insertions(+), 16 deletions(-) diff --git a/crates/vhost-user-backend/src/handler.rs b/crates/vhost-user-backend/src/handler.rs -index 262bf6c..73402b2 100644 +index 8be4768..e141e07 100644 --- a/crates/vhost-user-backend/src/handler.rs +++ b/crates/vhost-user-backend/src/handler.rs @@ -11,9 +11,9 @@ use std::sync::Arc; @@ -53,8 +53,8 @@ index 262bf6c..73402b2 100644 + VhostUserVringAddrFlags, VhostUserVringState, }; use vhost::vhost_user::{ - Error as VhostUserError, Result as VhostUserResult, Slave, VhostUserSlaveReqHandlerMut, -@@ -602,6 +602,10 @@ where + Backend, Error as VhostUserError, Result as VhostUserResult, VhostUserBackendReqHandlerMut, +@@ -597,6 +597,10 @@ where Ok(()) } @@ -64,12 +64,100 @@ index 262bf6c..73402b2 100644 + } } - impl<S, V, B: Bitmap> Drop for VhostUserHandler<S, V, B> { -diff --git a/crates/vhost/src/vhost_user/dummy_slave.rs b/crates/vhost/src/vhost_user/dummy_slave.rs -index ae728a0..00a1ae8 100644 ---- a/crates/vhost/src/vhost_user/dummy_slave.rs -+++ b/crates/vhost/src/vhost_user/dummy_slave.rs -@@ -291,4 +291,8 @@ impl VhostUserSlaveReqHandlerMut for DummySlaveReqHandler { + impl<T: VhostUserBackend> Drop for VhostUserHandler<T> { +diff --git a/crates/vhost/src/vhost_user/backend_req.rs b/crates/vhost/src/vhost_user/backend_req.rs +index b43982f..948e1b2 100644 +--- a/crates/vhost/src/vhost_user/backend_req.rs ++++ b/crates/vhost/src/vhost_user/backend_req.rs +@@ -46,12 +46,16 @@ impl BackendInternal { + } + self.sock.send_message(&hdr, body, fds)?; + +- self.wait_for_ack(&hdr) ++ self.wait_for_reply(&hdr) + } + +- fn wait_for_ack(&mut self, hdr: &VhostUserMsgHeader<BackendReq>) -> Result<u64> { ++ fn wait_for_reply(&mut self, hdr: &VhostUserMsgHeader<BackendReq>) -> Result<u64> { + self.check_state()?; +- if !self.reply_ack_negotiated { ++ if !matches!( ++ hdr.get_code(), ++ Ok(BackendReq::SHMEM_MAP | BackendReq::SHMEM_UNMAP) ++ ) && !self.reply_ack_negotiated ++ { + return Ok(0); + } + +@@ -129,6 +133,16 @@ impl Backend { + } + + impl VhostUserFrontendReqHandler for Backend { ++ /// Handle shared memory region mapping requests. ++ fn shmem_map(&self, req: &VhostUserShmemMapMsg, fd: &dyn AsRawFd) -> HandlerResult<u64> { ++ self.send_message(BackendReq::SHMEM_MAP, req, Some(&[fd.as_raw_fd()])) ++ } ++ ++ /// Handle shared memory region unmapping requests. ++ fn shmem_unmap(&self, req: &VhostUserShmemUnmapMsg) -> HandlerResult<u64> { ++ self.send_message(BackendReq::SHMEM_UNMAP, req, None) ++ } ++ + /// Forward vhost-user-fs map file requests to the backend. + fn fs_backend_map(&self, fs: &VhostUserFSBackendMsg, fd: &dyn AsRawFd) -> HandlerResult<u64> { + self.send_message(BackendReq::FS_MAP, fs, Some(&[fd.as_raw_fd()])) +diff --git a/crates/vhost/src/vhost_user/backend_req_handler.rs b/crates/vhost/src/vhost_user/backend_req_handler.rs +index 7b4cbe9..84486aa 100644 +--- a/crates/vhost/src/vhost_user/backend_req_handler.rs ++++ b/crates/vhost/src/vhost_user/backend_req_handler.rs +@@ -70,6 +70,7 @@ pub trait VhostUserBackendReqHandler { + fn get_max_mem_slots(&self) -> Result<u64>; + fn add_mem_region(&self, region: &VhostUserSingleMemoryRegion, fd: File) -> Result<()>; + fn remove_mem_region(&self, region: &VhostUserSingleMemoryRegion) -> Result<()>; ++ fn get_shared_memory_regions(&self) -> Result<Vec<VhostSharedMemoryRegion>>; + } + + /// Services provided to the frontend by the backend without interior mutability. +@@ -118,6 +119,7 @@ pub trait VhostUserBackendReqHandlerMut { + fn get_max_mem_slots(&mut self) -> Result<u64>; + fn add_mem_region(&mut self, region: &VhostUserSingleMemoryRegion, fd: File) -> Result<()>; + fn remove_mem_region(&mut self, region: &VhostUserSingleMemoryRegion) -> Result<()>; ++ fn get_shared_memory_regions(&mut self) -> Result<Vec<VhostSharedMemoryRegion>>; + } + + impl<T: VhostUserBackendReqHandlerMut> VhostUserBackendReqHandler for Mutex<T> { +@@ -226,6 +228,10 @@ impl<T: VhostUserBackendReqHandlerMut> VhostUserBackendReqHandler for Mutex<T> { + fn remove_mem_region(&self, region: &VhostUserSingleMemoryRegion) -> Result<()> { + self.lock().unwrap().remove_mem_region(region) + } ++ ++ fn get_shared_memory_regions(&self) -> Result<Vec<VhostSharedMemoryRegion>> { ++ self.lock().unwrap().get_shared_memory_regions() ++ } + } + + /// Server to handle service requests from frontends from the frontend communication channel. +@@ -519,6 +525,15 @@ impl<S: VhostUserBackendReqHandler> BackendReqHandler<S> { + let res = self.backend.remove_mem_region(&msg); + self.send_ack_message(&hdr, res)?; + } ++ Ok(FrontendReq::GET_SHARED_MEMORY_REGIONS) => { ++ let regions = self.backend.get_shared_memory_regions()?; ++ let mut buf = Vec::new(); ++ let msg = VhostUserU64::new(regions.len() as u64); ++ for r in regions { ++ buf.extend_from_slice(r.as_slice()) ++ } ++ self.send_reply_with_payload(&hdr, &msg, buf.as_slice())?; ++ } + _ => { + return Err(Error::InvalidMessage); + } +diff --git a/crates/vhost/src/vhost_user/dummy_backend.rs b/crates/vhost/src/vhost_user/dummy_backend.rs +index 060a344..aab5ee1 100644 +--- a/crates/vhost/src/vhost_user/dummy_backend.rs ++++ b/crates/vhost/src/vhost_user/dummy_backend.rs +@@ -291,4 +291,8 @@ impl VhostUserBackendReqHandlerMut for DummyBackendReqHandler { fn remove_mem_region(&mut self, _region: &VhostUserSingleMemoryRegion) -> Result<()> { Ok(()) } @@ -78,11 +166,11 @@ index ae728a0..00a1ae8 100644 + Ok(Vec::new()) + } } -diff --git a/crates/vhost/src/vhost_user/master.rs b/crates/vhost/src/vhost_user/master.rs -index 89aec20..6808cb0 100644 ---- a/crates/vhost/src/vhost_user/master.rs -+++ b/crates/vhost/src/vhost_user/master.rs -@@ -72,6 +72,9 @@ pub trait VhostUserMaster: VhostBackend { +diff --git a/crates/vhost/src/vhost_user/frontend.rs b/crates/vhost/src/vhost_user/frontend.rs +index 4068dd6..0d572f3 100644 +--- a/crates/vhost/src/vhost_user/frontend.rs ++++ b/crates/vhost/src/vhost_user/frontend.rs +@@ -72,6 +72,9 @@ pub trait VhostUserFrontend: VhostBackend { /// Remove a guest memory mapping from vhost. fn remove_mem_region(&mut self, region: &VhostUserMemoryRegionInfo) -> Result<()>; @@ -92,14 +180,14 @@ index 89aec20..6808cb0 100644 } fn error_code<T>(err: VhostUserError) -> Result<T> { -@@ -513,6 +516,28 @@ impl VhostUserMaster for Master { - let hdr = node.send_request_with_body(MasterReq::REM_MEM_REG, &body, None)?; +@@ -517,6 +520,28 @@ impl VhostUserFrontend for Frontend { + let hdr = node.send_request_with_body(FrontendReq::REM_MEM_REG, &body, None)?; node.wait_for_ack(&hdr).map_err(|e| e.into()) } + + fn get_shared_memory_regions(&self) -> Result<Vec<VhostSharedMemoryRegion>> { + let mut node = self.node(); -+ let hdr = node.send_request_header(MasterReq::GET_SHARED_MEMORY_REGIONS, None)?; ++ let hdr = node.send_request_header(FrontendReq::GET_SHARED_MEMORY_REGIONS, None)?; + let (body_reply, buf_reply, rfds) = node.recv_reply_with_payload::<VhostUserU64>(&hdr)?; + let struct_size = mem::size_of::<VhostSharedMemoryRegion>(); + if rfds.is_some() || buf_reply.len() != body_reply.value as usize * struct_size { @@ -120,12 +208,12 @@ index 89aec20..6808cb0 100644 + } } - impl AsRawFd for Master { -diff --git a/crates/vhost/src/vhost_user/master_req_handler.rs b/crates/vhost/src/vhost_user/master_req_handler.rs -index c9c528b..3d01542 100644 ---- a/crates/vhost/src/vhost_user/master_req_handler.rs -+++ b/crates/vhost/src/vhost_user/master_req_handler.rs -@@ -33,6 +33,16 @@ pub trait VhostUserMasterReqHandler { + impl AsRawFd for Frontend { +diff --git a/crates/vhost/src/vhost_user/frontend_req_handler.rs b/crates/vhost/src/vhost_user/frontend_req_handler.rs +index fb2dc16..cd4f604 100644 +--- a/crates/vhost/src/vhost_user/frontend_req_handler.rs ++++ b/crates/vhost/src/vhost_user/frontend_req_handler.rs +@@ -33,6 +33,16 @@ pub trait VhostUserFrontendReqHandler { Err(std::io::Error::from_raw_os_error(libc::ENOSYS)) } @@ -140,9 +228,9 @@ index c9c528b..3d01542 100644 + } + /// Handle virtio-fs map file requests. - fn fs_slave_map(&self, _fs: &VhostUserFSSlaveMsg, _fd: &dyn AsRawFd) -> HandlerResult<u64> { + fn fs_backend_map(&self, _fs: &VhostUserFSBackendMsg, _fd: &dyn AsRawFd) -> HandlerResult<u64> { Err(std::io::Error::from_raw_os_error(libc::ENOSYS)) -@@ -66,6 +76,16 @@ pub trait VhostUserMasterReqHandlerMut { +@@ -66,6 +76,16 @@ pub trait VhostUserFrontendReqHandlerMut { Err(std::io::Error::from_raw_os_error(libc::ENOSYS)) } @@ -157,9 +245,9 @@ index c9c528b..3d01542 100644 + } + /// Handle virtio-fs map file requests. - fn fs_slave_map(&mut self, _fs: &VhostUserFSSlaveMsg, _fd: &dyn AsRawFd) -> HandlerResult<u64> { - Err(std::io::Error::from_raw_os_error(libc::ENOSYS)) -@@ -95,6 +115,14 @@ impl<S: VhostUserMasterReqHandlerMut> VhostUserMasterReqHandler for Mutex<S> { + fn fs_backend_map( + &mut self, +@@ -103,6 +123,14 @@ impl<S: VhostUserFrontendReqHandlerMut> VhostUserFrontendReqHandler for Mutex<S> self.lock().unwrap().handle_config_change() } @@ -171,30 +259,30 @@ index c9c528b..3d01542 100644 + self.lock().unwrap().shmem_unmap(req) + } + - fn fs_slave_map(&self, fs: &VhostUserFSSlaveMsg, fd: &dyn AsRawFd) -> HandlerResult<u64> { - self.lock().unwrap().fs_slave_map(fs, fd) + fn fs_backend_map(&self, fs: &VhostUserFSBackendMsg, fd: &dyn AsRawFd) -> HandlerResult<u64> { + self.lock().unwrap().fs_backend_map(fs, fd) } -@@ -222,6 +250,19 @@ impl<S: VhostUserMasterReqHandler> MasterReqHandler<S> { +@@ -230,6 +258,19 @@ impl<S: VhostUserFrontendReqHandler> FrontendReqHandler<S> { .handle_config_change() .map_err(Error::ReqHandlerError) } -+ Ok(SlaveReq::SHMEM_MAP) => { ++ Ok(BackendReq::SHMEM_MAP) => { + let msg = self.extract_msg_body::<VhostUserShmemMapMsg>(&hdr, size, &buf)?; + // check_attached_files() has validated files + self.backend + .shmem_map(&msg, &files.unwrap()[0]) + .map_err(Error::ReqHandlerError) + } -+ Ok(SlaveReq::SHMEM_UNMAP) => { ++ Ok(BackendReq::SHMEM_UNMAP) => { + let msg = self.extract_msg_body::<VhostUserShmemUnmapMsg>(&hdr, size, &buf)?; + self.backend + .shmem_unmap(&msg) + .map_err(Error::ReqHandlerError) + } - Ok(SlaveReq::FS_MAP) => { - let msg = self.extract_msg_body::<VhostUserFSSlaveMsg>(&hdr, size, &buf)?; + Ok(BackendReq::FS_MAP) => { + let msg = self.extract_msg_body::<VhostUserFSBackendMsg>(&hdr, size, &buf)?; // check_attached_files() has validated files -@@ -251,7 +292,7 @@ impl<S: VhostUserMasterReqHandler> MasterReqHandler<S> { +@@ -259,7 +300,7 @@ impl<S: VhostUserFrontendReqHandler> FrontendReqHandler<S> { _ => Err(Error::InvalidMessage), }; @@ -203,39 +291,39 @@ index c9c528b..3d01542 100644 res } -@@ -285,7 +326,7 @@ impl<S: VhostUserMasterReqHandler> MasterReqHandler<S> { +@@ -293,7 +334,7 @@ impl<S: VhostUserFrontendReqHandler> FrontendReqHandler<S> { files: &Option<Vec<File>>, ) -> Result<()> { match hdr.get_code() { -- Ok(SlaveReq::FS_MAP | SlaveReq::FS_IO) => { -+ Ok(SlaveReq::SHMEM_MAP | SlaveReq::FS_MAP | SlaveReq::FS_IO) => { +- Ok(BackendReq::FS_MAP | BackendReq::FS_IO) => { ++ Ok(BackendReq::SHMEM_MAP | BackendReq::FS_MAP | BackendReq::FS_IO) => { // Expect a single file is passed. match files { Some(files) if files.len() == 1 => Ok(()), -@@ -327,12 +368,12 @@ impl<S: VhostUserMasterReqHandler> MasterReqHandler<S> { +@@ -335,12 +376,16 @@ impl<S: VhostUserFrontendReqHandler> FrontendReqHandler<S> { )) } - fn send_ack_message( -- &mut self, -- req: &VhostUserMsgHeader<SlaveReq>, -- res: &Result<u64>, -- ) -> Result<()> { ++ fn send_reply( + &mut self, + req: &VhostUserMsgHeader<BackendReq>, + res: &Result<u64>, + ) -> Result<()> { - if self.reply_ack_negotiated && req.is_need_reply() { -+ fn send_reply(&mut self, req: &VhostUserMsgHeader<SlaveReq>, res: &Result<u64>) -> Result<()> { + if matches!( + req.get_code(), -+ Ok(SlaveReq::SHMEM_MAP | SlaveReq::SHMEM_UNMAP) ++ Ok(BackendReq::SHMEM_MAP | BackendReq::SHMEM_UNMAP) + ) || (self.reply_ack_negotiated && req.is_need_reply()) + { let hdr = self.new_reply_header::<VhostUserU64>(req)?; let def_err = libc::EINVAL; let val = match res { diff --git a/crates/vhost/src/vhost_user/message.rs b/crates/vhost/src/vhost_user/message.rs -index bbd8eb9..be24992 100644 +index df7edcd..21b0943 100644 --- a/crates/vhost/src/vhost_user/message.rs +++ b/crates/vhost/src/vhost_user/message.rs -@@ -146,8 +146,10 @@ pub enum MasterReq { +@@ -146,8 +146,10 @@ pub enum FrontendReq { /// Query the backend for its device status as defined in the VIRTIO /// specification. GET_STATUS = 40, @@ -246,8 +334,8 @@ index bbd8eb9..be24992 100644 + MAX_CMD = 42, } - impl From<MasterReq> for u32 { -@@ -178,16 +180,20 @@ pub enum SlaveReq { + impl From<FrontendReq> for u32 { +@@ -178,16 +180,20 @@ pub enum BackendReq { VRING_CALL = 4, /// Indicate that an error occurred on the specific vring. VRING_ERR = 5, @@ -272,13 +360,13 @@ index bbd8eb9..be24992 100644 + MAX_CMD = 12, } - impl From<SlaveReq> for u32 { -@@ -972,6 +978,99 @@ impl VhostUserMsgValidator for VhostUserFSSlaveMsg { + impl From<BackendReq> for u32 { +@@ -978,6 +984,99 @@ impl VhostUserMsgValidator for VhostUserFSBackendMsg { } } +bitflags! { -+ #[derive(Default)] ++ #[derive(Default, Copy, Clone)] + /// Flags for SHMEM_MAP messages. + pub struct VhostUserShmemMapMsgFlags: u8 { + /// Empty permission. @@ -290,7 +378,7 @@ index bbd8eb9..be24992 100644 + } +} + -+/// Slave request message to map a file into a shared memory region. ++/// Backend request message to map a file into a shared memory region. +#[repr(C, packed)] +#[derive(Default, Copy, Clone)] +pub struct VhostUserShmemMapMsg { @@ -311,7 +399,7 @@ index bbd8eb9..be24992 100644 + +impl VhostUserMsgValidator for VhostUserShmemMapMsg { + fn is_valid(&self) -> bool { -+ (self.flags.bits() & !VhostUserFSSlaveMsgFlags::all().bits() as u8) == 0 ++ (self.flags.bits() & !VhostUserFSBackendMsgFlags::all().bits() as u8) == 0 + && self.fd_offset.checked_add(self.len).is_some() + && self.shm_offset.checked_add(self.len).is_some() + } @@ -337,7 +425,7 @@ index bbd8eb9..be24992 100644 + } +} + -+/// Slave request message to unmap part of a shared memory region. ++/// Backend request message to unmap part of a shared memory region. +#[repr(C, packed)] +#[derive(Default, Copy, Clone)] +pub struct VhostUserShmemUnmapMsg { @@ -373,7 +461,7 @@ index bbd8eb9..be24992 100644 /// Inflight I/O descriptor state for split virtqueues #[repr(packed)] #[derive(Clone, Copy, Default)] -@@ -1103,6 +1202,31 @@ impl QueueRegionPacked { +@@ -1109,6 +1208,31 @@ impl QueueRegionPacked { } } @@ -405,94 +493,6 @@ index bbd8eb9..be24992 100644 #[cfg(test)] mod tests { use super::*; -diff --git a/crates/vhost/src/vhost_user/slave_req.rs b/crates/vhost/src/vhost_user/slave_req.rs -index ade1e91..b7ecd20 100644 ---- a/crates/vhost/src/vhost_user/slave_req.rs -+++ b/crates/vhost/src/vhost_user/slave_req.rs -@@ -46,12 +46,16 @@ impl SlaveInternal { - } - self.sock.send_message(&hdr, body, fds)?; - -- self.wait_for_ack(&hdr) -+ self.wait_for_reply(&hdr) - } - -- fn wait_for_ack(&mut self, hdr: &VhostUserMsgHeader<SlaveReq>) -> Result<u64> { -+ fn wait_for_reply(&mut self, hdr: &VhostUserMsgHeader<SlaveReq>) -> Result<u64> { - self.check_state()?; -- if !self.reply_ack_negotiated { -+ if !matches!( -+ hdr.get_code(), -+ Ok(SlaveReq::SHMEM_MAP | SlaveReq::SHMEM_UNMAP) -+ ) && !self.reply_ack_negotiated -+ { - return Ok(0); - } - -@@ -129,6 +133,16 @@ impl Slave { - } - - impl VhostUserMasterReqHandler for Slave { -+ /// Handle shared memory region mapping requests. -+ fn shmem_map(&self, req: &VhostUserShmemMapMsg, fd: &dyn AsRawFd) -> HandlerResult<u64> { -+ self.send_message(SlaveReq::SHMEM_MAP, req, Some(&[fd.as_raw_fd()])) -+ } -+ -+ /// Handle shared memory region unmapping requests. -+ fn shmem_unmap(&self, req: &VhostUserShmemUnmapMsg) -> HandlerResult<u64> { -+ self.send_message(SlaveReq::SHMEM_UNMAP, req, None) -+ } -+ - /// Forward vhost-user-fs map file requests to the slave. - fn fs_slave_map(&self, fs: &VhostUserFSSlaveMsg, fd: &dyn AsRawFd) -> HandlerResult<u64> { - self.send_message(SlaveReq::FS_MAP, fs, Some(&[fd.as_raw_fd()])) -diff --git a/crates/vhost/src/vhost_user/slave_req_handler.rs b/crates/vhost/src/vhost_user/slave_req_handler.rs -index e998339..b84feca 100644 ---- a/crates/vhost/src/vhost_user/slave_req_handler.rs -+++ b/crates/vhost/src/vhost_user/slave_req_handler.rs -@@ -70,6 +70,7 @@ pub trait VhostUserSlaveReqHandler { - fn get_max_mem_slots(&self) -> Result<u64>; - fn add_mem_region(&self, region: &VhostUserSingleMemoryRegion, fd: File) -> Result<()>; - fn remove_mem_region(&self, region: &VhostUserSingleMemoryRegion) -> Result<()>; -+ fn get_shared_memory_regions(&self) -> Result<Vec<VhostSharedMemoryRegion>>; - } - - /// Services provided to the master by the slave without interior mutability. -@@ -118,6 +119,7 @@ pub trait VhostUserSlaveReqHandlerMut { - fn get_max_mem_slots(&mut self) -> Result<u64>; - fn add_mem_region(&mut self, region: &VhostUserSingleMemoryRegion, fd: File) -> Result<()>; - fn remove_mem_region(&mut self, region: &VhostUserSingleMemoryRegion) -> Result<()>; -+ fn get_shared_memory_regions(&mut self) -> Result<Vec<VhostSharedMemoryRegion>>; - } - - impl<T: VhostUserSlaveReqHandlerMut> VhostUserSlaveReqHandler for Mutex<T> { -@@ -226,6 +228,10 @@ impl<T: VhostUserSlaveReqHandlerMut> VhostUserSlaveReqHandler for Mutex<T> { - fn remove_mem_region(&self, region: &VhostUserSingleMemoryRegion) -> Result<()> { - self.lock().unwrap().remove_mem_region(region) - } -+ -+ fn get_shared_memory_regions(&self) -> Result<Vec<VhostSharedMemoryRegion>> { -+ self.lock().unwrap().get_shared_memory_regions() -+ } - } - - /// Server to handle service requests from masters from the master communication channel. -@@ -519,6 +525,15 @@ impl<S: VhostUserSlaveReqHandler> SlaveReqHandler<S> { - let res = self.backend.remove_mem_region(&msg); - self.send_ack_message(&hdr, res)?; - } -+ Ok(MasterReq::GET_SHARED_MEMORY_REGIONS) => { -+ let regions = self.backend.get_shared_memory_regions()?; -+ let mut buf = Vec::new(); -+ let msg = VhostUserU64::new(regions.len() as u64); -+ for r in regions { -+ buf.extend_from_slice(r.as_slice()) -+ } -+ self.send_reply_with_payload(&hdr, &msg, buf.as_slice())?; -+ } - _ => { - return Err(Error::InvalidMessage); - } -- 2.42.0 diff --git a/pkgs/cloud-hypervisor/vhost/0003-vhost-user-add-protocol-flag-for-shmem.patch b/pkgs/cloud-hypervisor/vhost/0003-vhost-user-add-protocol-flag-for-shmem.patch index 5f4c5d2..f7dcf15 100644 --- a/pkgs/cloud-hypervisor/vhost/0003-vhost-user-add-protocol-flag-for-shmem.patch +++ b/pkgs/cloud-hypervisor/vhost/0003-vhost-user-add-protocol-flag-for-shmem.patch @@ -1,4 +1,4 @@ -From 5ce74080b5846c7183cd0696aab8b5653c0830a7 Mon Sep 17 00:00:00 2001 +From 6ee06aaac2c6d51e993416e81685d6dee120c97d Mon Sep 17 00:00:00 2001 From: David Stevens <stevensd@chromium.org> Date: Thu, 13 Oct 2022 10:37:47 +0900 Subject: [PATCH 3/4] vhost-user: add protocol flag for shmem @@ -25,10 +25,10 @@ Signed-off-by: Alyssa Ross <hi@alyssa.is> 1 file changed, 2 insertions(+) diff --git a/crates/vhost/src/vhost_user/message.rs b/crates/vhost/src/vhost_user/message.rs -index be24992..5fb2fb8 100644 +index 21b0943..6764d6d 100644 --- a/crates/vhost/src/vhost_user/message.rs +++ b/crates/vhost/src/vhost_user/message.rs -@@ -435,6 +435,8 @@ bitflags! { +@@ -437,6 +437,8 @@ bitflags! { const STATUS = 0x0001_0000; /// Support Xen mmap. const XEN_MMAP = 0x0002_0000; diff --git a/pkgs/cloud-hypervisor/vhost/0004-vmm_vhost-renumber-SHARED_MEMORY_REGIONS.patch b/pkgs/cloud-hypervisor/vhost/0004-vmm_vhost-renumber-SHARED_MEMORY_REGIONS.patch index 018c11e..34533cd 100644 --- a/pkgs/cloud-hypervisor/vhost/0004-vmm_vhost-renumber-SHARED_MEMORY_REGIONS.patch +++ b/pkgs/cloud-hypervisor/vhost/0004-vmm_vhost-renumber-SHARED_MEMORY_REGIONS.patch @@ -1,4 +1,4 @@ -From ca160417c77eaf0b70f53568b34917c16a72e25a Mon Sep 17 00:00:00 2001 +From da75b10ab1512d215a7c2ff6c439601547a8217c Mon Sep 17 00:00:00 2001 From: Alyssa Ross <hi@alyssa.is> Date: Sat, 29 Jul 2023 12:03:18 +0000 Subject: [PATCH 4/4] vmm_vhost: renumber SHARED_MEMORY_REGIONS @@ -29,10 +29,10 @@ Signed-off-by: Alyssa Ross <hi@alyssa.is> 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/vhost/src/vhost_user/message.rs b/crates/vhost/src/vhost_user/message.rs -index 5fb2fb8..8ea19d3 100644 +index 6764d6d..0be6b1a 100644 --- a/crates/vhost/src/vhost_user/message.rs +++ b/crates/vhost/src/vhost_user/message.rs -@@ -435,8 +435,8 @@ bitflags! { +@@ -437,8 +437,8 @@ bitflags! { const STATUS = 0x0001_0000; /// Support Xen mmap. const XEN_MMAP = 0x0002_0000; |