vmm, main: make PCI BDF configurable for ConsoleConfig

Add common PCI device configuration to the virtio-console device
configuration. This allows setting the device ID (the name), ID, the
PCI segment, and the PCI device ID (BDF), which were previously not
configurable for the virtio-console device.

This gives management software, such as libvirt, more control over PCI
resource assignment and aligns virtio-console with other devices that
already support this functionality [0].

[0] https://github.com/cloud-hypervisor/cloud-hypervisor/issues/8175

On-behalf-of: Philipp Schuster <philipp.schuster@sap.com>
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
This commit is contained in:
Philipp Schuster
2026-05-11 16:11:48 +02:00
committed by Rob Bradford
parent 36a3369802
commit e793353bfb
6 changed files with 70 additions and 33 deletions

View File

@@ -2368,7 +2368,7 @@ impl DeviceManager {
transport: ConsoleTransport,
resize_pipe: Option<Arc<File>>,
) -> DeviceManagerResult<Option<Arc<virtio_devices::ConsoleResizer>>> {
let console_config = self.config.lock().unwrap().console.clone();
let mut console_config = self.config.lock().unwrap().console.clone();
let endpoint = match transport {
ConsoleTransport::File(file) => Endpoint::File(file),
ConsoleTransport::Pty(file) => {
@@ -2402,7 +2402,15 @@ impl DeviceManager {
ConsoleTransport::Null => Endpoint::Null,
ConsoleTransport::Off => return Ok(None),
};
let id = String::from(CONSOLE_DEVICE_NAME);
let id = match console_config.pci_common.id.as_ref() {
Some(id) => id.clone(),
None => console_config
.pci_common
.id
.insert(CONSOLE_DEVICE_NAME.to_string())
.clone(),
};
let (virtio_console_device, console_resizer) = virtio_devices::Console::new(
id.clone(),
@@ -2410,7 +2418,7 @@ impl DeviceManager {
self.console_resize_pipe
.as_ref()
.map(|p| p.try_clone().unwrap()),
self.force_access_platform | console_config.iommu,
self.force_access_platform | console_config.pci_common.iommu,
self.seccomp_action.clone(),
self.exit_evt
.try_clone()
@@ -2423,11 +2431,7 @@ impl DeviceManager {
self.virtio_devices.push(MetaVirtioDevice {
virtio_device: Arc::clone(&virtio_console_device)
as Arc<Mutex<dyn virtio_devices::VirtioDevice>>,
pci_common: PciDeviceCommonConfig {
id: Some(id.clone()),
iommu: console_config.iommu,
..Default::default()
},
pci_common: console_config.pci_common.clone(),
dma_handler: None,
});