vmm: Use virtio-blk to support booting from disk image
After the virtio-blk device support has been introduced in the
previous commit, the vmm need to rely on this new device to boot
from disk images instead of initrd built into the kernel.
In order to achieve the proper support of virtio-blk, this commit
had to handle a few things:
- Register an ioevent fd for each virtqueue. This important to be
notified from the virtio driver that something has been written
on the queue.
- Fix the retrieval of 64bits BAR address. This is needed to provide
the right address which need to be registered as the notification
address from the virtio driver.
- Fix the write_bar and read_bar functions. They were both assuming
to be provided with an address, from which they were trying to
find the associated offset. But the reality is that the offset is
directly provided by the Bus layer.
- Register a new virtio-blk device as a virtio-pci device from the
vm.rs code. When the VM is started, it expects a block device to
be created, using this block device as the VM rootfs.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
65f96e408f
commit
b67e0b3dad
7 changed files with 327 additions and 22 deletions
|
|
@ -402,13 +402,20 @@ impl PciConfiguration {
|
|||
Ok(config.reg_idx)
|
||||
}
|
||||
|
||||
/// Returns the address of the given BAR region.
|
||||
pub fn get_bar_addr(&self, bar_num: usize) -> u32 {
|
||||
/// Returns the address of the given 32 bits BAR region.
|
||||
pub fn get_bar32_addr(&self, bar_num: usize) -> u32 {
|
||||
let bar_idx = BAR0_REG + bar_num;
|
||||
|
||||
self.registers[bar_idx] & BAR_MEM_ADDR_MASK
|
||||
}
|
||||
|
||||
/// Returns the address of the given 64 bits BAR region.
|
||||
pub fn get_bar64_addr(&self, bar_num: usize) -> u64 {
|
||||
let bar_idx = BAR0_REG + bar_num;
|
||||
|
||||
u64::from(self.registers[bar_idx] & BAR_MEM_ADDR_MASK) | (u64::from(self.registers[bar_idx+1]) << 32)
|
||||
}
|
||||
|
||||
/// Configures the IRQ line and pin used by this device.
|
||||
pub fn set_irq(&mut self, line: u8, pin: PciInterruptPin) {
|
||||
// `pin` is 1-based in the pci config space.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
use crate::configuration::{self, PciConfiguration};
|
||||
use crate::PciInterruptPin;
|
||||
use devices::BusDevice;
|
||||
use kvm_ioctls::*;
|
||||
use std;
|
||||
use std::fmt::{self, Display};
|
||||
use vm_allocator::SystemAllocator;
|
||||
|
|
@ -60,7 +59,7 @@ pub trait PciDevice: BusDevice {
|
|||
|
||||
/// Gets a list of ioeventfds that should be registered with the running VM. The list is
|
||||
/// returned as a Vec of (eventfd, addr, datamatch) tuples.
|
||||
fn ioeventfds(&self) -> Vec<(&EventFd, u64, NoDatamatch)> {
|
||||
fn ioeventfds(&self) -> Vec<(&EventFd, u64, u64)> {
|
||||
Vec::new()
|
||||
}
|
||||
/// Gets the configuration registers of the Pci Device.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue