Skip to content

Commit

Permalink
Add the EnableVncShimVm flag
Browse files Browse the repository at this point in the history
We differentiate between the access to the edge application and the
shim VM:

- `enableVNC` is used to enable VNC for the edge application
- `enableVncShimVm` is used to enable VNC for the shim VM

This differentiation is need, because currently shim VM doesn't support
any user authentication, so anybody able to access the VNC port can
access the shim VM. This way VNC access to the shim VM stays disabled
by default unless explicitly enabled by the controller.

VNC is enabled in QEMU if either of the flags is set, but the
virtconsole is only enabled if the `enableVNCshimVm` flag is set.

Signed-off-by: Paul Gaiduk <paulg@zededa.com>
  • Loading branch information
europaul committed Apr 4, 2024
1 parent 4f80b11 commit 888bc6e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/pillar/cmd/domainmgr/domainmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2211,6 +2211,7 @@ func handleModify(ctx *domainContext, key string,
func updateStatusFromConfig(status *types.DomainStatus, config types.DomainConfig) {
status.VirtualizationMode = config.VirtualizationModeOrDefault()
status.EnableVnc = config.EnableVnc
status.EnableVncShimVM = config.EnableVncShimVM
status.VncDisplay = config.VncDisplay
status.VncPasswd = config.VncPasswd
status.DisableLogs = config.DisableLogs
Expand Down
7 changes: 7 additions & 0 deletions pkg/pillar/cmd/zedagent/parseconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ func parseAppInstanceConfig(getconfigCtx *getconfigContext,
appInstance.FixedResources.MaxCpus = int(cfgApp.Fixedresources.Maxcpus)
appInstance.FixedResources.VirtualizationMode = types.VmMode(cfgApp.Fixedresources.VirtualizationMode)
appInstance.FixedResources.EnableVnc = cfgApp.Fixedresources.EnableVnc
appInstance.FixedResources.EnableVncShimVM = cfgApp.Fixedresources.EnableVncShimVm
appInstance.FixedResources.VncDisplay = cfgApp.Fixedresources.VncDisplay
appInstance.FixedResources.VncPasswd = cfgApp.Fixedresources.VncPasswd
appInstance.DisableLogs = cfgApp.Fixedresources.DisableLogs
Expand Down Expand Up @@ -2614,6 +2615,12 @@ func checkAndPublishAppInstanceConfig(getconfigCtx *getconfigContext,
config.Errors = append(config.Errors, err.Error())
}

if config.FixedResources.EnableVnc == false && config.FixedResources.EnableVncShimVM == true {
err := fmt.Errorf("VNC shim VM enabled but VNC disabled for app instance %s", config.UUIDandVersion.UUID)
log.Error(err)
config.Errors = append(config.Errors, err.Error())
}

pub.Publish(key, config)
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/pillar/hypervisor/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ const qemuConfTemplate = `# This file is automatically generated by domainmgr
chardev = "charserial1"
name = "org.lfedge.eve.console.prime"
{{- if .DomainConfig.EnableVncShimVM}}
[chardev "charserial2"]
backend = "vc"
[device]
driver = "virtconsole"
chardev = "charserial2"
name = "org.lfedge.eve.console.prime.forvnc"
{{- end -}}
{{end}}
{{if .DomainConfig.EnableVnc}}
Expand Down
8 changes: 7 additions & 1 deletion pkg/pillar/types/domainmgrtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (config DomainConfig) LogCreate(logBase *base.LogObject) {
}
logObject.CloneAndAddField("activate", config.Activate).
AddField("enable-vnc", config.EnableVnc).
AddField("enable-vnc-shim-vm", config.EnableVncShimVM).
Noticef("domain config create")
}

Expand All @@ -165,12 +166,15 @@ func (config DomainConfig) LogModify(logBase *base.LogObject, old interface{}) {
logObject.Clone().Fatalf("LogModify: Old object interface passed is not of DomainConfig type")
}
if oldConfig.Activate != config.Activate ||
oldConfig.EnableVnc != config.EnableVnc {
oldConfig.EnableVnc != config.EnableVnc ||
oldConfig.EnableVncShimVM != config.EnableVncShimVM {

logObject.CloneAndAddField("activate", config.Activate).
AddField("enable-vnc", config.EnableVnc).
AddField("enable-vnc-shim-vm", config.EnableVncShimVM).
AddField("old-activate", oldConfig.Activate).
AddField("old-enable-vnc", oldConfig.EnableVnc).
AddField("old-enable-vnc-shim-vm", oldConfig.EnableVncShimVM).
Noticef("domain config modify")
} else {
// XXX remove?
Expand All @@ -185,6 +189,7 @@ func (config DomainConfig) LogDelete(logBase *base.LogObject) {
config.UUIDandVersion.UUID, config.LogKey())
logObject.CloneAndAddField("activate", config.Activate).
AddField("enable-vnc", config.EnableVnc).
AddField("enable-vnc-shim-vm", config.EnableVncShimVM).
Noticef("domain config delete")

base.DeleteLogObject(logBase, config.LogKey())
Expand Down Expand Up @@ -229,6 +234,7 @@ type VmConfig struct {
VncPasswd string
CPUsPinned bool
VMMMaxMem int // in kbytes
EnableVncShimVM bool
}

type VmMode uint8
Expand Down

0 comments on commit 888bc6e

Please sign in to comment.