Skip to content

Commit

Permalink
Merge pull request #2 from mcastelino/topic/virtio-mmio
Browse files Browse the repository at this point in the history
virtio-mmio: Add support for virtio-mmio
  • Loading branch information
Eric Ernst authored Dec 6, 2018
2 parents 8206f64 + b9706aa commit 8e12712
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ func (h hypervisor) blockDeviceDriver() (string, error) {
return defaultBlockDeviceDriver, nil
}

if h.BlockDeviceDriver != vc.VirtioSCSI && h.BlockDeviceDriver != vc.VirtioBlock {
return "", fmt.Errorf("Invalid value %s provided for hypervisor block storage driver, can be either %s or %s", h.BlockDeviceDriver, vc.VirtioSCSI, vc.VirtioBlock)
if h.BlockDeviceDriver != vc.VirtioSCSI && h.BlockDeviceDriver != vc.VirtioBlock && h.BlockDeviceDriver != vc.VirtioMmio {
return "", fmt.Errorf("Invalid value %s provided for hypervisor block storage driver, can be either %s or %s or %s", h.BlockDeviceDriver, vc.VirtioSCSI, vc.VirtioBlock, vc.VirtioMmio)
}

return h.BlockDeviceDriver, nil
Expand Down
3 changes: 3 additions & 0 deletions virtcontainers/device/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ type BlockDrive struct {
// Index assigned to the drive. In case of virtio-scsi, this is used as SCSI LUN index
Index int

// MmioAddr is used to identify the slot at which the drive is attached (order?).
MmioAddr string

// PCIAddr is the PCI address used to identify the slot at which the drive is attached.
PCIAddr string

Expand Down
6 changes: 5 additions & 1 deletion virtcontainers/device/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
)

const (
// VirtioMmio indicates block driver is virtio-mmio based
VirtioMmio string = "virtio-mmio"
// VirtioBlock indicates block driver is virtio-blk based
VirtioBlock string = "virtio-blk"
// VirtioSCSI indicates block driver is virtio-scsi based
Expand Down Expand Up @@ -55,7 +57,9 @@ func NewDeviceManager(blockDriver string, devices []api.Device) api.DeviceManage
dm := &deviceManager{
devices: make(map[string]api.Device),
}
if blockDriver == VirtioBlock {
if blockDriver == VirtioMmio {
dm.blockDriver = VirtioMmio
} else if blockDriver == VirtioBlock {
dm.blockDriver = VirtioBlock
} else {
dm.blockDriver = VirtioSCSI
Expand Down
3 changes: 2 additions & 1 deletion virtcontainers/hyperstart_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ func (h *hyper) startOneContainer(sandbox *Sandbox, c *Container) error {

if c.state.Fstype != "" {
// Pass a drive name only in case of block driver
if sandbox.config.HypervisorConfig.BlockDeviceDriver == VirtioBlock {
if (sandbox.config.HypervisorConfig.BlockDeviceDriver == VirtioBlock) ||
(sandbox.config.HypervisorConfig.BlockDeviceDriver == VirtioMmio) {
driveName, err := utils.GetVirtDriveName(c.state.BlockIndex)
if err != nil {
return err
Expand Down
6 changes: 5 additions & 1 deletion virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var (
// CAP_NET_BIND_SERVICE capability may bind to these port numbers.
vSockPort = 1024
kata9pDevType = "9p"
kataMmioBlkDevType = "mmioblk"
kataBlkDevType = "blk"
kataSCSIDevType = "scsi"
sharedDir9pOptions = []string{"trans=virtio,version=9p2000.L,cache=mmap", "nodev"}
Expand Down Expand Up @@ -912,7 +913,10 @@ func (k *kataAgent) buildContainerRootfs(sandbox *Sandbox, c *Container, rootPat
return nil, fmt.Errorf("malformed block drive")
}

if sandbox.config.HypervisorConfig.BlockDeviceDriver == VirtioBlock {
if sandbox.config.HypervisorConfig.BlockDeviceDriver == VirtioMmio {
rootfs.Driver = kataMmioBlkDevType
rootfs.Source = blockDrive.MmioAddr
} else if sandbox.config.HypervisorConfig.BlockDeviceDriver == VirtioBlock {
rootfs.Driver = kataBlkDevType
rootfs.Source = blockDrive.PCIAddr
} else {
Expand Down
4 changes: 4 additions & 0 deletions virtcontainers/qemu_arch_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ const (
// 0 is reserved.
const bridgePCIStartAddr = 2

//TODO: This should be a hypervisor agnostic definition
const (
// VirtioMmio means use virtio-mmio for mmio based drives
VirtioMmio = "virtio-mmio"

// VirtioBlock means use virtio-blk for hotplugging drives
VirtioBlock = "virtio-blk"

Expand Down

0 comments on commit 8e12712

Please sign in to comment.