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 <[email protected]>
  • Loading branch information
shjala committed Sep 17, 2024
1 parent af37037 commit b093cac
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/CONFIG-PROPERTIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
| 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 one of [predefined](/pkg/pillar/types/global.go) FmlResolution* values. |
| 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 |
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"
// FmlResolution1920x1080 is a string to indicate 1280x720 resolution
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
1 change: 1 addition & 0 deletions pkg/pillar/types/global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func TestNewConfigItemSpecMap(t *testing.T) {
DefaultRemoteLogLevel,
SyslogLogLevel,
KernelLogLevel,
FmlCustomResolution,
DisableDHCPAllOnesNetMask,
ProcessCloudInitMultiPart,
NetDumpEnable,
Expand Down

0 comments on commit b093cac

Please sign in to comment.