vm-virtio: pci: Expect an identifier upon device creation

This identifier is chosen from the DeviceManager so that it will manage
all identifiers across the VM, which will ensure uniqueness.

It is based off the name from the virtio device attached to this
transport layer.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-04-27 16:19:40 +02:00
committed by Rob Bradford
parent eeb7e10d1f
commit 06487131f9
2 changed files with 20 additions and 8 deletions

View File

@@ -259,6 +259,8 @@ const VIRTIO_PCI_VENDOR_ID: u16 = 0x1af4;
const VIRTIO_PCI_DEVICE_ID_BASE: u16 = 0x1040; // Add to device type to get device ID.
pub struct VirtioPciDevice {
id: String,
// PCI configuration registers.
configuration: PciConfiguration,
@@ -308,6 +310,7 @@ pub struct VirtioPciDevice {
impl VirtioPciDevice {
/// Constructs a new PCI transport for the given virtio device.
pub fn new(
id: String,
memory: GuestMemoryAtomic<GuestMemoryMmap>,
device: Arc<Mutex<dyn VirtioDevice>>,
msix_num: u16,
@@ -384,6 +387,7 @@ impl VirtioPciDevice {
);
let mut virtio_pci_device = VirtioPciDevice {
id,
configuration,
common_config: VirtioPciCommonConfig {
driver_status: 0,
@@ -962,6 +966,10 @@ impl Pausable for VirtioPciDevice {
}
}
impl Snapshottable for VirtioPciDevice {}
impl Snapshottable for VirtioPciDevice {
fn id(&self) -> String {
self.id.clone()
}
}
impl Transportable for VirtioPciDevice {}
impl Migratable for VirtioPciDevice {}