From 83c34f8453c299dd1de5fff71a0829d54291a902 Mon Sep 17 00:00:00 2001
From: centra
Date: Thu, 2 Apr 2026 13:54:01 +0900
Subject: [PATCH] add nix-backed kvm boot smoke coverage
---
plasmavmc/crates/plasmavmc-kvm/src/lib.rs | 268 ++++++++++++++++++++--
1 file changed, 243 insertions(+), 25 deletions(-)
diff --git a/plasmavmc/crates/plasmavmc-kvm/src/lib.rs b/plasmavmc/crates/plasmavmc-kvm/src/lib.rs
index 04b0b04..40d4d02 100644
--- a/plasmavmc/crates/plasmavmc-kvm/src/lib.rs
+++ b/plasmavmc/crates/plasmavmc-kvm/src/lib.rs
@@ -1128,6 +1128,15 @@ impl HypervisorBackend for KvmBackend {
mod tests {
use super::*;
use plasmavmc_types::DiskSpec;
+ use std::{
+ ffi::OsStr,
+ fs::{self, File},
+ os::unix::fs::PermissionsExt,
+ path::{Path, PathBuf},
+ process::Command as StdCommand,
+ sync::OnceLock,
+ time::{SystemTime, UNIX_EPOCH},
+ };
use tokio::net::UnixListener;
#[test]
@@ -1383,42 +1392,251 @@ mod tests {
.expect("qmp became ready");
}
- // Integration smoke: requires env to point to QEMU and a qcow2 image.
+ fn resolve_repo_root() -> Option {
+ let mut current = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+ loop {
+ if current.join("flake.nix").exists()
+ && current.join("nix/test-cluster/flake.nix").exists()
+ {
+ return Some(current);
+ }
+ if !current.pop() {
+ return None;
+ }
+ }
+ }
+
+ fn find_qcow2(path: &Path) -> Option {
+ if path.is_file() {
+ return path
+ .extension()
+ .and_then(|ext| (ext == OsStr::new("qcow2")).then(|| path.to_path_buf()));
+ }
+
+ let entries = fs::read_dir(path).ok()?;
+ for entry in entries.flatten() {
+ let candidate = entry.path();
+ if let Some(found) = find_qcow2(&candidate) {
+ return Some(found);
+ }
+ }
+ None
+ }
+
+ fn resolve_vm_guest_image() -> Option {
+ static VM_GUEST_IMAGE: OnceLock