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

Commit a857a3b

Browse files
committed
virtio-mmio: Add support for virtio-mmio blk devices
Add support for discovery of rootfs passed in via virtio-mmio. The discovery is done based on predicted device name. Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
1 parent 29f3fe9 commit a857a3b

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

device.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
const (
2727
driver9pType = "9p"
2828
driverBlkType = "blk"
29+
driverMmioBlkType = "mmioblk"
2930
driverSCSIType = "scsi"
3031
driverNvdimmType = "nvdimm"
3132
driverEphemeralType = "ephemeral"
@@ -59,9 +60,10 @@ var (
5960
type deviceHandler func(device pb.Device, spec *pb.Spec, s *sandbox) error
6061

6162
var deviceHandlerList = map[string]deviceHandler{
62-
driverBlkType: virtioBlkDeviceHandler,
63-
driverSCSIType: virtioSCSIDeviceHandler,
64-
driverNvdimmType: nvdimmDeviceHandler,
63+
driverMmioBlkType: virtioMmioBlkDeviceHandler,
64+
driverBlkType: virtioBlkDeviceHandler,
65+
driverSCSIType: virtioSCSIDeviceHandler,
66+
driverNvdimmType: nvdimmDeviceHandler,
6567
}
6668

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

173+
// device.Id should be the predicted device name (vda, vdb, ...)
174+
// device.VmPath already provides a way to send it in
175+
func virtioMmioBlkDeviceHandler(device pb.Device, spec *pb.Spec, s *sandbox) error {
176+
if device.VmPath == "" {
177+
return fmt.Errorf("Invalid path for virtioMmioBlkDevice")
178+
}
179+
180+
return updateSpecDeviceList(device, spec)
181+
}
182+
171183
// device.Id should be the PCI address in the format "bridgeAddr/deviceAddr".
172184
// Here, bridgeAddr is the address at which the brige is attached on the root bus,
173185
// while deviceAddr is the address at which the device is attached on the bridge.

mount.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ type storageHandler func(storage pb.Storage, s *sandbox) (string, error)
192192
var storageHandlerList = map[string]storageHandler{
193193
driver9pType: virtio9pStorageHandler,
194194
driverBlkType: virtioBlkStorageHandler,
195+
driverMmioBlkType: virtioMmioBlkStorageHandler,
195196
driverSCSIType: virtioSCSIStorageHandler,
196197
driverEphemeralType: ephemeralStorageHandler,
197198
}
@@ -216,6 +217,12 @@ func virtio9pStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
216217
return commonStorageHandler(storage)
217218
}
218219

220+
// virtioMmioBlkStorageHandler handles the storage for mmio blk driver.
221+
func virtioMmioBlkStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
222+
//The source path is VmPath
223+
return commonStorageHandler(storage)
224+
}
225+
219226
// virtioBlkStorageHandler handles the storage for blk driver.
220227
func virtioBlkStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
221228
// Get the device node path based on the PCI address provided

0 commit comments

Comments
 (0)