From 1e18716fbdc01df4538bb1604f6019d95ed29da3 Mon Sep 17 00:00:00 2001 From: wangyf0611 Date: Thu, 21 May 2026 15:48:33 +0800 Subject: [PATCH] arch, vmm: Fix riscv64 build gaps Several riscv64 paths are compiled by the KVM build but missed imports or cfg coverage needed by the current code. Import the vm-memory Bytes trait for the RISC-V UEFI loader, keep Instant available for migration timing code, and enable the UEFI flash error path for riscv64. Assisted-by: OpenAI-Codex:GPT-5 Signed-off-by: wangyf0611 --- arch/src/riscv64/uefi.rs | 2 +- vmm/src/lib.rs | 4 +--- vmm/src/memory_manager.rs | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/src/riscv64/uefi.rs b/arch/src/riscv64/uefi.rs index bd40e36ff..2ff3a8638 100644 --- a/arch/src/riscv64/uefi.rs +++ b/arch/src/riscv64/uefi.rs @@ -7,7 +7,7 @@ use std::os::fd::AsFd; use std::result; use thiserror::Error; -use vm_memory::{GuestAddress, GuestMemory}; +use vm_memory::{Bytes, GuestAddress, GuestMemory}; /// Errors thrown while loading UEFI binary #[derive(Debug, Error)] diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 8e1b163c2..ed26eebc4 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -12,9 +12,7 @@ use std::panic::AssertUnwindSafe; use std::path::PathBuf; use std::sync::mpsc::{Receiver, RecvError, SendError, Sender}; use std::sync::{Arc, Mutex}; -use std::time::Duration; -#[cfg(not(target_arch = "riscv64"))] -use std::time::Instant; +use std::time::{Duration, Instant}; use std::{io, result, thread}; use anyhow::{Context, anyhow}; diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 6d94fb9f8..3a9e6df4b 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -24,7 +24,7 @@ use anyhow::anyhow; use arch::RegionType; #[cfg(target_arch = "x86_64")] use devices::ioapic; -#[cfg(target_arch = "aarch64")] +#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] use hypervisor::HypervisorVmError; use libc::_SC_NPROCESSORS_ONLN; use log::{debug, error, info, warn}; @@ -445,7 +445,7 @@ pub enum Error { #[error("Failed to allocate MMIO address")] AllocateMmioAddress, - #[cfg(target_arch = "aarch64")] + #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] /// Failed to create UEFI flash #[error("Failed to create UEFI flash")] CreateUefiFlash(#[source] HypervisorVmError),