Merge pull request #10780 from RuoqingHe/setup-dragonball-workspace

dragonball: Appease clippy, setup workspace and centralize RustVMM
This commit is contained in:
Xuewei Niu 2025-02-21 14:04:19 +08:00 committed by GitHub
commit cdb29a4fd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
209 changed files with 202 additions and 123 deletions

View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "addr2line"
@ -265,6 +265,13 @@ dependencies = [
"typenum",
]
[[package]]
name = "dbs-acpi"
version = "0.1.0"
dependencies = [
"vm-memory",
]
[[package]]
name = "dbs-address-space"
version = "0.3.0"
@ -303,6 +310,8 @@ name = "dbs-boot"
version = "0.4.0"
dependencies = [
"dbs-arch",
"dbs-device",
"device_tree",
"kvm-bindings",
"kvm-ioctls",
"lazy_static",
@ -350,6 +359,7 @@ version = "0.1.0"
dependencies = [
"byteorder",
"dbs-allocator",
"dbs-arch",
"dbs-boot",
"dbs-device",
"dbs-interrupt",
@ -364,6 +374,16 @@ dependencies = [
"vm-memory",
]
[[package]]
name = "dbs-tdx"
version = "0.1.0"
dependencies = [
"kvm-bindings",
"serde_json",
"thiserror",
"vmm-sys-util",
]
[[package]]
name = "dbs-upcall"
version = "0.3.0"
@ -385,6 +405,7 @@ dependencies = [
"libc",
"log",
"serde",
"serde_json",
"thiserror",
"timerfd",
"vmm-sys-util",
@ -446,6 +467,12 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "device_tree"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f18f717c5c7c2e3483feb64cccebd077245ad6d19007c2db0fd341d38595353c"
[[package]]
name = "digest"
version = "0.10.7"

View File

@ -9,34 +9,68 @@ repository = "https://github.com/kata-containers/kata-containers.git"
license = "Apache-2.0"
edition = "2018"
[workspace]
members = [
"dbs_acpi",
"dbs_address_space",
"dbs_allocator",
"dbs_arch",
"dbs_boot",
"dbs_device",
"dbs_interrupt",
"dbs_legacy_devices",
"dbs_pci",
"dbs_tdx",
"dbs_upcall",
"dbs_utils",
"dbs_virtio_devices",
]
resolver = "2"
# Rust-VMM crates
[workspace.dependencies]
event-manager = "0.2.1"
kvm-bindings = "0.6.0"
kvm-ioctls = "0.12.0"
linux-loader = "0.8.0"
seccompiler = "0.2.0"
vfio-bindings = "0.3.0"
vfio-ioctls = "0.1.0"
virtio-bindings = "0.1.0"
virtio-queue = "0.7.0"
vm-fdt = "0.2.0"
vm-memory = "0.10.0"
vm-superio = "0.5.0"
vmm-sys-util = "0.11.0"
[dependencies]
anyhow = "1.0.32"
arc-swap = "1.5.0"
bytes = "1.1.0"
dbs-address-space = { path = "./src/dbs_address_space" }
dbs-allocator = { path = "./src/dbs_allocator" }
dbs-arch = { path = "./src/dbs_arch" }
dbs-boot = { path = "./src/dbs_boot" }
dbs-device = { path = "./src/dbs_device" }
dbs-interrupt = { path = "./src/dbs_interrupt", features = ["kvm-irq"] }
dbs-legacy-devices = { path = "./src/dbs_legacy_devices" }
dbs-upcall = { path = "./src/dbs_upcall", optional = true }
dbs-utils = { path = "./src/dbs_utils" }
dbs-virtio-devices = { path = "./src/dbs_virtio_devices", optional = true, features = [
"virtio-mmio",
dbs-address-space = { path = "dbs_address_space" }
dbs-allocator = { path = "dbs_allocator" }
dbs-arch = { path = "dbs_arch" }
dbs-boot = { path = "dbs_boot" }
dbs-device = { path = "dbs_device" }
dbs-interrupt = { path = "dbs_interrupt", features = ["kvm-irq"] }
dbs-legacy-devices = { path = "dbs_legacy_devices" }
dbs-upcall = { path = "dbs_upcall", optional = true }
dbs-utils = { path = "dbs_utils" }
dbs-virtio-devices = { path = "dbs_virtio_devices", optional = true, features = [
"virtio-mmio",
] }
dbs-pci = { path = "./src/dbs_pci", optional = true }
dbs-pci = { path = "dbs_pci", optional = true }
derivative = "2.2.0"
kvm-bindings = "0.6.0"
kvm-ioctls = "0.12.0"
kvm-bindings = { workspace = true }
kvm-ioctls = { workspace = true }
lazy_static = "1.2"
libc = "0.2.39"
linux-loader = "0.8.0"
linux-loader = {workspace = true}
log = "0.4.14"
nix = "0.24.2"
procfs = "0.12.0"
prometheus = { version = "0.13.0", features = ["process"] }
seccompiler = "0.2.0"
seccompiler = {workspace = true}
serde = "1.0.27"
serde_derive = "1.0.27"
serde_json = "1.0.9"
@ -44,13 +78,13 @@ slog = "2.5.2"
slog-scope = "4.4.0"
thiserror = "1"
tracing = "0.1.37"
vmm-sys-util = "0.11.0"
virtio-queue = { version = "0.7.0", optional = true }
vm-memory = { version = "0.10.0", features = ["backend-mmap"] }
vmm-sys-util = {workspace = true}
virtio-queue = { workspace = true, optional = true }
vm-memory = { workspace = true, features = ["backend-mmap"] }
crossbeam-channel = "0.5.6"
fuse-backend-rs = "0.10.5"
vfio-bindings = { version = "0.3.0", optional = true }
vfio-ioctls = { version = "0.1.0", optional = true }
vfio-bindings = { workspace = true, optional = true }
vfio-ioctls = { workspace = true, optional = true }
[dev-dependencies]
slog-async = "2.7.0"

View File

@ -35,7 +35,7 @@ vendor:
format:
@echo "INFO: rust fmt..."
# This is kinda dirty step here simply because cargo fmt --all will apply fmt to all dependencies of dragonball which will include /src/libs/protocols with some file generated during compilation time and could not be formatted when you use cargo fmt --all before building the whole project. In order to avoid this problem, we do fmt check in this following way.
rustfmt --edition 2018 ./src/dbs_address_space/src/lib.rs ./src/dbs_allocator/src/lib.rs ./src/dbs_arch/src/lib.rs ./src/dbs_boot/src/lib.rs ./src/dbs_device/src/lib.rs ./src/dbs_interrupt/src/lib.rs ./src/dbs_legacy_devices/src/lib.rs ./src/dbs_pci/src/lib.rs ./src/dbs_upcall/src/lib.rs ./src/dbs_utils/src/lib.rs ./src/dbs_virtio_devices/src/lib.rs ./src/lib.rs --check
rustfmt --edition 2018 ./dbs_address_space/src/lib.rs ./dbs_allocator/src/lib.rs ./dbs_arch/src/lib.rs ./dbs_boot/src/lib.rs ./dbs_device/src/lib.rs ./dbs_interrupt/src/lib.rs ./dbs_legacy_devices/src/lib.rs ./dbs_pci/src/lib.rs ./dbs_upcall/src/lib.rs ./dbs_utils/src/lib.rs ./dbs_virtio_devices/src/lib.rs ./src/lib.rs --check
clean:
cargo clean

View File

@ -20,19 +20,19 @@ and configuration process.
- vCPU: [vCPU Document](docs/vcpu.md)
- API: [API Document](docs/api.md)
- `Upcall`: [`Upcall` Document](docs/upcall.md)
- `dbs_acpi`: [`dbs_acpi` Document](src/dbs_acpi/README.md)
- `dbs_address_space`: [`dbs_address_space` Document](src/dbs_address_space/README.md)
- `dbs_allocator`: [`dbs_allocator` Document](src/dbs_allocator/README.md)
- `dbs_arch`: [`dbs_arch` Document](src/dbs_arch/README.md)
- `dbs_boot`: [`dbs_boot` Document](src/dbs_boot/README.md)
- `dbs_device`: [`dbs_device` Document](src/dbs_device/README.md)
- `dbs_interrupt`: [`dbs_interrput` Document](src/dbs_interrupt/README.md)
- `dbs_legacy_devices`: [`dbs_legacy_devices` Document](src/dbs_legacy_devices/README.md)
- `dbs_tdx`: [`dbs_tdx` Document](src/dbs_tdx/README.md)
- `dbs_upcall`: [`dbs_upcall` Document](src/dbs_upcall/README.md)
- `dbs_utils`: [`dbs_utils` Document](src/dbs_utils/README.md)
- `dbs_virtio_devices`: [`dbs_virtio_devices` Document](src/dbs_virtio_devices/README.md)
- `dbs_pci`: [`dbc_pci` Document](src/dbs_pci/README.md)
- `dbs_acpi`: [`dbs_acpi` Document](dbs_acpi/README.md)
- `dbs_address_space`: [`dbs_address_space` Document](dbs_address_space/README.md)
- `dbs_allocator`: [`dbs_allocator` Document](dbs_allocator/README.md)
- `dbs_arch`: [`dbs_arch` Document](dbs_arch/README.md)
- `dbs_boot`: [`dbs_boot` Document](dbs_boot/README.md)
- `dbs_device`: [`dbs_device` Document](dbs_device/README.md)
- `dbs_interrupt`: [`dbs_interrput` Document](dbs_interrupt/README.md)
- `dbs_legacy_devices`: [`dbs_legacy_devices` Document](dbs_legacy_devices/README.md)
- `dbs_tdx`: [`dbs_tdx` Document](dbs_tdx/README.md)
- `dbs_upcall`: [`dbs_upcall` Document](dbs_upcall/README.md)
- `dbs_utils`: [`dbs_utils` Document](dbs_utils/README.md)
- `dbs_virtio_devices`: [`dbs_virtio_devices` Document](dbs_virtio_devices/README.md)
- `dbs_pci`: [`dbc_pci` Document](dbs_pci/README.md)
Currently, the documents are still actively adding.
You could see the [official documentation](docs/) page for more details.

View File

@ -11,4 +11,4 @@ keywords = ["dragonball", "acpi", "vmm", "secure-sandbox"]
readme = "README.md"
[dependencies]
vm-memory = "0.9.0"
vm-memory = {workspace = true}

View File

@ -16,5 +16,5 @@ libc = "0.2.39"
nix = "0.23.1"
lazy_static = "1"
thiserror = "1"
vmm-sys-util = "0.11.0"
vm-memory = { version = "0.10", features = ["backend-mmap", "backend-atomic"] }
vmm-sys-util = {workspace = true}
vm-memory = { workspace = true, features = ["backend-mmap", "backend-atomic"] }

View File

@ -0,0 +1 @@
../LICENSE

View File

@ -223,6 +223,7 @@ impl AddressSpaceRegion {
.read(true)
.write(true)
.create(true)
.truncate(true)
.open(mem_file_path)
.map_err(AddressSpaceError::OpenFile)?;
nix::unistd::unlink(mem_file_path).map_err(AddressSpaceError::UnlinkFile)?;

View File

@ -0,0 +1 @@
../LICENSE

View File

@ -93,7 +93,7 @@ impl Range {
{
let umin = u64::from(base);
let umax = u64::from(size).checked_add(umin).unwrap();
if umin > umax || (umin == 0 && umax == std::u64::MAX) {
if umin > umax || (umin == 0 && umax == u64::MAX) {
panic!("interval_tree: Range({}, {}) is invalid", umin, umax);
}
Range {
@ -910,7 +910,7 @@ impl<T> IntervalTree<T> {
}
}
}
if range.max < std::u64::MAX {
if range.max < u64::MAX {
if let Some((r, v)) = self.get_superset(&Range::new(range.max + 1, range.max + 1)) {
if v.is_free() {
range.max = r.max;

View File

@ -12,15 +12,15 @@ readme = "README.md"
[dependencies]
memoffset = "0.6"
kvm-bindings = { version = "0.6.0", features = ["fam-wrappers"] }
kvm-ioctls = "0.12.0"
kvm-bindings = { workspace = true, features = ["fam-wrappers"] }
kvm-ioctls = {workspace = true}
thiserror = "1"
vm-memory = { version = "0.10" }
vmm-sys-util = "0.11.0"
vm-memory = { workspace = true }
vmm-sys-util = {workspace = true}
libc = ">=0.2.39"
[dev-dependencies]
vm-memory = { version = "0.10", features = ["backend-mmap"] }
vm-memory = { workspace = true, features = ["backend-mmap"] }
[package.metadata.docs.rs]
all-features = true

View File

@ -0,0 +1 @@
../LICENSE

View File

@ -0,0 +1 @@
../THIRD-PARTY

View File

@ -119,6 +119,7 @@ pub fn update_extended_topology_entry(
/// topology enumeration data. Software must detect the presence of CPUID leaf 1FH by verifying
/// - the highest leaf index supported by CPUID is >= 1FH
/// - CPUID.1FH:EBX[15:0] reports a non-zero value
///
/// If leaf_0x1f is not implemented in cpu used in host, guest OS should turn to leaf_0xb to
/// determine the cpu topology.
pub fn update_extended_topology_v2_entry(

View File

@ -12,15 +12,15 @@ readme = "README.md"
[dependencies]
dbs-arch = { path = "../dbs_arch" }
kvm-bindings = { version = "0.6.0", features = ["fam-wrappers"] }
kvm-ioctls = "0.12.0"
kvm-bindings = { workspace = true, features = ["fam-wrappers"] }
kvm-ioctls = {workspace = true}
lazy_static = "1"
libc = "0.2.39"
thiserror = "1"
vm-memory = "0.10.0"
vm-fdt = "0.2.0"
vm-memory = {workspace = true}
vm-fdt = {workspace= true}
[dev-dependencies]
vm-memory = { version = "0.10.0", features = ["backend-mmap"] }
vm-memory = { workspace = true, features = ["backend-mmap"] }
device_tree = ">=1.1.0"
dbs-device = { path = "../dbs_device" }

View File

@ -0,0 +1 @@
../LICENSE

View File

@ -0,0 +1 @@
../THIRD-PARTY

View File

@ -133,8 +133,8 @@ const MPC_SPEC: i8 = 4;
const MPC_OEM: [c_char; 8] = char_array!(c_char; 'A', 'L', 'I', 'C', 'L', 'O', 'U', 'D');
const MPC_PRODUCT_ID: [c_char; 12] =
char_array!(c_char; 'D', 'R', 'A', 'G', 'O', 'N', 'B', 'A', 'L', 'L', '1', '0');
const BUS_TYPE_ISA: [u8; 6] = char_array!(u8; 'I', 'S', 'A', ' ', ' ', ' ');
const BUS_TYPE_PCI: [u8; 6] = char_array!(u8; 'P', 'C', 'I', ' ', ' ', ' ');
const BUS_TYPE_ISA: [u8; 6] = char_array!(u8; b'I', b'S', b'A', b' ', b' ', b' ');
const BUS_TYPE_PCI: [u8; 6] = char_array!(u8; b'P', b'C', b'I', b' ', b' ', b' ');
const IO_APIC_DEFAULT_PHYS_BASE: u32 = 0xfec0_0000; // source: linux/arch/x86/include/asm/apicdef.h
const APIC_DEFAULT_PHYS_BASE: u32 = 0xfee0_0000; // source: linux/arch/x86/include/asm/apicdef.h

View File

@ -0,0 +1 @@
../LICENSE

View File

@ -107,7 +107,7 @@ impl TryFrom<IoSize> for PioSize {
#[inline]
fn try_from(size: IoSize) -> Result<Self, Self::Error> {
if size.raw_value() <= std::u16::MAX as u64 {
if size.raw_value() <= u16::MAX as u64 {
Ok(PioSize(size.raw_value() as PioAddressType))
} else {
Err(size)
@ -153,7 +153,7 @@ impl TryFrom<IoAddress> for PioAddress {
#[inline]
fn try_from(addr: IoAddress) -> Result<Self, Self::Error> {
if addr.0 <= std::u16::MAX as u64 {
if addr.0 <= u16::MAX as u64 {
Ok(PioAddress(addr.raw_value() as PioAddressType))
} else {
Err(addr)

View File

@ -13,10 +13,10 @@ readme = "README.md"
[dependencies]
dbs-device = { path = "../dbs_device" }
dbs-arch = { path = "../dbs_arch" }
kvm-bindings = { version = "0.6.0", optional = true }
kvm-ioctls = { version = "0.12.0", optional = true }
kvm-bindings = { workspace = true, optional = true }
kvm-ioctls = { workspace = true, optional = true }
libc = "0.2"
vmm-sys-util = "0.11.0"
vmm-sys-util = {workspace = true}
[features]
default = ["legacy-irq", "msi-irq"]

View File

@ -0,0 +1 @@
../LICENSE

View File

@ -16,8 +16,8 @@ dbs-utils = { path = "../dbs_utils" }
libc = "0.2.39"
log = "0.4.14"
serde = { version = "1.0.27", features = ["derive", "rc"] }
vm-superio = "0.5.0"
vmm-sys-util = "0.11.0"
vm-superio = {workspace = true}
vmm-sys-util = {workspace = true}
[dev-dependencies]
libc = "0.2.39"

View File

@ -0,0 +1 @@
../LICENSE

View File

@ -0,0 +1 @@
../THIRD-PARTY

View File

@ -23,16 +23,16 @@ dbs-interrupt = { path = "../dbs_interrupt", features = [
] }
downcast-rs = "1.2.0"
byteorder = "1.4.3"
vm-memory = "0.10.0"
kvm-ioctls = "0.12.0"
kvm-bindings = "0.6.0"
vfio-ioctls = "0.1.0"
vfio-bindings = "0.3.0"
vm-memory = {workspace = true}
kvm-ioctls = {workspace = true}
kvm-bindings = {workspace = true}
vfio-ioctls = {workspace = true}
vfio-bindings = {workspace = true}
libc = "0.2.39"
[dev-dependencies]
dbs-arch = { path = "../dbs_arch" }
kvm-ioctls = "0.12.0"
kvm-ioctls = {workspace = true}
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [

View File

@ -4,11 +4,11 @@
`dbs-pci` is a crate for emulating PCI device.
There are several components in `dbs-pci` crate building together to emulate PCI device behaviour :
There are several components in `dbs-pci` crate building together to emulate PCI device behavior :
1. device mod: mainly provide the trait for `PciDevice`, providing the ability to get id, write PCI configuration space, read PCI configuration space and `as_any` to downcast the trait object to the actual device type.
2. configuration mod: simulate PCI device configuration header and manage PCI Bar configuration. The PCI Specification defines the organization of the 256-byte Configuration Space registers and imposes a specific template for the space. The first 64 bytes of configuration space are standardised as configuration space header.
2. configuration mod: simulate PCI device configuration header and manage PCI Bar configuration. The PCI Specification defines the organization of the 256-byte Configuration Space registers and imposes a specific template for the space. The first 64 bytes of configuration space are standardized as configuration space header.
3. bus mod: simulate PCI buses, to simplify the implementation, PCI hierarchy is not supported. So all PCI devices are directly connected to the PCI root bus. PCI Bus has bus id, PCI devices attached and PCI bus I/O port, I/O mem resource use condition.
@ -16,9 +16,9 @@ There are several components in `dbs-pci` crate building together to emulate PCI
5. root device mod: a pseudo PCI root device to manage accessing to PCI configuration space.
6. `msi` mod: struct to maintain information for PCI Message Signalled Interrupt Capability. It will be initialized when parsing PCI configuration space and used when getting interrupt capabilities.
6. `msi` mod: struct to maintain information for PCI Message Signaled Interrupt Capability. It will be initialized when parsing PCI configuration space and used when getting interrupt capabilities.
7. `msix` mod: struct to maintain information for PCI Message Signalled Interrupt Extended Capability. It will be initialized when parsing PCI configuration space and used when getting interrupt capabilities.
7. `msix` mod: struct to maintain information for PCI Message Signaled Interrupt Extended Capability. It will be initialized when parsing PCI configuration space and used when getting interrupt capabilities.
8. `vfio` mod: `vfio` mod collects lots of information related to the `vfio` operations.
a. `vfio` `msi` and `msix` capability and state

View File

@ -1000,18 +1000,18 @@ impl PciConfiguration {
.ok_or(Error::BarAddressInvalid(config.addr, config.size))?;
match config.bar_type {
PciBarRegionType::IoRegion => {
if config.size < 0x4 || config.size > u64::from(u32::max_value()) {
if config.size < 0x4 || config.size > u64::from(u32::MAX) {
return Err(Error::BarSizeInvalid(config.size));
}
if end_addr > u64::from(u32::max_value()) {
if end_addr > u64::from(u32::MAX) {
return Err(Error::BarAddressInvalid(config.addr, config.size));
}
}
PciBarRegionType::Memory32BitRegion => {
if config.size < 0x10 || config.size > u64::from(u32::max_value()) {
if config.size < 0x10 || config.size > u64::from(u32::MAX) {
return Err(Error::BarSizeInvalid(config.size));
}
if end_addr > u64::from(u32::max_value()) {
if end_addr > u64::from(u32::MAX) {
return Err(Error::BarAddressInvalid(config.addr, config.size));
}
}
@ -1022,9 +1022,6 @@ impl PciConfiguration {
if self.bar_used(config.bar_idx + 1) {
return Err(Error::BarInUse64(config.bar_idx));
}
if end_addr > u64::max_value() {
return Err(Error::BarAddressInvalid(config.addr, config.size));
}
self.registers[reg_idx + 1] = (config.addr >> 32) as u32;
self.writable_bits[reg_idx + 1] = 0xffff_ffff;
@ -1085,7 +1082,7 @@ impl PciConfiguration {
.bitand(!(u64::from(!ROM_BAR_ADDR_MASK)))
.checked_add(config.size - 1)
.ok_or(Error::RomBarAddressInvalid(config.addr, config.size))?;
if end_addr > u64::from(u32::max_value()) {
if end_addr > u64::from(u32::MAX) {
return Err(Error::RomBarAddressInvalid(config.addr, config.size));
}

Some files were not shown because too many files have changed in this diff Show More