mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
qemu: Add a Knobs field to the Config structure
The Knobs structure groups all qemu isolated boolean settings. For now this is -no-user-config, -no-defaults and -nographic. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
fe1bdcd2f7
commit
ebfa382d2e
34
qemu.go
34
qemu.go
@ -163,6 +163,18 @@ type Kernel struct {
|
|||||||
Params string
|
Params string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Knobs regroups a set of qemu boolean settings
|
||||||
|
type Knobs struct {
|
||||||
|
// NoUserConfig prevents qemu from loading user config files.
|
||||||
|
NoUserConfig bool
|
||||||
|
|
||||||
|
// NoDefaults prevents qemu from creating default devices.
|
||||||
|
NoDefaults bool
|
||||||
|
|
||||||
|
// NoGraphic completely disables graphic output.
|
||||||
|
NoGraphic bool
|
||||||
|
}
|
||||||
|
|
||||||
// Config is the qemu configuration structure.
|
// Config is the qemu configuration structure.
|
||||||
// It allows for passing custom settings and parameters to the qemu API.
|
// It allows for passing custom settings and parameters to the qemu API.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@ -214,9 +226,12 @@ type Config struct {
|
|||||||
// SMP is the quest multi processors configuration.
|
// SMP is the quest multi processors configuration.
|
||||||
SMP SMP
|
SMP SMP
|
||||||
|
|
||||||
// GlobalParam is the -global parameter
|
// GlobalParam is the -global parameter.
|
||||||
GlobalParam string
|
GlobalParam string
|
||||||
|
|
||||||
|
// Knobs is a set of qemu boolean settings.
|
||||||
|
Knobs Knobs
|
||||||
|
|
||||||
// FDs is a list of open file descriptors to be passed to the spawned qemu process
|
// FDs is a list of open file descriptors to be passed to the spawned qemu process
|
||||||
FDs []*os.File
|
FDs []*os.File
|
||||||
}
|
}
|
||||||
@ -482,6 +497,22 @@ func appendKernel(params []string, config Config) []string {
|
|||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func appendKnobs(params []string, config Config) []string {
|
||||||
|
if config.Knobs.NoUserConfig == true {
|
||||||
|
params = append(params, "-no-user-config")
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Knobs.NoDefaults == true {
|
||||||
|
params = append(params, "-nodefaults")
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Knobs.NoGraphic == true {
|
||||||
|
params = append(params, "-nographic")
|
||||||
|
}
|
||||||
|
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
|
||||||
// LaunchQemu can be used to launch a new qemu instance.
|
// LaunchQemu can be used to launch a new qemu instance.
|
||||||
//
|
//
|
||||||
// The Config parameter contains a set of qemu parameters and settings.
|
// The Config parameter contains a set of qemu parameters and settings.
|
||||||
@ -509,6 +540,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) {
|
|||||||
params = appendKernel(params, config)
|
params = appendKernel(params, config)
|
||||||
params = appendGlobalParam(params, config)
|
params = appendGlobalParam(params, config)
|
||||||
params = appendVGA(params, config)
|
params = appendVGA(params, config)
|
||||||
|
params = appendKnobs(params, config)
|
||||||
|
|
||||||
return LaunchCustomQemu(config.Ctx, config.Path, params, config.FDs, logger)
|
return LaunchCustomQemu(config.Ctx, config.Path, params, config.FDs, logger)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user