Skip to content

Commit

Permalink
Merge pull request kata-containers#9 from devimc/qemu/extraOptions
Browse files Browse the repository at this point in the history
qemu: add extra options for the machine type
  • Loading branch information
Mark Ryan authored Feb 12, 2018
2 parents 065d1d2 + 693d954 commit d602561
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ type Machine struct {

// Acceleration are the machine acceleration options to be used by qemu.
Acceleration string

// Options are options for the machine type
// For example gic-version=host and usb=off
Options string
}

// Device is the qemu device interface.
Expand Down Expand Up @@ -1240,6 +1244,10 @@ func (config *Config) appendMachine() {
machineParams = append(machineParams, fmt.Sprintf(",accel=%s", config.Machine.Acceleration))
}

if config.Machine.Options != "" {
machineParams = append(machineParams, fmt.Sprintf(",%s", config.Machine.Options))
}

config.qemuParams = append(config.qemuParams, "-machine")
config.qemuParams = append(config.qemuParams, strings.Join(machineParams, ""))
}
Expand Down
10 changes: 8 additions & 2 deletions qemu/qemu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,20 @@ func testAppend(structure interface{}, expected string, t *testing.T) {
}
}

var machineString = "-machine pc-lite,accel=kvm,kernel_irqchip,nvdimm"

func TestAppendMachine(t *testing.T) {
machineString := "-machine pc-lite,accel=kvm,kernel_irqchip,nvdimm"
machine := Machine{
Type: "pc-lite",
Acceleration: "kvm,kernel_irqchip,nvdimm",
}
testAppend(machine, machineString, t)

machineString = "-machine pc-lite,accel=kvm,kernel_irqchip,nvdimm,gic-version=host,usb=off"
machine = Machine{
Type: "pc-lite",
Acceleration: "kvm,kernel_irqchip,nvdimm",
Options: "gic-version=host,usb=off",
}
testAppend(machine, machineString, t)
}

Expand Down

0 comments on commit d602561

Please sign in to comment.