Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add config for FML mode custom resolution #4264

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
27 changes: 27 additions & 0 deletions pkg/pillar/cmd/domainmgr/domainmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
uuid "github.com/satori/go.uuid"
"github.com/sirupsen/logrus"
"github.com/vishvananda/netlink"
"gopkg.in/yaml.v2"
)

const (
Expand Down Expand Up @@ -2067,6 +2068,15 @@ func configToStatus(ctx *domainContext, config types.DomainConfig,
return fmt.Errorf("failed to fetch cloud-init userdata: %s",
err)
}

// Set FML custom resolution if it is set in cloud-init config,
// xxx : this is hack and this should be removed, this should be
// part of the vm config, but desprate times call for desprate measures.
status.FmlCustomResolution = types.FmlResolutionUnset
if cloudconfig.IsCloudConfig(ciStr) {
setFmlCustomResolution(ciStr, status)
}

if status.OCIConfigDir != "" { // If AppInstance is a container, we need to parse cloud-init config and apply the supported parts
if cloudconfig.IsCloudConfig(ciStr) { // treat like the cloud-init config
cc, err := cloudconfig.ParseCloudConfig(ciStr)
Expand Down Expand Up @@ -2113,6 +2123,23 @@ func configToStatus(ctx *domainContext, config types.DomainConfig,
return nil
}

func setFmlCustomResolution(config string, status *types.DomainStatus) {
var cloudinit map[string]interface{}
err := yaml.Unmarshal([]byte(config), &cloudinit)
if err != nil {
log.Errorf("error parsing cloud-config YAML: %v", err)
return
}

status.FmlCustomResolution = types.FmlResolutionUnset
if val, ok := cloudinit[string(types.FmlCustomResolution)]; ok {
if fmlCustomResolution, valid := val.(string); valid {
status.FmlCustomResolution = fmlCustomResolution
log.Noticef("FML resolution is set to: %s", status.FmlCustomResolution)
}
}
}

// Check for errors and reserve any assigned adapters.
// Please note that reservation is done only by setting UsedByUUID to the application UUID.
// The actual call to PCIReserve() is done later by doAssignIoAdaptersToDomain().
Expand Down
36 changes: 36 additions & 0 deletions pkg/pillar/hypervisor/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,14 @@ func (ctx KvmContext) Setup(status types.DomainStatus, config types.DomainConfig
domainName := status.DomainName
domainUUID := status.UUIDandVersion.UUID

// this needs to be reworked to fit into the OVMF_VAR changes.
res, err := getFmlCustomResolution(&status, globalConfig)
if err != nil {
logError("failed to get fml custom resolution: %v", err)
} else {
logError("fml custom resolution is set to: %s", res)
}

// check if vTPM is enabled
swtpmCtrlSock := ""
if status.VirtualTPM {
Expand Down Expand Up @@ -791,6 +799,34 @@ func isVncShimVMEnabled(
return config.EnableVnc && (config.EnableVncShimVM || globalShimVnc)
}

func getFmlCustomResolution(status *types.DomainStatus, globalConfig *types.ConfigItemValueMap) (string, error) {
fmlResolutions := status.FmlCustomResolution
// if not set in the domain status, try to get it from the global config
if fmlResolutions == types.FmlResolutionUnset {
if globalConfig != nil {
item, ok := globalConfig.GlobalSettings[types.FmlCustomResolution]
if ok {
fmlResolutions = item.StringValue()
}
}
}

// debug, remove later
logError("getFmlCustomResolution -> FmlResolution is set to: %s", fmlResolutions)

// validate the resolution
switch fmlResolutions {
case types.FmlResolution800x600,
types.FmlResolution1024x768,
types.FmlResolution1280x800,
types.FmlResolution1920x1080,
types.FmlResolutionUnset:
return fmlResolutions, nil
}

return "", fmt.Errorf("invalid fml resolution %s", fmlResolutions)
}

// CreateDomConfig creates a domain config (a qemu config file,
// typically named something like xen-%d.cfg)
func (ctx KvmContext) CreateDomConfig(domainName string,
Expand Down
3 changes: 3 additions & 0 deletions pkg/pillar/types/domainmgrtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ type DomainStatus struct {
// VirtualTPM is a flag to signal the hypervisor implementation
// that vTPM is available for the domain.
VirtualTPM bool
// FmlCustomResolution is the custom resolution for FML mode,
// xxx: this should be moved to VmConfig
FmlCustomResolution string
}

func (status DomainStatus) Key() string {
Expand Down
16 changes: 16 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,19 @@ var (
SyslogKernelDefaultLogLevel = "info"
)

var (
// FmlResolutionUnset is a string to indicate that custom resolution is not set
FmlResolutionUnset = "unset"
// FmlResolution800x600 is a string to indicate 800x600 resolution
FmlResolution800x600 = "800x600"
// FmlResolution1024x768 is a string to indicate 1024x768 resolution
FmlResolution1024x768 = "1024x768"
// FmlResolution1280x800 is a string to indicate 1280x720 resolution
FmlResolution1280x800 = "1280x800"
// 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 +926,7 @@ func NewConfigItemSpecMap() ConfigItemSpecMap {
configItemSpecMap.AddStringItem(DefaultRemoteLogLevel, "info", validateLogrusLevel)
configItemSpecMap.AddStringItem(SyslogLogLevel, "info", validateSyslogKernelLevel)
configItemSpecMap.AddStringItem(KernelLogLevel, "info", validateSyslogKernelLevel)
configItemSpecMap.AddStringItem(FmlCustomResolution, FmlResolutionUnset, blankValidator)

// Add Agent Settings
configItemSpecMap.AddAgentSettingStringItem(LogLevel, "info", validateLogrusLevel)
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
Loading