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

Commit

Permalink
virtcontainers: support vm factory in QEMU 4
Browse files Browse the repository at this point in the history
Turn off VMX if vm-factory is enabled since it's not migratable yet.
see https://bugzilla.redhat.com/show_bug.cgi?id=1689216

fixes #1747

Signed-off-by: Julio Montes <[email protected]>
  • Loading branch information
Julio Montes committed Jun 3, 2019
1 parent 3d8803b commit b780c16
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
18 changes: 17 additions & 1 deletion virtcontainers/qemu_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
type qemuAmd64 struct {
// inherit from qemuArchBase, overwrite methods if needed
qemuArchBase

vmFactory bool
}

const defaultQemuPath = "/usr/bin/qemu-system-x86_64"
Expand Down Expand Up @@ -89,8 +91,13 @@ func newQemuArch(config HypervisorConfig) qemuArch {
machineType = defaultQemuMachineType
}

factory := false
if config.BootToBeTemplate || config.BootFromTemplate {
factory = true
}

q := &qemuAmd64{
qemuArchBase{
qemuArchBase: qemuArchBase{
machineType: machineType,
memoryOffset: config.MemOffset,
qemuPaths: qemuPaths,
Expand All @@ -99,6 +106,7 @@ func newQemuArch(config HypervisorConfig) qemuArch {
kernelParamsDebug: kernelParamsDebug,
kernelParams: kernelParams,
},
vmFactory: factory,
}

q.handleImagePath(config)
Expand Down Expand Up @@ -129,6 +137,14 @@ func (q *qemuAmd64) cpuModel() string {
if q.nestedRun {
cpuModel += ",pmu=off"
}

// VMX is not migratable yet.
// issue: https://github.com/kata-containers/runtime/issues/1750
if q.vmFactory {
virtLog.WithField("subsystem", "qemuAmd64").Warn("VMX is not migratable yet: turning it off")
cpuModel += ",vmx=off"
}

return cpuModel
}

Expand Down
8 changes: 8 additions & 0 deletions virtcontainers/qemu_amd64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ func TestQemuAmd64CPUModel(t *testing.T) {
expectedOut = defaultCPUModel + ",pmu=off"
model = amd64.cpuModel()
assert.Equal(expectedOut, model)

amd64.disableNestingChecks()
base, ok := amd64.(*qemuAmd64)
assert.True(ok)
base.vmFactory = true
expectedOut = defaultCPUModel + ",vmx=off"
model = amd64.cpuModel()
assert.Equal(expectedOut, model)
}

func TestQemuAmd64MemoryTopology(t *testing.T) {
Expand Down

0 comments on commit b780c16

Please sign in to comment.