Skip to content

Commit a3d19a1

Browse files
committed
Merge
1 parent fc294d6 commit a3d19a1

File tree

9 files changed

+73
-48
lines changed

9 files changed

+73
-48
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rust 1.85.0
1+
rust 1.79.0

Cargo.lock

Lines changed: 11 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cpu-template-helper/src/utils/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub fn build_microvm_from_config(
125125
state: VmState::NotStarted,
126126
vmm_version: CPU_TEMPLATE_HELPER_VERSION.to_string(),
127127
app_name: "cpu-template-helper".to_string(),
128+
memory_regions: None,
128129
};
129130
let mut vm_resources =
130131
VmResources::from_json(&config, &instance_info, HTTP_MAX_PAYLOAD_SIZE, None)

src/firecracker/Cargo.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ vmm-sys-util = { version = "0.12.1", features = ["with-serde"] }
3535
[dev-dependencies]
3636
cargo_toml = "0.20.5"
3737
libc = "0.2.161"
38-
regex = { version = "1.11.1", default-features = false, features = ["std", "unicode-perl"] }
38+
regex = { version = "1.11.1", default-features = false, features = [
39+
"std",
40+
"unicode-perl",
41+
] }
3942

4043
# Dev-Dependencies for uffd examples
4144
serde = { version = "1.0.214", features = ["derive"] }
@@ -48,7 +51,12 @@ serde = { version = "1.0.214" }
4851
serde_json = "1.0.132"
4952

5053
[features]
51-
tracing = ["log-instrument", "seccompiler/tracing", "utils/tracing", "vmm/tracing"]
54+
tracing = [
55+
"log-instrument",
56+
"seccompiler/tracing",
57+
"utils/tracing",
58+
"vmm/tracing",
59+
]
5260
gdb = ["vmm/gdb"]
5361

5462
[lints]

src/vmm/Cargo.toml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ license = "Apache-2.0"
99
bench = false
1010

1111
[dependencies]
12-
acpi_tables = { path = "../acpi-tables" }
13-
aes-gcm = { version = "0.10.1", default-features = false, features = ["aes"] }
12+
acpi_tables = { path = "../acpi-tables" }
13+
aes-gcm = { version = "0.10.1", default-features = false, features = ["aes"] }
1414
arrayvec = { version = "0.7.6", optional = true }
1515
aws-lc-rs = { version = "1.10.0", features = ["bindgen"] }
1616
base64 = "0.22.1"
1717
bincode = "1.2.1"
1818
bitflags = "2.6.0"
1919
crc64 = "2.0.0"
20-
derive_more = { version = "1.0.0", default-features = false, features = ["from", "display"] }
20+
derive_more = { version = "1.0.0", default-features = false, features = [
21+
"from",
22+
"display",
23+
] }
2124
displaydoc = "0.2.5"
2225
event-manager = "0.4.0"
2326
gdbstub = { version = "0.7.3", optional = true }
@@ -43,7 +46,10 @@ userfaultfd = "0.8.1"
4346
utils = { path = "../utils" }
4447
vhost = { version = "0.13.0", features = ["vhost-user-frontend"] }
4548
vm-allocator = "0.1.0"
46-
vm-memory = { version = "0.16.0", features = ["backend-mmap", "backend-bitmap"] }
49+
vm-memory = { version = "0.16.0", features = [
50+
"backend-mmap",
51+
"backend-bitmap",
52+
] }
4753
vm-superio = "0.8.0"
4854
vmm-sys-util = { version = "0.12.1", features = ["with-serde"] }
4955
zerocopy = { version = "0.8.8" }
@@ -80,3 +86,8 @@ harness = false
8086

8187
[lints]
8288
workspace = true
89+
90+
[patch.crates-io]
91+
aws-lc-sys = "=0.29.0"
92+
aws-lc-rs = "=1.13.1"
93+
aws-lc-fips-sys = "=0.13.7"

src/vmm/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ use crate::vstate::memory::{
153153
use crate::vstate::vcpu::VcpuState;
154154
pub use crate::vstate::vcpu::{Vcpu, VcpuConfig, VcpuEvent, VcpuHandle, VcpuResponse};
155155
pub use crate::vstate::vm::Vm;
156+
use serde::{Deserialize, Serialize};
156157

157158
/// Shorthand type for the EventManager flavour used by Firecracker.
158159
pub type EventManager = BaseEventManager<Arc<Mutex<dyn MutEventSubscriber>>>;
@@ -191,6 +192,20 @@ pub enum FcExitCode {
191192
ArgParsing = 153,
192193
}
193194

195+
/// Describes the region of guest memory that can be used for creating the memfile.
196+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
197+
pub struct GuestMemoryRegionMapping {
198+
/// Base host virtual address where the guest memory contents for this region
199+
/// should be copied/populated.
200+
pub base_host_virt_addr: u64,
201+
/// Region size.
202+
pub size: usize,
203+
/// Offset in the backend file/buffer where the region contents are.
204+
pub offset: u64,
205+
/// The configured page size for this memory region.
206+
pub page_size: usize,
207+
}
208+
194209
/// Timeout used in recv_timeout, when waiting for a vcpu response on
195210
/// Pause/Resume/Save/Restore. A high enough limit that should not be reached during normal usage,
196211
/// used to detect a potential vcpu deadlock.
@@ -451,6 +466,21 @@ impl Vmm {
451466
&self.guest_memory
452467
}
453468

469+
pub fn guest_memory_mappings(&self, vm_info: &VmInfo) -> Vec<GuestMemoryRegionMapping> {
470+
let mut offset = 0;
471+
let mut mappings = Vec::new();
472+
for mem_region in self.guest_memory().iter() {
473+
mappings.push(GuestMemoryRegionMapping {
474+
base_host_virt_addr: mem_region.as_ptr() as u64,
475+
size: mem_region.size(),
476+
offset,
477+
page_size: vm_info.huge_pages.page_size_kib(),
478+
});
479+
offset += mem_region.size() as u64;
480+
}
481+
mappings
482+
}
483+
454484
/// Sets RDA bit in serial console
455485
pub fn emulate_serial_init(&self) -> Result<(), EmulateSerialInitError> {
456486
// When restoring from a previously saved state, there is no serial

src/vmm/src/rpc_interface.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,8 @@ impl RuntimeApiController {
651651

652652
let mut instance_info = locked_vmm.instance_info();
653653

654-
instance_info.memory_regions = locked_vmm
655-
.vm
656-
.guest_memory_mappings(&VmInfo::from(&self.vm_resources));
654+
instance_info.memory_regions =
655+
locked_vmm.guest_memory_mappings(&VmInfo::from(&self.vm_resources));
657656

658657
Ok(VmmData::InstanceInformation(instance_info))
659658
}

src/vmm/src/vmm_config/instance_info.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
use std::fmt::{self, Display, Formatter};
44

5-
use crate::vstate::vm::GuestMemoryRegionMapping;
5+
use crate::GuestMemoryRegionMapping;
66
use serde::{ser, Serialize};
77

88
/// Enumerates microVM runtime states.
@@ -48,5 +48,6 @@ pub struct InstanceInfo {
4848
/// The name of the application that runs the microVM.
4949
pub app_name: String,
5050
/// The regions of the guest memory.
51-
pub memory_regions: Vec<GuestMemoryRegionMapping>,
51+
#[serde(skip_serializing_if = "Option::is_none")]
52+
pub memory_regions: Option<Vec<GuestMemoryRegionMapping>>,
5253
}

src/vmm/src/vstate/vm.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,6 @@ use crate::cpu_config::templates::KvmCapability;
2727
use crate::utils::u64_to_usize;
2828
use crate::vstate::memory::{Address, GuestMemory, GuestMemoryMmap, GuestMemoryRegion};
2929

30-
/// Describes the region of guest memory that can be used for creating the memfile.
31-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
32-
pub struct GuestMemoryRegionMapping {
33-
/// Base host virtual address where the guest memory contents for this region
34-
/// should be copied/populated.
35-
pub base_host_virt_addr: u64,
36-
/// Region size.
37-
pub size: usize,
38-
/// Offset in the backend file/buffer where the region contents are.
39-
pub offset: u64,
40-
/// The configured page size for this memory region.
41-
pub page_size: usize,
42-
}
43-
4430
/// Errors associated with the wrappers over KVM ioctls.
4531
/// Needs `rustfmt::skip` to make multiline comments work
4632
#[rustfmt::skip]

0 commit comments

Comments
 (0)