Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openvmm/openvmm_core/src/worker/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3837,6 +3837,7 @@ impl LoadedVm {
}
WorkerRpc::Inspect(deferred) => deferred.respond(|resp| {
resp.field("device_removal_pending", device_removal.is_pending())
.field("partition_supports_reset", self.inner.partition.supports_reset())
.field("memory", &self.inner.memory_manager)
.field("memory_layout", &self.inner.mem_layout)
.field("resolver", &self.inner.resolver)
Expand Down
39 changes: 37 additions & 2 deletions vmm_tests/vmm_tests/tests/tests/multiarch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,51 @@ async fn boot<T: PetriVmmBackend>(config: PetriVmBuilder<T>) -> anyhow::Result<(
Ok(())
}

/// Basic boot test using virtio vsock instead of vmbus hvsocket.
/// Verify that Pipette can exchange data over virtio-vsock at boot and, when supported, after reboot.
/// N.B. Because this requires kernel support, it's only done for Linux direct boot since the test
/// kernel is guaranteed to include it.
#[vmm_test(openvmm_linux_direct_x64, openvmm_linux_direct_aarch64)]
async fn boot_virtio_vsock(config: PetriVmBuilder<OpenVmmPetriBackend>) -> anyhow::Result<()> {
let (vm, agent) = config
async fn probe(agent: &pipette_client::PipetteClient) -> anyhow::Result<Guid> {
anyhow::ensure!(
agent.local_vsock_cid() == Some(3),
"expected virtio-vsock guest CID 3, got {:?}",
agent.local_vsock_cid()
);
let sh = agent.unix_shell();
let marker = Guid::new_random().to_string();
let reply = cmd!(sh, "echo {marker}").read().await?;
anyhow::ensure!(reply.trim() == marker, "expected {marker}, got {reply:?}");
sh.read_file("/proc/sys/kernel/random/boot_id")
.await?
.trim()
.parse()
.context("invalid guest boot ID")
}

let (mut vm, mut agent) = config
.with_virtio_vsock(true)
.modify_backend(|b| b.with_pcie_root_topology(1, 1, 1))
.run()
.await?;
let first_boot = probe(&agent).await.context("vsock before reboot")?;
let reset_capability = vm.inspect_vmm("partition_supports_reset").await?;
let inspect::Node::Value(inspect::Value {
kind: inspect::ValueKind::Bool(supports_reset),
..
}) = reset_capability
else {
anyhow::bail!("unexpected VMM reset capability: {reset_capability:?}");
};
if supports_reset {
agent.reboot().await?;
// Keep the original vsock connection alive through reset.
agent = vm.wait_for_reset().await?;
let second_boot = probe(&agent).await.context("vsock after reboot")?;
anyhow::ensure!(first_boot != second_boot, "guest boot ID did not change");
} else {
tracing::info!("partition reset is not supported; skipping the vsock reboot check");
}
agent.power_off().await?;
vm.wait_for_clean_teardown().await?;
Ok(())
Expand Down
44 changes: 42 additions & 2 deletions vmm_tests/vmm_tests/tests/tests/ttrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ async fn test_ttrpc_interface(
driver: DefaultDriver,
[openvmm, kernel_path, initrd_path, pipette_path]: [ResolvedArtifact; 4],
) -> anyhow::Result<()> {
const FLAT_MEMORY_MIB: u64 = 256;
const FLAT_VCPUS: u32 = 2;

// All temporary files for this test live under a single temp directory
// that is cleaned up automatically when it is dropped at the end of the
// test.
Expand Down Expand Up @@ -984,12 +987,12 @@ async fn test_ttrpc_interface(
} else if i == 2 {
(
Some(vmservice::MemoryConfig {
memory_mb: 256,
memory_mb: FLAT_MEMORY_MIB,
..Default::default()
}),
None,
Some(vmservice::ProcessorConfig {
processor_count: 2,
processor_count: FLAT_VCPUS,
..Default::default()
}),
Some(vmservice::PcieTopologyConfig {
Expand Down Expand Up @@ -1479,6 +1482,7 @@ async fn test_ttrpc_interface(
)
.await?;
if i == 2 {
validate_guest_sizing(&agent, FLAT_VCPUS, FLAT_MEMORY_MIB).await?;
let sh = agent.unix_shell();
cmd!(sh, "sh -c 'printf ttrpc-console-file-marker > /dev/hvc0'")
.run()
Expand Down Expand Up @@ -2722,6 +2726,42 @@ const SMBIOS_SYS_SKU: &str = "SKU-CONTOSO-42";
const SMBIOS_SYS_FAMILY: &str = "Contoso VM Family";
const SMBIOS_SYS_UUID: &str = "12345678-9abc-def0-1234-56789abcdef0";

async fn validate_guest_sizing(
agent: &pipette_client::PipetteClient,
vcpus: u32,
memory_mib: u64,
) -> anyhow::Result<()> {
let sh = agent.unix_shell();
let online = sh.read_file("/sys/devices/system/cpu/online").await?;
let expected_online = format!("0-{}", vcpus - 1);
anyhow::ensure!(
online.trim() == expected_online,
"requested {vcpus} vCPUs, expected online set {expected_online}, got {online:?}"
);

let meminfo = sh.read_file("/proc/meminfo").await?;
let total = meminfo
.lines()
.find_map(|line| line.strip_prefix("MemTotal:"))
.context("missing MemTotal in guest /proc/meminfo")?;
let total_kib: u64 = total
.trim()
.strip_suffix(" kB")
.with_context(|| format!("unexpected guest MemTotal unit: {total:?}"))?
.trim_end()
.parse()
.with_context(|| format!("invalid guest MemTotal: {total:?}"))?;

// Linux excludes reserved pages from MemTotal. Allow up to 64 MiB in this direct-boot guest.
let requested_kib = memory_mib * 1024;
let min_kib = requested_kib - 64 * 1024;
anyhow::ensure!(
(min_kib..=requested_kib).contains(&total_kib),
"requested {memory_mib} MiB, expected guest MemTotal in {min_kib}..={requested_kib} KiB, got {total_kib} KiB"
);
Ok(())
}

async fn validate_smbios(agent: &pipette_client::PipetteClient) -> anyhow::Result<()> {
for (file, expected) in [
("bios_vendor", SMBIOS_BIOS_VENDOR),
Expand Down
Loading