Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #437 from mcastelino/topic/firecracker-virtio-mmio
Browse files Browse the repository at this point in the history
virtio-mmio: Add support for virtio-mmio blk devices
  • Loading branch information
Julio Montes authored Dec 18, 2018
2 parents 29f3fe9 + ff87c26 commit 173bb55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
18 changes: 15 additions & 3 deletions device.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
const (
driver9pType = "9p"
driverBlkType = "blk"
driverMmioBlkType = "mmioblk"
driverSCSIType = "scsi"
driverNvdimmType = "nvdimm"
driverEphemeralType = "ephemeral"
Expand Down Expand Up @@ -59,9 +60,10 @@ var (
type deviceHandler func(device pb.Device, spec *pb.Spec, s *sandbox) error

var deviceHandlerList = map[string]deviceHandler{
driverBlkType: virtioBlkDeviceHandler,
driverSCSIType: virtioSCSIDeviceHandler,
driverNvdimmType: nvdimmDeviceHandler,
driverMmioBlkType: virtioMmioBlkDeviceHandler,
driverBlkType: virtioBlkDeviceHandler,
driverSCSIType: virtioSCSIDeviceHandler,
driverNvdimmType: nvdimmDeviceHandler,
}

func rescanPciBus() error {
Expand Down Expand Up @@ -168,6 +170,16 @@ func getPCIDeviceName(s *sandbox, pciID string) (string, error) {
return filepath.Join(systemDevPath, devName), nil
}

// device.Id should be the predicted device name (vda, vdb, ...)
// device.VmPath already provides a way to send it in
func virtioMmioBlkDeviceHandler(device pb.Device, spec *pb.Spec, s *sandbox) error {
if device.VmPath == "" {
return fmt.Errorf("Invalid path for virtioMmioBlkDevice")
}

return updateSpecDeviceList(device, spec)
}

// device.Id should be the PCI address in the format "bridgeAddr/deviceAddr".
// Here, bridgeAddr is the address at which the brige is attached on the root bus,
// while deviceAddr is the address at which the device is attached on the bridge.
Expand Down
7 changes: 7 additions & 0 deletions mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ type storageHandler func(storage pb.Storage, s *sandbox) (string, error)
var storageHandlerList = map[string]storageHandler{
driver9pType: virtio9pStorageHandler,
driverBlkType: virtioBlkStorageHandler,
driverMmioBlkType: virtioMmioBlkStorageHandler,
driverSCSIType: virtioSCSIStorageHandler,
driverEphemeralType: ephemeralStorageHandler,
}
Expand All @@ -216,6 +217,12 @@ func virtio9pStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
return commonStorageHandler(storage)
}

// virtioMmioBlkStorageHandler handles the storage for mmio blk driver.
func virtioMmioBlkStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
//The source path is VmPath
return commonStorageHandler(storage)
}

// virtioBlkStorageHandler handles the storage for blk driver.
func virtioBlkStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
// Get the device node path based on the PCI address provided
Expand Down

0 comments on commit 173bb55

Please sign in to comment.