mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
qemu: Add a RTC field to the Config structure
The RTC structure represents the guest Real Time Clock configuration. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
c63ec0965a
commit
612a5a9e5d
37
qemu.go
37
qemu.go
@ -88,6 +88,18 @@ type FSDevice struct {
|
||||
SecurityModel string
|
||||
}
|
||||
|
||||
// RTC represents a qemu Real Time Clock configuration.
|
||||
type RTC struct {
|
||||
// Base is the RTC start time.
|
||||
Base string
|
||||
|
||||
// Clock is the is the RTC clock driver.
|
||||
Clock string
|
||||
|
||||
// DriftFix is the drift fixing mechanism.
|
||||
DriftFix string
|
||||
}
|
||||
|
||||
// QMPSocket represents a qemu QMP socket configuration.
|
||||
type QMPSocket struct {
|
||||
// Type is the socket type (e.g. "unix").
|
||||
@ -178,6 +190,9 @@ type Config struct {
|
||||
// FilesystemDevices is a list of filesystem devices.
|
||||
FilesystemDevices []FSDevice
|
||||
|
||||
// RTC is the qemu Real Time Clock configuration
|
||||
RTC RTC
|
||||
|
||||
// UUID is the qemu process UUID.
|
||||
UUID string
|
||||
|
||||
@ -397,6 +412,27 @@ func appendCPUs(params []string, config Config) []string {
|
||||
return params
|
||||
}
|
||||
|
||||
func appendRTC(params []string, config Config) []string {
|
||||
if config.RTC.Base != "" {
|
||||
var RTCParams []string
|
||||
|
||||
RTCParams = append(RTCParams, fmt.Sprintf("base=%s", config.RTC.Base))
|
||||
|
||||
if config.RTC.DriftFix != "" {
|
||||
RTCParams = append(RTCParams, fmt.Sprintf(",driftfix=%s", config.RTC.DriftFix))
|
||||
}
|
||||
|
||||
if config.RTC.Clock != "" {
|
||||
RTCParams = append(RTCParams, fmt.Sprintf(",clock=%s", config.RTC.Clock))
|
||||
}
|
||||
|
||||
params = append(params, "-rtc")
|
||||
params = append(params, strings.Join(RTCParams, ""))
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
func appendKernel(params []string, config Config) []string {
|
||||
if config.Kernel.Path != "" {
|
||||
params = append(params, "-kernel")
|
||||
@ -434,6 +470,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) {
|
||||
params = appendCharDevices(params, config)
|
||||
params = appendFilesystemDevices(params, config)
|
||||
params = appendObjects(params, config)
|
||||
params = appendRTC(params, config)
|
||||
params = appendKernel(params, config)
|
||||
|
||||
params = append(params, config.ExtraParams...)
|
||||
|
Loading…
Reference in New Issue
Block a user