Author SHA1 Message Date
isrc-riscv-port ba05fe8cd6 runtime: enable Cloud Hypervisor config on RISC-V
Stale issues with activity before a fixed date / stale (push) Has been cancelled
Automatically close stale PRs / stale (push) Has been cancelled
Cleanup dangling Azure resources / cleanup-resources (push) Has been cancelled
Kata Containers Nightly CI / kata-containers-ci-on-push (push) Has been cancelled
Nightly CI for s390x / check-internal-test-result (cc-se-e2e-tests-go) (push) Has been cancelled
Nightly CI for s390x / check-internal-test-result (cc-se-e2e-tests-rs) (push) Has been cancelled
Nightly CI for s390x / check-internal-test-result (cc-vfio-ap-e2e-tests) (push) Has been cancelled
Nightly CI for s390x / check-internal-test-result (kata-vfio-ap-e2e-tests) (push) Has been cancelled
Nightly CI for RISC-V / build-kata-static-tarball-riscv (push) Has been cancelled
Nightly CI for RISC-V / build-checks-preview (riscv-builder) (push) Has been cancelled
Build kubectl multi-arch image / Build and push multi-arch image (push) Has been cancelled
OSV-Scanner / Scan of whole repo (push) Has been cancelled
OSV-Scanner / Scan of just PR code (push) Has been cancelled
Docs URL Alive Check / test (push) Has been cancelled
CodeQL Advanced / Analyze (go) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Signed-off-by: isrc-riscv-port <riscv-port@isrc.iscas.ac.cn>
2026-05-14 19:37:00 +08:00
isrc-riscv-port 8c32a6a334 virtcontainers: extend Cloud Hypervisor boot timeout on RISC-V
Stale issues with activity before a fixed date / stale (push) Has been cancelled
Nightly CI for s390x / check-internal-test-result (cc-se-e2e-tests-go) (push) Has been cancelled
Nightly CI for s390x / check-internal-test-result (cc-se-e2e-tests-rs) (push) Has been cancelled
Nightly CI for s390x / check-internal-test-result (cc-vfio-ap-e2e-tests) (push) Has been cancelled
Nightly CI for s390x / check-internal-test-result (kata-vfio-ap-e2e-tests) (push) Has been cancelled
Nightly CI for RISC-V / build-kata-static-tarball-riscv (push) Has been cancelled
Nightly CI for RISC-V / build-checks-preview (riscv-builder) (push) Has been cancelled
Automatically close stale PRs / stale (push) Has been cancelled
Cleanup dangling Azure resources / cleanup-resources (push) Has been cancelled
Kata Containers Nightly CI / kata-containers-ci-on-push (push) Has been cancelled
Signed-off-by: isrc-riscv-port <riscv-port@isrc.iscas.ac.cn>
2026-05-13 03:15:56 +00:00
isrc-riscv-port 3e8fe90bd2 agent: resolve RISC-V platform PCI root bus path
Signed-off-by: isrc-riscv-port <riscv-port@isrc.iscas.ac.cn>
2026-05-13 03:15:55 +00:00
isrc-riscv-port 921d0917bd agent: poll sysfs while waiting for PCI net devices
Signed-off-by: isrc-riscv-port <riscv-port@isrc.iscas.ac.cn>
2026-05-13 03:15:54 +00:00
4 changed files with 86 additions and 15 deletions
+36 -7
View File
@@ -5,18 +5,26 @@
//
#[cfg(target_arch = "s390x")]
use crate::ccw;
#[cfg(not(target_arch = "s390x"))]
use crate::AGENT_CONFIG;
use crate::linux_abi::*;
use crate::sandbox::Sandbox;
use crate::uevent::{wait_for_uevent, Uevent, UeventMatcher};
#[cfg(target_arch = "s390x")]
use crate::uevent::wait_for_uevent;
use crate::uevent::{Uevent, UeventMatcher};
#[cfg(not(target_arch = "s390x"))]
use crate::{device::pcipath_to_sysfs, pci};
use anyhow::{anyhow, Result};
use regex::Regex;
use std::fs;
use std::sync::Arc;
#[cfg(not(target_arch = "s390x"))]
use std::time::Duration;
use tokio::sync::Mutex;
#[cfg(not(target_arch = "s390x"))]
use tokio::time::{sleep, Instant};
fn check_existing(re: Regex) -> Result<bool> {
fn check_existing(re: &Regex) -> Result<bool> {
// Check if the interface is already added in case network is cold-plugged
// or the uevent loop is started before network is added.
// We check for the device in the sysfs directory for network devices.
@@ -37,7 +45,7 @@ fn check_existing(re: Regex) -> Result<bool> {
#[cfg(not(target_arch = "s390x"))]
pub async fn wait_for_pci_net_interface(
sandbox: &Arc<Mutex<Sandbox>>,
_sandbox: &Arc<Mutex<Sandbox>>,
root_complex: &str,
pcipath: &pci::Path,
) -> Result<()> {
@@ -49,13 +57,34 @@ pub async fn wait_for_pci_net_interface(
matcher.devpath.as_str()
);
let re = Regex::new(&pattern).expect("BUG: Failed to compile regex for NetPciMatcher");
if check_existing(re)? {
if check_existing(&re)? {
return Ok(());
}
let _uev = wait_for_uevent(sandbox, matcher).await?;
// Some virtual PCI network devices can be visible in sysfs without a net
// uevent reaching the agent watcher. Poll the same sysfs symlink pattern
// used for cold-plug detection so UpdateInterface can still proceed.
let timeout = AGENT_CONFIG.hotplug_timeout;
let deadline = Instant::now() + timeout;
let interval = Duration::from_millis(100);
Ok(())
loop {
if check_existing(&re)? {
return Ok(());
}
if Instant::now() >= deadline {
break;
}
sleep(interval).await;
}
Err(anyhow!(
"Timeout after {:?} waiting for net interface {:?}",
timeout,
matcher
))
}
#[cfg(not(target_arch = "s390x"))]
@@ -91,7 +120,7 @@ pub async fn wait_for_ccw_net_interface(
device: &ccw::Device,
) -> Result<()> {
let matcher = NetCcwMatcher::new(CCW_ROOT_BUS_PATH, device);
if check_existing(matcher.re.clone())? {
if check_existing(&matcher.re)? {
return Ok(());
}
let _uev = wait_for_uevent(sandbox, matcher).await?;
+31 -2
View File
@@ -9,13 +9,12 @@ use cfg_if::cfg_if;
use std::str::FromStr;
// Linux ABI related constants.
#[cfg(target_arch = "aarch64")]
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
use std::fs;
pub const SYSFS_DIR: &str = "/sys";
#[cfg(any(
all(target_arch = "powerpc64", target_endian = "little"),
target_arch = "riscv64",
target_arch = "s390x",
target_arch = "x86_64",
target_arch = "x86"
@@ -26,6 +25,36 @@ pub fn create_pci_root_bus_path(root_complex: &str) -> String {
format!("/devices/pci0000:{root_complex}")
}
#[cfg(target_arch = "riscv64")]
pub fn create_pci_root_bus_path(root_complex: &str) -> String {
let acpi_root_bus_path = format!("/devices/pci0000:{root_complex}");
let acpi_sysfs_dir = format!("{SYSFS_DIR}{acpi_root_bus_path}");
if fs::metadata(acpi_sysfs_dir).is_ok() {
return acpi_root_bus_path;
}
let fallback = format!("/devices/platform/30000000.pci/pci0000:{root_complex}");
let platform_sysfs_dir = format!("{SYSFS_DIR}/devices/platform");
let entries = match fs::read_dir(platform_sysfs_dir) {
Ok(entries) => entries,
Err(_) => return fallback,
};
for entry in entries.flatten() {
let dir_name = entry.file_name();
let root_bus_path = format!(
"/devices/platform/{}/pci0000:{root_complex}",
dir_name.to_string_lossy()
);
let sysfs_dir = format!("{SYSFS_DIR}{root_bus_path}");
if fs::metadata(sysfs_dir).is_ok() {
return root_bus_path;
}
}
fallback
}
// This is used in several modules, let's create a helper function to parse the
// qom path and switch easily once the shim sends us the full NUMA path
pub fn pcipath_from_dev_tree_path(dev_tree_path: &str) -> Result<(&str, pci::Path)> {
+1
View File
@@ -11,3 +11,4 @@ MACHINEACCELERATORS :=
CPUFEATURES :=
QEMUCMD := qemu-system-riscv64
CLHCMD := cloud-hypervisor
+18 -6
View File
@@ -76,9 +76,10 @@ const (
clhTimeout = 10
clhAPITimeout = 1
clhAPITimeoutConfidentialGuest = 20
// Minimum timout for calling CreateVM followed by BootVM. Executing these two APIs
// Minimum timeout for calling CreateVM followed by BootVM. Executing these two APIs
// might take longer than the value returned by getClhAPITimeout().
clhCreateAndBootVMMinimumTimeout = 10
clhCreateAndBootVMMinimumTimeout = 10
clhRiscv64CreateAndBootVMMinimumTimeout = 60
// Timeout for hot-plug - hotplug devices can take more time, than usual API calls
// Use longer time timeout for it.
clhHotPlugAPITimeout = 5
@@ -318,6 +319,20 @@ func (clh *cloudHypervisor) getClhAPITimeout() time.Duration {
return clhAPITimeout
}
func (clh *cloudHypervisor) getClhCreateAndBootVMTimeout() time.Duration {
minimumTimeout := time.Duration(clhCreateAndBootVMMinimumTimeout)
if runtime.GOARCH == "riscv64" {
minimumTimeout = time.Duration(clhRiscv64CreateAndBootVMMinimumTimeout)
}
apiTimeout := clh.getClhAPITimeout()
if apiTimeout < minimumTimeout {
return minimumTimeout
}
return apiTimeout
}
func (clh *cloudHypervisor) getClhStopSandboxTimeout() time.Duration {
// Increase the StopSandboxTimeout when dealing with a Confidential Guest.
// The value has been chosen based on tests using `ctr`, and hopefully
@@ -764,10 +779,7 @@ func (clh *cloudHypervisor) StartVM(ctx context.Context, timeout int) error {
return fmt.Errorf("failed to launch cloud-hypervisor: %q", err)
}
bootTimeout := clh.getClhAPITimeout()
if bootTimeout < clhCreateAndBootVMMinimumTimeout {
bootTimeout = clhCreateAndBootVMMinimumTimeout
}
bootTimeout := clh.getClhCreateAndBootVMTimeout()
ctx, cancel := context.WithTimeout(ctx, bootTimeout*time.Second)
defer cancel()