runtime-rs: Handle PortDevice devices when invoke start_vm with Qemu

Extract PortDevice relevant information, and then invoke different
processing methods based on the device type.

Fixes #10361

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
alex.lyn 2025-04-11 17:05:21 +08:00
parent c109328097
commit 07533522b8

View File

@ -5,6 +5,7 @@
use super::cmdline_generator::{get_network_device, QemuCmdLine, QMP_SOCKET_FILE};
use super::qmp::Qmp;
use crate::device::topology::PCIePort;
use crate::{
device::driver::ProtectionDeviceConfig, hypervisor_persist::HypervisorState,
utils::enter_netns, HypervisorConfig, MemoryConfig, VcpuThreadIds, VsockDevice,
@ -145,6 +146,26 @@ impl QemuInner {
}
ProtectionDeviceConfig::Se => cmdline.add_se_protection_device(),
},
DeviceType::PortDevice(port_device) => {
let port_type = port_device.config.port_type;
let mem_reserve = port_device.config.memsz_reserve;
let pref64_reserve = port_device.config.pref64_reserve;
let devices_per_port = port_device.port_devices.clone();
match port_type {
PCIePort::RootPort => cmdline.add_pcie_root_ports(
devices_per_port,
mem_reserve,
pref64_reserve,
)?,
PCIePort::SwitchPort => cmdline.add_pcie_switch_ports(
devices_per_port,
mem_reserve,
pref64_reserve,
)?,
_ => info!(sl!(), "no need to add {} ports", port_type),
}
}
_ => info!(sl!(), "qemu cmdline: unsupported device: {:?}", device),
}
}