Skip to content
Merged
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
9 changes: 7 additions & 2 deletions pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/bin/sh

infinite_loop() {
while true; do
$@
stop=0
child=""
trap 'stop=1; [ -n "$child" ] && kill $child 2> /dev/null' USR1
while [ "$stop" -eq 0 ]; do
$@ &
child=$!
wait "$child"
done
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/pillar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ARG BUILD_PKGS_BASE="git gcc linux-headers libc-dev make linux-pam-dev m4 findut
ARG EVE_ALPINE_IMAGE=lfedge/eve-alpine:745ae9066273c73b0fd879c4ba4ff626a8392d04

FROM lfedge/eve-uefi:b3ef9ca37c99439c776673aeba83c52ea8b84626 AS uefi-build
FROM lfedge/eve-dom0-ztools:728e9ccb619ccc27368fa93c7121200d85a81f88 AS zfs
FROM lfedge/eve-dom0-ztools:5260091b794f9466d08cb33b8c613a6a8398c16a AS zfs
RUN mkdir /out
# copy zfs-related files from dom0-ztools using prepared list of files
RUN while read -r x; do \
Expand Down
38 changes: 35 additions & 3 deletions pkg/pillar/cmd/domainmgr/domainmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,9 @@

if !domainCtx.setInitialConsoleAccess {
log.Functionf("GCComplete but not setInitialConsoleAccess => first boot")
// Enable Console
domainCtx.consoleAccess = true
// Auto-enable the console only while the device is not yet
// onboarded to a controller.
domainCtx.consoleAccess = !isDeviceOnboarded(ps)
updateConsoleAccess(&domainCtx)
domainCtx.setInitialConsoleAccess = true
}
Expand Down Expand Up @@ -3145,8 +3146,8 @@
// Check if any adapters got deleted
// Loop first then delete to avoid deleting while we iterate
var deleteList []string
for indx := range aa.IoBundleList {

Check failure on line 3149 in pkg/pillar/cmd/domainmgr/domainmgr.go

View workflow job for this annotation

GitHub Actions / yetus

Yetus [codespell]

indx ==> index
phylabel := aa.IoBundleList[indx].Phylabel

Check failure on line 3150 in pkg/pillar/cmd/domainmgr/domainmgr.go

View workflow job for this annotation

GitHub Actions / yetus

Yetus [codespell]

indx ==> index
phyAdapter := phyIOAdapterList.LookupAdapter(phylabel)
if phyAdapter == nil {
deleteList = append(deleteList, phylabel)
Expand Down Expand Up @@ -3251,8 +3252,8 @@
log.Functionf("handlePhysicalIOAdapterListDelete: ALL PhysicalIoAdapters " +
"deleted")

for indx := range phyAdapterList.AdapterList {

Check failure on line 3255 in pkg/pillar/cmd/domainmgr/domainmgr.go

View workflow job for this annotation

GitHub Actions / yetus

Yetus [codespell]

indx ==> index
phylabel := phyAdapterList.AdapterList[indx].Phylabel

Check failure on line 3256 in pkg/pillar/cmd/domainmgr/domainmgr.go

View workflow job for this annotation

GitHub Actions / yetus

Yetus [codespell]

indx ==> index
log.Functionf("handlePhysicalIOAdapterListDelete: Deleting Adapter %s",
phylabel)
handleIBDelete(ctx, phylabel)
Expand Down Expand Up @@ -3671,10 +3672,41 @@

func updateConsoleAccess(ctx *domainContext) {
log.Functionf("updateConsoleAccess(%t)", ctx.consoleAccess)
// FIXME: explore the way to stop getty/login
if ctx.consoleAccess {
startGetty(log)
} else {
stopGetty(log)
}
}

// isDeviceOnboarded reports whether the device has already been onboarded to a
// controller.
func isDeviceOnboarded(ps *pubsub.PubSub) bool {
sub, err := ps.NewSubscription(pubsub.SubscriptionOptions{
AgentName: "zedclient",
MyAgentName: agentName,
TopicImpl: types.OnboardingStatus{},
Persistent: true,
Activate: false,
})
if err != nil {
log.Errorf("isDeviceOnboarded: subscription failed: %v", err)
return false
}
defer sub.Close()
// Activate() populates a persistent subscription synchronously from the
// on-disk JSON, so GetAll() below observes the persisted status.
if err := sub.Activate(); err != nil {
log.Errorf("isDeviceOnboarded: activate failed: %v", err)
return false
}
for _, st := range sub.GetAll() {
if status, ok := st.(types.OnboardingStatus); ok &&
status.DeviceUUID != nilUUID {
return true
}
}
return false
}

// Track which ones of these are loaded
Expand Down
32 changes: 32 additions & 0 deletions pkg/pillar/cmd/domainmgr/handlegetty.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"os"
"os/exec"
"strings"
"syscall"

"github.com/lf-edge/eve/pkg/pillar/base"
"github.com/shirou/gopsutil/process"
)

// cmdlineGettyFlag should be aligned with grub.cfg in grub and 001-getty in dom0-ztools
Expand Down Expand Up @@ -51,3 +53,33 @@ func startGetty(log *base.LogObject) {
log.Noticeln("getty started")
gettyStarted = true
}

func stopGetty(log *base.LogObject) {
if !gettyStarted {
return
}
if hasInitGettyStarted(log) {
log.Noticeln("Not killing getty because it was started in init")
return
}

// Find and send USR1 signal to all rungetty.sh processes
procs, err := process.Processes()
if err != nil {
log.Errorf("Cannot list processes: %v", err)
return
}
for _, p := range procs {
cmdline, _ := p.Cmdline()
if strings.Contains(cmdline, "rungetty.sh") {
proc, err := os.FindProcess(int(p.Pid))
if err != nil {
continue
}
if err := proc.Signal(syscall.SIGUSR1); err != nil {
log.Errorf("Failed to signal pid %d: %v", p.Pid, err)
}
}
}
gettyStarted = false
}
2 changes: 1 addition & 1 deletion pkg/vtpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2023-2025 Zededa, Inc.
# SPDX-License-Identifier: Apache-2.0

FROM lfedge/eve-dom0-ztools:728e9ccb619ccc27368fa93c7121200d85a81f88 AS dom0
FROM lfedge/eve-dom0-ztools:5260091b794f9466d08cb33b8c613a6a8398c16a AS dom0
FROM lfedge/eve-alpine:745ae9066273c73b0fd879c4ba4ff626a8392d04 AS build
ENV BUILD_PKGS="gcc g++ autoconf automake libtool make openssl-dev libtasn1-dev \
json-glib-dev gnutls bash expect gawk socat libseccomp-dev gmp-dev \
Expand Down
Loading