mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
qemu: Group all machine configurations into one structure
Here we group the machine type and acceleration together as they are defined through the same qemu parameter (-machine). Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
d94b5af875
commit
15bce61a90
32
qemu.go
32
qemu.go
@ -34,6 +34,15 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Machine describes the machine type qemu will emulate.
|
||||||
|
type Machine struct {
|
||||||
|
// Type is the machine type to be used by qemu.
|
||||||
|
Type string
|
||||||
|
|
||||||
|
// Acceleration are the machine acceleration options to be used by qemu.
|
||||||
|
Acceleration string
|
||||||
|
}
|
||||||
|
|
||||||
// Device describes a device to be created by qemu.
|
// Device describes a device to be created by qemu.
|
||||||
type Device struct {
|
type Device struct {
|
||||||
// Type is the qemu device type
|
// Type is the qemu device type
|
||||||
@ -166,11 +175,8 @@ type Config struct {
|
|||||||
// Name is the qemu guest name
|
// Name is the qemu guest name
|
||||||
Name string
|
Name string
|
||||||
|
|
||||||
// MachineType is the machine type to be used by qemu.
|
// Machine
|
||||||
MachineType string
|
Machine Machine
|
||||||
|
|
||||||
// MachineTypeAcceleration are the machine acceleration option to be used by qemu.
|
|
||||||
MachineTypeAcceleration string
|
|
||||||
|
|
||||||
// CPUModel is the CPU model to be used by qemu.
|
// CPUModel is the CPU model to be used by qemu.
|
||||||
CPUModel string
|
CPUModel string
|
||||||
@ -227,10 +233,18 @@ func appendName(params []string, config Config) []string {
|
|||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendMachineParams(params []string, config Config) []string {
|
func appendMachine(params []string, config Config) []string {
|
||||||
if config.MachineType != "" && config.MachineTypeAcceleration != "" {
|
if config.Machine.Type != "" {
|
||||||
|
var machineParams []string
|
||||||
|
|
||||||
|
machineParams = append(machineParams, config.Machine.Type)
|
||||||
|
|
||||||
|
if config.Machine.Acceleration != "" {
|
||||||
|
machineParams = append(machineParams, fmt.Sprintf(",accel=%s", config.Machine.Acceleration))
|
||||||
|
}
|
||||||
|
|
||||||
params = append(params, "-machine")
|
params = append(params, "-machine")
|
||||||
params = append(params, fmt.Sprintf("%s,accel=%s", config.MachineType, config.MachineTypeAcceleration))
|
params = append(params, strings.Join(machineParams, ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
return params
|
return params
|
||||||
@ -485,7 +499,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) {
|
|||||||
|
|
||||||
params = appendName(params, config)
|
params = appendName(params, config)
|
||||||
params = appendUUID(params, config)
|
params = appendUUID(params, config)
|
||||||
params = appendMachineParams(params, config)
|
params = appendMachine(params, config)
|
||||||
params = appendCPUModel(params, config)
|
params = appendCPUModel(params, config)
|
||||||
params = appendQMPSocket(params, config)
|
params = appendQMPSocket(params, config)
|
||||||
params = appendMemory(params, config)
|
params = appendMemory(params, config)
|
||||||
|
Loading…
Reference in New Issue
Block a user