Skip to content

Commit 56c573a

Browse files
committed
chore: move KVM architecture-specific state in vmm::arch module
Move KVM architecture-specific code under the `vmm::arch` module, so that we start having all architecture-specific code under a single module. Signed-off-by: Babis Chalios <[email protected]>
1 parent 0ee10bb commit 56c573a

File tree

8 files changed

+20
-11
lines changed

8 files changed

+20
-11
lines changed

src/vmm/src/arch/aarch64/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub mod layout;
1111
pub mod regs;
1212
/// Helper methods for VcpuFd.
1313
pub mod vcpu;
14+
/// Architecture specific microVM state.
15+
pub mod vstate;
1416

1517
use std::cmp::min;
1618
use std::collections::HashMap;
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
/// Architecture specific KVM-related code
5+
pub mod kvm;

src/vmm/src/arch/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use vm_memory::GuestAddress;
1212
#[cfg(target_arch = "aarch64")]
1313
pub mod aarch64;
1414

15+
#[cfg(target_arch = "aarch64")]
16+
pub use aarch64::vstate::kvm::{Kvm, KvmArchError, OptionalCapabilities};
1517
#[cfg(target_arch = "aarch64")]
1618
pub use aarch64::{
1719
ConfigurationError, MMIO_MEM_SIZE, MMIO_MEM_START, arch_memory_regions, configure_system,
@@ -30,6 +32,8 @@ pub use crate::arch::x86_64::{
3032
layout::IOAPIC_ADDR, layout::IRQ_BASE, layout::IRQ_MAX, layout::SYSTEM_MEM_SIZE,
3133
layout::SYSTEM_MEM_START,
3234
};
35+
#[cfg(target_arch = "x86_64")]
36+
pub use x86_64::vstate::kvm::{Kvm, KvmArchError};
3337

3438
/// Types of devices that can get attached to this platform.
3539
#[derive(Clone, Debug, PartialEq, Eq, Hash, Copy, Serialize, Deserialize)]

src/vmm/src/arch/x86_64/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ mod mptable;
1919
pub mod msr;
2020
/// Logic for configuring x86_64 registers.
2121
pub mod regs;
22+
/// Architecture specific microVM state.
23+
pub mod vstate;
2224
/// Logic for configuring XSTATE features.
2325
pub mod xstate;
2426

@@ -221,7 +223,7 @@ fn configure_pvh(
221223
// boot_params. This will be stored at PVH_INFO_START address, and %rbx
222224
// will be initialized to contain PVH_INFO_START prior to starting the
223225
// guest, as required by the PVH ABI.
224-
#[allow(clippy::cast_possible_truncation)] // the vec lenghts are single digit integers
226+
#[allow(clippy::cast_possible_truncation)] // the vec lengths are single digit integers
225227
let mut start_info = hvm_start_info {
226228
magic: XEN_HVM_START_MAGIC_VALUE,
227229
version: 1,
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
/// Architecture specific KVM-related code
5+
pub mod kvm;

src/vmm/src/vstate/kvm/mod.rs renamed to src/vmm/src/vstate/kvm.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,10 @@ use kvm_bindings::KVM_API_VERSION;
55
use kvm_ioctls::Kvm as KvmFd;
66
use serde::{Deserialize, Serialize};
77

8+
pub use crate::arch::{Kvm, KvmArchError};
89
use crate::cpu_config::templates::KvmCapability;
910
use crate::vstate::memory::{GuestMemory, GuestMemoryMmap};
1011

11-
#[cfg(target_arch = "aarch64")]
12-
mod aarch64;
13-
#[cfg(target_arch = "x86_64")]
14-
mod x86_64;
15-
16-
#[cfg(target_arch = "aarch64")]
17-
pub use aarch64::{Kvm, KvmArchError, OptionalCapabilities};
18-
#[cfg(target_arch = "x86_64")]
19-
pub use x86_64::{Kvm, KvmArchError};
20-
2112
/// Errors associated with the wrappers over KVM ioctls.
2213
/// Needs `rustfmt::skip` to make multiline comments work
2314
#[rustfmt::skip]

0 commit comments

Comments
 (0)