Skip to content

Commit 1a8418a

Browse files
committed
pci: add virtio-pci transport implementation
Add a VirtIO PCI transport implementation. Nothing uses it at the moment. This requires a few changes in our vended pci and vm-device crates. Add a couple of tests that ensure that PCI configuration space is what expected. We read common fields and make sure the BAR we allocate for the VirtIO device is what expected. Signed-off-by: Babis Chalios <[email protected]>
1 parent 821166c commit 1a8418a

File tree

8 files changed

+1682
-1
lines changed

8 files changed

+1682
-1
lines changed

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/vmm/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ gdb = ["arrayvec", "gdbstub", "gdbstub_arch"]
1717

1818
acpi_tables = { path = "../acpi-tables" }
1919
aes-gcm = { version = "0.10.1", default-features = false, features = ["aes"] }
20+
anyhow = "1.0.98"
2021
arrayvec = { version = "0.7.6", optional = true }
2122
aws-lc-rs = { version = "1.13.1", features = ["bindgen"] }
2223
base64 = "0.22.1"
2324
bincode = { version = "2.0.1", features = ["serde"] }
2425
bitflags = "2.9.1"
26+
byteorder = "1.5.0"
2527
crc64 = "2.0.0"
2628
derive_more = { version = "2.0.1", default-features = false, features = [
2729
"from",

src/vmm/src/devices/virtio/device.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub trait VirtioDevice: AsAny + Send {
148148

149149
/// Optionally deactivates this device and returns ownership of the guest memory map, interrupt
150150
/// event, and queue events.
151-
fn reset(&mut self) -> Option<(EventFd, Vec<EventFd>)> {
151+
fn reset(&mut self) -> Option<(Arc<dyn VirtioInterrupt>, Vec<EventFd>)> {
152152
None
153153
}
154154

src/vmm/src/devices/virtio/queue.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,19 @@ impl Queue {
712712

713713
new - used_event - Wrapping(1) < new - old
714714
}
715+
716+
/// Resets the Virtio Queue
717+
pub(crate) fn reset(&mut self) {
718+
self.ready = false;
719+
self.size = self.max_size;
720+
self.desc_table_address = GuestAddress(0);
721+
self.avail_ring_address = GuestAddress(0);
722+
self.used_ring_address = GuestAddress(0);
723+
self.next_avail = Wrapping(0);
724+
self.next_used = Wrapping(0);
725+
self.num_added = Wrapping(0);
726+
self.uses_notif_suppression = false;
727+
}
715728
}
716729

717730
#[cfg(kani)]

src/vmm/src/devices/virtio/transport/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use vmm_sys_util::eventfd::EventFd;
88

99
/// MMIO transport for VirtIO devices
1010
pub mod mmio;
11+
/// PCI transport for VirtIO devices
12+
pub mod pci;
1113

1214
/// Represents the types of interrupts used by VirtIO devices
1315
#[derive(Debug, Clone)]

0 commit comments

Comments
 (0)