Skip to content

Commit

Permalink
Add global config for FML mode custom resolution
Browse files Browse the repository at this point in the history
Add a new global config value app.fml.resolution to set custom resolution
for FML apps. This is a string value in the format of "widthxheight".

Signed-off-by: Shahriyar Jalayeri <shahriyar@zededa.com>
  • Loading branch information
shjala committed Sep 17, 2024
1 parent af37037 commit 6a083e4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/CONFIG-PROPERTIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
| app.allow.vnc | boolean | false (only local access) | allow access to EVE's VNC ports from external IPs |
| app.fml.resolution | string | notset | Set system-wide value of forced resolution for applications running in FML mode, it can be of [predefined](/pkg/pillar/types/global.go) FmlResolution* |
| timer.config.interval | integer in seconds | 60 | how frequently device gets config |
| timer.cert.interval | integer in seconds | 1 day (24*3600) | how frequently device checks for new controller certificates |
| timer.metric.interval | integer in seconds | 60 | how frequently device reports metrics |
| timer.metric.diskscan.interval | integer in seconds | 300 | how frequently device should scan the disk for metrics |
| timer.location.cloud.interval | integer in seconds | 1 hour | how frequently device reports geographic location information to controller |
| timer.location.app.interval | integer in seconds | 20 | how frequently device reports geographic location information to applications (to local profile server and to other apps via meta-data server) |
| timer.location.app.interval | integer in seconds | 20 | how frequently device reports geographic location information to applications (to local proπfile server and to other apps via meta-data server) |
| timer.ntpsources.interval | integer in seconds | 10 minutes | how frequently device forcibly reports information about NTP sources to which EVE has established a connection for the NTP synchronization. Requests are also sent to the controller if the list of NTP peers or NTP peer fields, such as mode, state, have changed. |
| timer.send.timeout | timer in seconds | 120 | time for each http/send |
| timer.dial.timeout | timer in seconds | 10 | maximum time allowed to establish connection |
Expand Down
29 changes: 29 additions & 0 deletions pkg/pillar/hypervisor/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,17 @@ func isVncShimVMEnabled(
return config.EnableVnc && (config.EnableVncShimVM || globalShimVnc)
}

func getFmlCustomResolution(globalConfig *types.ConfigItemValueMap) (string, error) {
if globalConfig != nil {
item, ok := globalConfig.GlobalSettings[types.FmlCustomResolution]
if ok {
return item.StringValue(), nil
}
}

return "", fmt.Errorf("no custom resolution found")
}

// CreateDomConfig creates a domain config (a qemu config file,
// typically named something like xen-%d.cfg)
func (ctx KvmContext) CreateDomConfig(domainName string,
Expand All @@ -796,6 +807,24 @@ func (ctx KvmContext) CreateDomConfig(domainName string,
isVncShimVMEnabled(globalConfig, config)
tmplCtx.DomainConfig.DisplayName = domainName

fmlResolutions, err := getFmlCustomResolution(globalConfig)
if err != nil {
// this should never happen, but just in case
logError("failed to get fml-mode custom resolution, reverting back to notset. error : %v", err)
fmlResolutions = types.FmlResolutionNotSet
}

if fmlResolutions != types.FmlResolutionNotSet {
// logError for visibility
logError("Setting FML resolution to : %s", fmlResolutions)
if fmlResolutions == types.FmlResolution1024x768 {
// do what ever else needed, like set the custom ovmf vars
}
if fmlResolutions == types.FmlResolution1920x1080 {
// do what ever else needed, like set the custom ovmf vars
}
}

// render global device model settings
t, _ := template.New("qemu").Parse(qemuConfTemplate)
if err := t.Execute(file, tmplCtx); err != nil {
Expand Down
21 changes: 21 additions & 0 deletions pkg/pillar/types/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ const (
SyslogLogLevel GlobalSettingKey = "debug.syslog.loglevel"
// KernelLogLevel global setting key
KernelLogLevel GlobalSettingKey = "debug.kernel.loglevel"
// FmlCustomResolution global setting key
FmlCustomResolution GlobalSettingKey = "app.fml.resolution"

// XXX Temporary flag to disable RFC 3442 classless static route usage
DisableDHCPAllOnesNetMask GlobalSettingKey = "debug.disable.dhcp.all-ones.netmask"
Expand Down Expand Up @@ -358,6 +360,15 @@ var (
SyslogKernelDefaultLogLevel = "info"
)

var (
// FmlResolutionNotSet is a string to indicate that custom resolution is not set
FmlResolutionNotSet = "notset"
// FmlResolution1024x768 is a string to indicate 1024x768 resolution
FmlResolution1024x768 = "1024x768"
// FmlResolution1280x720 is a string to indicate 1280x720 resolution

Check failure on line 368 in pkg/pillar/types/global.go

View workflow job for this annotation

GitHub Actions / yetus

revive: comment on exported var FmlResolution1920x1080 should be of the form "FmlResolution1920x1080 ..." https://revive.run/r#exported
FmlResolution1920x1080 = "1920x1080"
)

// ConfigItemSpec - Defines what a specification for a configuration should be
type ConfigItemSpec struct {
Key string
Expand Down Expand Up @@ -911,6 +922,7 @@ func NewConfigItemSpecMap() ConfigItemSpecMap {
configItemSpecMap.AddStringItem(DefaultRemoteLogLevel, "info", validateLogrusLevel)
configItemSpecMap.AddStringItem(SyslogLogLevel, "info", validateSyslogKernelLevel)
configItemSpecMap.AddStringItem(KernelLogLevel, "info", validateSyslogKernelLevel)
configItemSpecMap.AddStringItem(FmlCustomResolution, FmlResolutionNotSet, validateCustomResolution)

// Add Agent Settings
configItemSpecMap.AddAgentSettingStringItem(LogLevel, "info", validateLogrusLevel)
Expand Down Expand Up @@ -943,6 +955,15 @@ func validateSyslogKernelLevel(level string) error {
return nil
}

func validateCustomResolution(res string) error {
// it can be notset or one of the predefined resolutions
if res == FmlResolutionNotSet || res == FmlResolution1024x768 || res == FmlResolution1920x1080 {
return nil
}

return fmt.Errorf("validateCustomResolution: invalid resolution '%v'", res)
}

// blankValidator - A validator that accepts any string
func blankValidator(s string) error {
return nil
Expand Down

0 comments on commit 6a083e4

Please sign in to comment.