build: treewide: fmt for edition 2024

`cargo +nightly fmt`

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2025-08-12 12:59:23 +02:00
committed by Bo Chen
parent 061351d82d
commit 363273111a
121 changed files with 781 additions and 663 deletions

View File

@@ -37,9 +37,9 @@ use vmm_sys_util::eventfd::EventFd;
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;
use crate::{
ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, GuestMemoryMmap,
VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterrupt, VirtioInterruptType,
EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1,
ActivateResult, EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError, EpollHelperHandler,
GuestMemoryMmap, VIRTIO_F_VERSION_1, VirtioCommon, VirtioDevice, VirtioDeviceType,
VirtioInterrupt, VirtioInterruptType,
};
const QUEUE_SIZE: u16 = 128;
@@ -575,12 +575,12 @@ impl VirtioDevice for Balloon {
let data_len = data.len() as u64;
if offset + data_len > config_len {
error!(
"Out-of-bound access to configuration: config_len = {} offset = {:x} length = {} for {}",
config_len,
offset,
data_len,
self.device_type()
);
"Out-of-bound access to configuration: config_len = {} offset = {:x} length = {} for {}",
config_len,
offset,
data_len,
self.device_type()
);
return;
}

View File

@@ -19,12 +19,12 @@ use std::{io, result};
use anyhow::anyhow;
use block::async_io::{AsyncIo, AsyncIoError, DiskFile};
use block::fcntl::{get_lock_state, LockError, LockType};
use block::fcntl::{LockError, LockType, get_lock_state};
use block::{
build_serial, fcntl, ExecuteAsync, ExecuteError, Request, RequestType, VirtioBlockConfig,
ExecuteAsync, ExecuteError, Request, RequestType, VirtioBlockConfig, build_serial, fcntl,
};
use rate_limiter::group::{RateLimiterGroup, RateLimiterGroupHandle};
use rate_limiter::TokenType;
use rate_limiter::group::{RateLimiterGroup, RateLimiterGroupHandle};
use seccompiler::SeccompAction;
use serde::{Deserialize, Serialize};
use thiserror::Error;
@@ -38,9 +38,9 @@ use vm_virtio::AccessPlatform;
use vmm_sys_util::eventfd::EventFd;
use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
Error as DeviceError, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterruptType,
EPOLL_HELPER_EVENT_LAST,
ActivateError, ActivateResult, EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError,
EpollHelperHandler, Error as DeviceError, VirtioCommon, VirtioDevice, VirtioDeviceType,
VirtioInterruptType,
};
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;

View File

@@ -22,9 +22,9 @@ use vm_virtio::{AccessPlatform, Translatable};
use vmm_sys_util::eventfd::EventFd;
use super::{
ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, Error as DeviceError,
VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterruptType, EPOLL_HELPER_EVENT_LAST,
VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1,
ActivateResult, EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError, EpollHelperHandler,
Error as DeviceError, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1, VirtioCommon, VirtioDevice,
VirtioDeviceType, VirtioInterruptType,
};
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;

View File

@@ -24,8 +24,8 @@ use vm_virtio::AccessPlatform;
use vmm_sys_util::eventfd::EventFd;
use super::{
ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, Error as DeviceError,
VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_VERSION_1,
ActivateResult, EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError, EpollHelperHandler,
Error as DeviceError, VIRTIO_F_VERSION_1, VirtioCommon, VirtioDevice, VirtioDeviceType,
};
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;

View File

@@ -51,10 +51,10 @@ pub use self::device::{
VirtioSharedMemoryList,
};
pub use self::epoll_helper::{
EpollHelper, EpollHelperError, EpollHelperHandler, EPOLL_HELPER_EVENT_LAST,
EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError, EpollHelperHandler,
};
pub use self::iommu::{AccessPlatformMapping, Iommu, IommuMapping};
pub use self::mem::{BlocksState, Mem, VirtioMemMappingSource, VIRTIO_MEM_ALIGN_SIZE};
pub use self::mem::{BlocksState, Mem, VIRTIO_MEM_ALIGN_SIZE, VirtioMemMappingSource};
pub use self::net::{Net, NetCtrlEpollHandler};
pub use self::pmem::Pmem;
pub use self::rng::Rng;

View File

@@ -18,7 +18,7 @@ use std::collections::BTreeMap;
use std::mem::size_of;
use std::os::unix::io::{AsRawFd, RawFd};
use std::sync::atomic::AtomicBool;
use std::sync::{mpsc, Arc, Barrier, Mutex};
use std::sync::{Arc, Barrier, Mutex, mpsc};
use std::{io, result};
use anyhow::anyhow;
@@ -36,9 +36,9 @@ use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottabl
use vmm_sys_util::eventfd::EventFd;
use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
Error as DeviceError, VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST,
VIRTIO_F_VERSION_1,
ActivateError, ActivateResult, EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError,
EpollHelperHandler, Error as DeviceError, VIRTIO_F_VERSION_1, VirtioCommon, VirtioDevice,
VirtioDeviceType,
};
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;

View File

@@ -18,8 +18,8 @@ use anyhow::anyhow;
#[cfg(not(fuzzing))]
use net_util::virtio_features_to_tap_offload;
use net_util::{
build_net_config_space, build_net_config_space_with_mq, open_tap, CtrlQueue, MacAddr,
NetCounters, NetQueuePair, OpenTapError, RxVirtio, Tap, TapError, TxVirtio, VirtioNetConfig,
CtrlQueue, MacAddr, NetCounters, NetQueuePair, OpenTapError, RxVirtio, Tap, TapError, TxVirtio,
VirtioNetConfig, build_net_config_space, build_net_config_space_with_mq, open_tap,
};
use seccompiler::SeccompAction;
use serde::{Deserialize, Serialize};
@@ -34,9 +34,9 @@ use vm_virtio::AccessPlatform;
use vmm_sys_util::eventfd::EventFd;
use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
Error as DeviceError, RateLimiterConfig, VirtioCommon, VirtioDevice, VirtioDeviceType,
VirtioInterruptType, EPOLL_HELPER_EVENT_LAST,
ActivateError, ActivateResult, EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError,
EpollHelperHandler, Error as DeviceError, RateLimiterConfig, VirtioCommon, VirtioDevice,
VirtioDeviceType, VirtioInterruptType,
};
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;

View File

@@ -28,9 +28,9 @@ use vm_virtio::{AccessPlatform, Translatable};
use vmm_sys_util::eventfd::EventFd;
use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
Error as DeviceError, VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST,
VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1,
ActivateError, ActivateResult, EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError,
EpollHelperHandler, Error as DeviceError, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1,
VirtioCommon, VirtioDevice, VirtioDeviceType,
};
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;

View File

@@ -21,9 +21,9 @@ use vm_virtio::{AccessPlatform, Translatable};
use vmm_sys_util::eventfd::EventFd;
use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
Error as DeviceError, VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST,
VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1,
ActivateError, ActivateResult, EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError,
EpollHelperHandler, Error as DeviceError, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1,
VirtioCommon, VirtioDevice, VirtioDeviceType,
};
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;

View File

@@ -53,13 +53,15 @@ const VFIO_IOMMU_UNMAP_DMA: u64 = 0x3b72;
#[cfg(feature = "sev_snp")]
fn mshv_sev_snp_ioctl_seccomp_rule() -> SeccompRule {
and![Cond::new(
1,
ArgLen::Dword,
Eq,
mshv_ioctls::MSHV_MODIFY_GPA_HOST_ACCESS()
)
.unwrap()]
and![
Cond::new(
1,
ArgLen::Dword,
Eq,
mshv_ioctls::MSHV_MODIFY_GPA_HOST_ACCESS()
)
.unwrap()
]
}
#[cfg(feature = "sev_snp")]

View File

@@ -6,12 +6,12 @@
use std::panic::AssertUnwindSafe;
use std::thread::{self, JoinHandle};
use seccompiler::{apply_filter, SeccompAction};
use seccompiler::{SeccompAction, apply_filter};
use vmm_sys_util::eventfd::EventFd;
use crate::epoll_helper::EpollHelperError;
use crate::seccomp_filters::{get_seccomp_filter, Thread};
use crate::ActivateError;
use crate::epoll_helper::EpollHelperError;
use crate::seccomp_filters::{Thread, get_seccomp_filter};
pub(crate) fn spawn_virtio_thread<F>(
name: &str,

View File

@@ -5,7 +5,7 @@
use vmm_sys_util::eventfd::EventFd;
mod pci_common_config;
mod pci_device;
pub use pci_common_config::{VirtioPciCommonConfig, VIRTIO_PCI_COMMON_CONFIG_ID};
pub use pci_common_config::{VIRTIO_PCI_COMMON_CONFIG_ID, VirtioPciCommonConfig};
pub use pci_device::{VirtioPciDevice, VirtioPciDeviceActivator, VirtioPciDeviceError};
pub trait VirtioTransport {

View File

@@ -35,11 +35,11 @@ use vm_virtio::AccessPlatform;
use vmm_sys_util::eventfd::EventFd;
use super::pci_common_config::VirtioPciCommonConfigState;
use crate::transport::{VirtioPciCommonConfig, VirtioTransport, VIRTIO_PCI_COMMON_CONFIG_ID};
use crate::transport::{VIRTIO_PCI_COMMON_CONFIG_ID, VirtioPciCommonConfig, VirtioTransport};
use crate::{
ActivateResult, GuestMemoryMmap, VirtioDevice, VirtioDeviceType, VirtioInterrupt,
VirtioInterruptType, DEVICE_ACKNOWLEDGE, DEVICE_DRIVER, DEVICE_DRIVER_OK, DEVICE_FAILED,
DEVICE_FEATURES_OK, DEVICE_INIT,
ActivateResult, DEVICE_ACKNOWLEDGE, DEVICE_DRIVER, DEVICE_DRIVER_OK, DEVICE_FAILED,
DEVICE_FEATURES_OK, DEVICE_INIT, GuestMemoryMmap, VirtioDevice, VirtioDeviceType,
VirtioInterrupt, VirtioInterruptType,
};
/// Vector value used to disable MSI for a queue.
@@ -973,7 +973,7 @@ impl PciDevice for VirtioPciDevice {
settings_bar_addr = Some(GuestAddress(base));
use_64bit_bar = match type_ {
PciBarType::Io => {
return Err(PciDeviceError::InvalidResource(resource))
return Err(PciDeviceError::InvalidResource(resource));
}
PciBarType::Mmio32 => false,
PciBarType::Mmio64 => true,

View File

@@ -12,9 +12,9 @@ use anyhow::anyhow;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use vhost::vdpa::{VhostVdpa, VhostVdpaIovaRange};
use vhost::vhost_kern::VhostKernFeatures;
use vhost::vhost_kern::vdpa::VhostKernVdpa;
use vhost::vhost_kern::vhost_binding::VHOST_BACKEND_F_SUSPEND;
use vhost::vhost_kern::VhostKernFeatures;
use vhost::{VhostBackend, VringConfigData};
use virtio_queue::desc::RawDescriptor;
use virtio_queue::{Queue, QueueT};
@@ -25,9 +25,9 @@ use vm_virtio::{AccessPlatform, Translatable};
use vmm_sys_util::eventfd::EventFd;
use crate::{
ActivateError, ActivateResult, GuestMemoryMmap, VirtioCommon, VirtioDevice, VirtioInterrupt,
VirtioInterruptType, DEVICE_ACKNOWLEDGE, DEVICE_DRIVER, DEVICE_DRIVER_OK, DEVICE_FEATURES_OK,
VIRTIO_F_IOMMU_PLATFORM,
ActivateError, ActivateResult, DEVICE_ACKNOWLEDGE, DEVICE_DRIVER, DEVICE_DRIVER_OK,
DEVICE_FEATURES_OK, GuestMemoryMmap, VIRTIO_F_IOMMU_PLATFORM, VirtioCommon, VirtioDevice,
VirtioInterrupt, VirtioInterruptType,
};
#[derive(Error, Debug)]

View File

@@ -9,8 +9,8 @@ use block::VirtioBlockConfig;
use seccompiler::SeccompAction;
use serde::{Deserialize, Serialize};
use vhost::vhost_user::message::{
VhostUserConfigFlags, VhostUserProtocolFeatures, VhostUserVirtioFeatures,
VHOST_USER_CONFIG_OFFSET,
VHOST_USER_CONFIG_OFFSET, VhostUserConfigFlags, VhostUserProtocolFeatures,
VhostUserVirtioFeatures,
};
use vhost::vhost_user::{FrontendReqHandler, VhostUserFrontend, VhostUserFrontendReqHandler};
use virtio_bindings::virtio_blk::{
@@ -26,11 +26,11 @@ use vmm_sys_util::eventfd::EventFd;
use super::super::{ActivateResult, VirtioCommon, VirtioDevice, VirtioDeviceType};
use super::vu_common_ctrl::{VhostUserConfig, VhostUserHandle};
use super::{Error, Result, DEFAULT_VIRTIO_FEATURES};
use super::{DEFAULT_VIRTIO_FEATURES, Error, Result};
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;
use crate::vhost_user::VhostUserCommon;
use crate::{GuestMemoryMmap, GuestRegionMmap, VirtioInterrupt, VIRTIO_F_IOMMU_PLATFORM};
use crate::{GuestMemoryMmap, GuestRegionMmap, VIRTIO_F_IOMMU_PLATFORM, VirtioInterrupt};
const DEFAULT_QUEUE_NUMBER: usize = 1;
@@ -134,8 +134,10 @@ impl Blk {
};
if num_queues > backend_num_queues {
error!("vhost-user-blk requested too many queues ({}) since the backend only supports {}\n",
num_queues, backend_num_queues);
error!(
"vhost-user-blk requested too many queues ({}) since the backend only supports {}\n",
num_queues, backend_num_queues
);
return Err(Error::BadQueueNum);
}

View File

@@ -7,7 +7,7 @@ use std::{result, thread};
use seccompiler::SeccompAction;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, Bytes};
use serde_with::{Bytes, serde_as};
use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures};
use vhost::vhost_user::{FrontendReqHandler, VhostUserFrontend, VhostUserFrontendReqHandler};
use virtio_queue::Queue;
@@ -18,13 +18,13 @@ use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottabl
use vmm_sys_util::eventfd::EventFd;
use super::vu_common_ctrl::VhostUserHandle;
use super::{Error, Result, DEFAULT_VIRTIO_FEATURES};
use super::{DEFAULT_VIRTIO_FEATURES, Error, Result};
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;
use crate::vhost_user::VhostUserCommon;
use crate::{
ActivateResult, GuestMemoryMmap, GuestRegionMmap, MmapRegion, VirtioCommon, VirtioDevice,
VirtioDeviceType, VirtioInterrupt, VirtioSharedMemoryList, VIRTIO_F_IOMMU_PLATFORM,
ActivateResult, GuestMemoryMmap, GuestRegionMmap, MmapRegion, VIRTIO_F_IOMMU_PLATFORM,
VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterrupt, VirtioSharedMemoryList,
};
const NUM_QUEUE_OFFSET: usize = 1;
@@ -148,9 +148,9 @@ impl Fs {
if num_queues > backend_num_queues {
error!(
"vhost-user-fs requested too many queues ({}) since the backend only supports {}\n",
num_queues, backend_num_queues
);
"vhost-user-fs requested too many queues ({}) since the backend only supports {}\n",
num_queues, backend_num_queues
);
return Err(Error::BadQueueNum);
}

View File

@@ -10,11 +10,11 @@ use std::sync::{Arc, Barrier, Mutex};
use anyhow::anyhow;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use vhost::Error as VhostError;
use vhost::vhost_user::message::{
VhostUserInflight, VhostUserProtocolFeatures, VhostUserVirtioFeatures,
};
use vhost::vhost_user::{FrontendReqHandler, VhostUserFrontendReqHandler};
use vhost::Error as VhostError;
use virtio_queue::{Error as QueueError, Queue};
use vm_memory::mmap::MmapRegionError;
use vm_memory::{Address, Error as MmapError, GuestAddressSpace, GuestMemory, GuestMemoryAtomic};
@@ -24,10 +24,10 @@ use vmm_sys_util::eventfd::EventFd;
use vu_common_ctrl::VhostUserHandle;
use crate::{
ActivateError, EpollHelper, EpollHelperError, EpollHelperHandler, GuestMemoryMmap,
GuestRegionMmap, VirtioInterrupt, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_IN_ORDER,
VIRTIO_F_NOTIFICATION_DATA, VIRTIO_F_ORDER_PLATFORM, VIRTIO_F_RING_EVENT_IDX,
VIRTIO_F_RING_INDIRECT_DESC, VIRTIO_F_VERSION_1,
ActivateError, EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError, EpollHelperHandler,
GuestMemoryMmap, GuestRegionMmap, VIRTIO_F_IN_ORDER, VIRTIO_F_NOTIFICATION_DATA,
VIRTIO_F_ORDER_PLATFORM, VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_RING_INDIRECT_DESC,
VIRTIO_F_VERSION_1, VirtioInterrupt,
};
pub mod blk;

View File

@@ -5,7 +5,7 @@ use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Barrier, Mutex};
use std::{result, thread};
use net_util::{build_net_config_space, CtrlQueue, MacAddr, VirtioNetConfig};
use net_util::{CtrlQueue, MacAddr, VirtioNetConfig, build_net_config_space};
use seccompiler::SeccompAction;
use serde::{Deserialize, Serialize};
use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures};
@@ -28,9 +28,9 @@ use crate::thread_helper::spawn_virtio_thread;
use crate::vhost_user::vu_common_ctrl::{VhostUserConfig, VhostUserHandle};
use crate::vhost_user::{Error, Result, VhostUserCommon};
use crate::{
ActivateResult, GuestMemoryMmap, GuestRegionMmap, NetCtrlEpollHandler, VirtioCommon,
VirtioDevice, VirtioDeviceType, VirtioInterrupt, VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_VERSION_1,
ActivateResult, GuestMemoryMmap, GuestRegionMmap, NetCtrlEpollHandler, VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_VERSION_1, VirtioCommon, VirtioDevice, VirtioDeviceType,
VirtioInterrupt,
};
const DEFAULT_QUEUE_NUMBER: usize = 2;
@@ -168,8 +168,10 @@ impl Net {
};
if num_queues > backend_num_queues {
error!("vhost-user-net requested too many queues ({}) since the backend only supports {}\n",
num_queues, backend_num_queues);
error!(
"vhost-user-net requested too many queues ({}) since the backend only supports {}\n",
num_queues, backend_num_queues
);
return Err(Error::BadQueueNum);
}

View File

@@ -5,8 +5,8 @@ use std::ffi;
use std::fs::File;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::os::unix::net::UnixListener;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::sync::atomic::Ordering;
use std::thread::sleep;
use std::time::{Duration, Instant};
@@ -29,8 +29,8 @@ use vmm_sys_util::eventfd::EventFd;
use super::{Error, Result};
use crate::vhost_user::Inflight;
use crate::{
get_host_address_range, GuestMemoryMmap, GuestRegionMmap, MmapRegion, VirtioInterrupt,
VirtioInterruptType,
GuestMemoryMmap, GuestRegionMmap, MmapRegion, VirtioInterrupt, VirtioInterruptType,
get_host_address_range,
};
// Size of a dirty page for vhost-user.
@@ -399,7 +399,7 @@ impl VhostUserHandle {
acked_features: 0,
vrings_info: None,
queue_indexes: Vec::new(),
})
});
}
Err(e) => e,
};

View File

@@ -89,7 +89,7 @@ use super::super::defs::uapi;
use super::super::packet::VsockPacket;
use super::super::{Result as VsockResult, VsockChannel, VsockEpollListener, VsockError};
use super::txbuf::TxBuf;
use super::{defs, ConnState, Error, PendingRx, PendingRxSet, Result};
use super::{ConnState, Error, PendingRx, PendingRxSet, Result, defs};
/// A self-managing connection object, that handles communication between a guest-side AF_VSOCK
/// socket and a host-side `Read + Write + AsRawFd` stream.
@@ -1158,10 +1158,11 @@ mod tests {
// When there's data in the TX buffer, the connection should ask to be notified when it
// can write to its backing stream.
assert!(ctx
.conn
.get_polled_evset()
.contains(epoll::Events::EPOLLOUT));
assert!(
ctx.conn
.get_polled_evset()
.contains(epoll::Events::EPOLLOUT)
);
assert_eq!(ctx.conn.tx_buf.len(), data.len());
// Unlock the write stream and notify the connection it can now write its buffered
@@ -1212,10 +1213,11 @@ mod tests {
stream.write_state = StreamState::Closed;
ctx.set_stream(stream);
assert!(ctx
.conn
.get_polled_evset()
.contains(epoll::Events::EPOLLOUT));
assert!(
ctx.conn
.get_polled_evset()
.contains(epoll::Events::EPOLLOUT)
);
ctx.notify_epollout();
assert_eq!(ctx.conn.state, ConnState::Killed);
}

View File

@@ -5,7 +5,7 @@
use std::io::Write;
use std::num::Wrapping;
use super::{defs, Error, Result};
use super::{Error, Result, defs};
/// A simple ring-buffer implementation, used by vsock connections to buffer TX (guest -> host)
/// data. Memory for this buffer is allocated lazily, since buffering will only be needed when

View File

@@ -47,10 +47,10 @@ use super::{VsockBackend, VsockPacket};
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;
use crate::{
ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler, Error as DeviceError,
GuestMemoryMmap, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterrupt,
VirtioInterruptType, EPOLL_HELPER_EVENT_LAST, VIRTIO_F_IN_ORDER, VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_VERSION_1,
ActivateResult, EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError, EpollHelperHandler,
Error as DeviceError, GuestMemoryMmap, VIRTIO_F_IN_ORDER, VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_VERSION_1, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterrupt,
VirtioInterruptType,
};
const QUEUE_SIZE: u16 = 256;

View File

@@ -172,7 +172,7 @@ pub mod tests {
use vm_virtio::queue::testing::VirtQueue as GuestQ;
use vmm_sys_util::eventfd::EventFd;
use super::device::{VsockEpollHandler, RX_QUEUE_EVENT, TX_QUEUE_EVENT};
use super::device::{RX_QUEUE_EVENT, TX_QUEUE_EVENT, VsockEpollHandler};
use super::packet::VSOCK_PKT_HDR_SIZE;
use super::*;
use crate::device::{VirtioInterrupt, VirtioInterruptType};

View File

@@ -24,7 +24,7 @@ use virtio_queue::DescriptorChain;
use vm_memory::{Address, GuestMemory};
use vm_virtio::{AccessPlatform, Translatable};
use super::{defs, Result, VsockError};
use super::{Result, VsockError, defs};
use crate::get_host_address_range;
// The vsock packet header is defined by the C struct:
@@ -427,8 +427,8 @@ mod tests {
use super::super::tests::TestContext;
use super::*;
use crate::vsock::defs::MAX_PKT_BUF_SIZE;
use crate::GuestMemoryMmap;
use crate::vsock::defs::MAX_PKT_BUF_SIZE;
macro_rules! create_context {
($test_ctx:ident, $handler_ctx:ident) => {

View File

@@ -13,9 +13,9 @@ mod muxer;
mod muxer_killq;
mod muxer_rxq;
pub use Error as VsockUnixError;
pub use muxer::VsockMuxer as VsockUnixBackend;
use thiserror::Error;
pub use Error as VsockUnixError;
mod defs {
/// Maximum number of established connections that we can handle.

View File

@@ -52,7 +52,7 @@ use super::super::{
};
use super::muxer_killq::MuxerKillQ;
use super::muxer_rxq::MuxerRxQ;
use super::{defs, Error, MuxerConnection, Result};
use super::{Error, MuxerConnection, Result, defs};
/// A unique identifier of a `MuxerConnection` object. Connections are stored in a hash map,
/// keyed by a `ConnMapKey` object.

View File

@@ -29,7 +29,7 @@ use std::collections::{HashMap, VecDeque};
use std::time::Instant;
use super::muxer::ConnMapKey;
use super::{defs, MuxerConnection};
use super::{MuxerConnection, defs};
/// A kill queue item, holding the connection key and the scheduled time for termination.
///

View File

@@ -20,7 +20,7 @@ use std::collections::{HashMap, VecDeque};
use super::super::VsockChannel;
use super::muxer::{ConnMapKey, MuxerRx};
use super::{defs, MuxerConnection};
use super::{MuxerConnection, defs};
/// The muxer RX queue.
///

View File

@@ -23,9 +23,9 @@ use vm_migration::{Migratable, MigratableError, Pausable, Snapshot, Snapshottabl
use vmm_sys_util::eventfd::EventFd;
use super::{
ActivateError, ActivateResult, EpollHelper, EpollHelperError, EpollHelperHandler,
Error as DeviceError, VirtioCommon, VirtioDevice, VirtioDeviceType, EPOLL_HELPER_EVENT_LAST,
VIRTIO_F_VERSION_1,
ActivateError, ActivateResult, EPOLL_HELPER_EVENT_LAST, EpollHelper, EpollHelperError,
EpollHelperHandler, Error as DeviceError, VIRTIO_F_VERSION_1, VirtioCommon, VirtioDevice,
VirtioDeviceType,
};
use crate::seccomp_filters::Thread;
use crate::thread_helper::spawn_virtio_thread;