mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
qemu: Add a Memory field to the Config structure
The Memory field holds the guest memory configuration. It is used to define the current and maximum RAM is made available to the guest and how this amount of RAM is splitted into several slots. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
b198bc67e7
commit
7cf386a81c
40
qemu.go
40
qemu.go
@ -103,6 +103,21 @@ type QMPSocket struct {
|
||||
NoWait bool
|
||||
}
|
||||
|
||||
// Memory is the guest memory configuration structure.
|
||||
type Memory struct {
|
||||
// Size is the amount of memory made available to the guest.
|
||||
// It should be suffixed with M or G for sizes in megabytes or
|
||||
// gigabytes respectively.
|
||||
Size string
|
||||
|
||||
// Slots is the amount of memory slots made available to the guest.
|
||||
Slots uint8
|
||||
|
||||
// MaxMem is the maximum amount of memory that can be made available
|
||||
// to the guest through e.g. hot pluggable memory.
|
||||
MaxMem string
|
||||
}
|
||||
|
||||
// Kernel is the guest kernel configuration structure.
|
||||
type Kernel struct {
|
||||
// Path is the guest kernel path on the host filesystem.
|
||||
@ -154,6 +169,9 @@ type Config struct {
|
||||
// Kernel is the guest kernel configuration.
|
||||
Kernel Kernel
|
||||
|
||||
// Memory is the guest memory configuration.
|
||||
Memory Memory
|
||||
|
||||
// ExtraParams is a slice of options to pass to qemu.
|
||||
ExtraParams []string
|
||||
|
||||
@ -315,6 +333,27 @@ func appendUUID(params []string, config Config) []string {
|
||||
return params
|
||||
}
|
||||
|
||||
func appendMemory(params []string, config Config) []string {
|
||||
if config.Memory.Size != "" {
|
||||
var memoryParams []string
|
||||
|
||||
memoryParams = append(memoryParams, config.Memory.Size)
|
||||
|
||||
if config.Memory.Slots > 0 {
|
||||
memoryParams = append(memoryParams, fmt.Sprintf(",slots=%d", config.Memory.Slots))
|
||||
}
|
||||
|
||||
if config.Memory.MaxMem != "" {
|
||||
memoryParams = append(memoryParams, fmt.Sprintf(",maxmem=%s", config.Memory.MaxMem))
|
||||
}
|
||||
|
||||
params = append(params, "-m")
|
||||
params = append(params, strings.Join(memoryParams, ""))
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
func appendKernel(params []string, config Config) []string {
|
||||
if config.Kernel.Path != "" {
|
||||
params = append(params, "-kernel")
|
||||
@ -346,6 +385,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) {
|
||||
params = appendMachineParams(params, config)
|
||||
params = appendCPUModel(params, config)
|
||||
params = appendQMPSocket(params, config)
|
||||
params = appendMemory(params, config)
|
||||
params = appendDevices(params, config)
|
||||
params = appendCharDevices(params, config)
|
||||
params = appendFilesystemDevices(params, config)
|
||||
|
Loading…
Reference in New Issue
Block a user