Skip to content

Commit

Permalink
runtime: add appendBridges for arm64
Browse files Browse the repository at this point in the history
since generic func genericAppendBridges and genericBridges
is also applied for machine type QemuVirt, we use it as implementation
for appendBridges and bridges on aarch64.
since const defaultPCBridgeBus is used in generic func
genericAppendBridges for pc machine, we should define it once
in generic file, instead of redefining it in different
arch-specific files.

Fixes: kata-containers#1200

Signed-off-by: Penny Zheng <[email protected]>
  • Loading branch information
Pennyzct committed Feb 13, 2019
1 parent 82b66ee commit c2bdeb1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 9 deletions.
2 changes: 0 additions & 2 deletions virtcontainers/qemu_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const defaultQemuMachineType = QemuPC

const defaultQemuMachineOptions = "accel=kvm,kernel_irqchip,nvdimm"

const defaultPCBridgeBus = "pci.0"

var qemuPaths = map[string]string{
QemuPCLite: "/usr/bin/qemu-lite-system-x86_64",
QemuPC: defaultQemuPath,
Expand Down
1 change: 1 addition & 0 deletions virtcontainers/qemu_arch_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const (
defaultThreads uint32 = 1
defaultCPUModel = "host"
defaultBridgeBus = "pcie.0"
defaultPCBridgeBus = "pci.0"
maxDevIDSize = 31
defaultMsize9p = 8192
)
Expand Down
13 changes: 10 additions & 3 deletions virtcontainers/qemu_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strings"

govmmQemu "github.com/intel/govmm/qemu"
"github.com/kata-containers/runtime/virtcontainers/types"
"github.com/sirupsen/logrus"
)

Expand All @@ -25,9 +26,6 @@ const defaultQemuMachineType = QemuVirt

var defaultQemuMachineOptions = "usb=off,accel=kvm,gic-version=" + getGuestGICVersion()

// Not used
const defaultPCBridgeBus = ""

var qemuPaths = map[string]string{
QemuVirt: defaultQemuPath,
}
Expand Down Expand Up @@ -153,3 +151,12 @@ func newQemuArch(config HypervisorConfig) qemuArch {

return q
}

func (q *qemuArm64) bridges(number uint32) []types.PCIBridge {
return genericBridges(number, q.machineType)
}

// appendBridges appends to devices the given bridges
func (q *qemuArm64) appendBridges(devices []govmmQemu.Device, bridges []types.PCIBridge) []govmmQemu.Device {
return genericAppendBridges(devices, bridges, q.machineType)
}
27 changes: 27 additions & 0 deletions virtcontainers/qemu_arm64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,30 @@ func TestMaxQemuVCPUs(t *testing.T) {
assert.Equal(d.expectedResult, vCPUs)
}
}

func TestQemuArm64AppendBridges(t *testing.T) {
var devices []govmmQemu.Device
assert := assert.New(t)

arm64 := newTestQemu(QemuVirt)

bridges := arm64.bridges(1)
assert.Len(bridges, 1)

devices = []govmmQemu.Device{}
devices = arm64.appendBridges(devices, bridges)
assert.Len(devices, 1)

expectedOut := []govmmQemu.Device{
govmmQemu.BridgeDevice{
Type: govmmQemu.PCIBridge,
Bus: defaultBridgeBus,
ID: bridges[0].ID,
Chassis: 1,
SHPC: true,
Addr: "2",
},
}

assert.Equal(expectedOut, devices)
}
2 changes: 0 additions & 2 deletions virtcontainers/qemu_ppc64le.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const defaultQemuMachineType = QemuPseries

const defaultQemuMachineOptions = "accel=kvm,usb=off"

const defaultPCBridgeBus = "pci.0"

const defaultMemMaxPPC64le = 32256 // Restrict MemMax to 32Gb on PPC64le

var qemuPaths = map[string]string{
Expand Down
2 changes: 0 additions & 2 deletions virtcontainers/qemu_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const defaultQemuMachineType = QemuCCWVirtio

const defaultQemuMachineOptions = "accel=kvm"

const defaultPCBridgeBus = "pci.0"

const VirtioSerialCCW = "virtio-serial-ccw"

var qemuPaths = map[string]string{
Expand Down

0 comments on commit c2bdeb1

Please sign in to comment.