mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-22 13:38:26 +00:00
qemu: Add a Kernel field to the Config structure
The Kernel structure holds the guest kernel configuration: its path and its parameters. This is the kernel qemu will boot the VM from. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
b973bc59fb
commit
518ba627b1
27
qemu.go
27
qemu.go
@ -87,6 +87,15 @@ type QMPSocket struct {
|
||||
NoWait bool
|
||||
}
|
||||
|
||||
// Kernel is the guest kernel configuration structure.
|
||||
type Kernel struct {
|
||||
// Path is the guest kernel path on the host filesystem.
|
||||
Path string
|
||||
|
||||
// Params is the kernel parameters string.
|
||||
Params string
|
||||
}
|
||||
|
||||
// Config is the qemu configuration structure.
|
||||
// It allows for passing custom settings and parameters to the qemu API.
|
||||
type Config struct {
|
||||
@ -117,6 +126,9 @@ type Config struct {
|
||||
// Objects is a list of objects for qemu to create.
|
||||
Objects []Object
|
||||
|
||||
// Kernel is the guest kernel configuration.
|
||||
Kernel Kernel
|
||||
|
||||
// ExtraParams is a slice of options to pass to qemu.
|
||||
ExtraParams []string
|
||||
|
||||
@ -233,6 +245,20 @@ func appendObjects(params []string, config Config) []string {
|
||||
return params
|
||||
}
|
||||
|
||||
func appendKernel(params []string, config Config) []string {
|
||||
if config.Kernel.Path != "" {
|
||||
params = append(params, "-kernel")
|
||||
params = append(params, config.Kernel.Path)
|
||||
|
||||
if config.Kernel.Params != "" {
|
||||
params = append(params, "-append")
|
||||
params = append(params, config.Kernel.Params)
|
||||
}
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
// LaunchQemu can be used to launch a new qemu instance.
|
||||
//
|
||||
// The Config parameter contains a set of qemu parameters and settings.
|
||||
@ -251,6 +277,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) {
|
||||
params = appendQMPSocket(params, config)
|
||||
params = appendDevices(params, config)
|
||||
params = appendObjects(params, config)
|
||||
params = appendKernel(params, config)
|
||||
|
||||
params = append(params, config.ExtraParams...)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user