From a2d3587cea59ff828fef12afeb89db1de71cbef4 Mon Sep 17 00:00:00 2001 From: Mikhail Sakhnov Date: Tue, 10 Dec 2024 08:59:10 +0100 Subject: [PATCH] neonvm-builder: apply code review requests Rollback kuttl version Simplify agetty init line passing --- Makefile | 2 +- vm-builder/files/agetty-init-amd64 | 1 - vm-builder/files/agetty-init-arm64 | 1 - vm-builder/files/inittab | 2 +- vm-builder/main.go | 15 ++++++--------- 5 files changed, 8 insertions(+), 13 deletions(-) delete mode 100644 vm-builder/files/agetty-init-amd64 delete mode 100644 vm-builder/files/agetty-init-arm64 diff --git a/Makefile b/Makefile index ba5465812..90d05b7a0 100644 --- a/Makefile +++ b/Makefile @@ -496,7 +496,7 @@ CODE_GENERATOR_VERSION ?= v0.28.12 KUTTL ?= $(LOCALBIN)/kuttl # k8s deps @ 1.28.3 -KUTTL_VERSION ?= v0.19.0 +KUTTL_VERSION ?= v0.16.0 ifeq ($(GOARCH), arm64) KUTTL_ARCH = arm64 else ifeq ($(GOARCH), amd64) diff --git a/vm-builder/files/agetty-init-amd64 b/vm-builder/files/agetty-init-amd64 deleted file mode 100644 index 894a24ae4..000000000 --- a/vm-builder/files/agetty-init-amd64 +++ /dev/null @@ -1 +0,0 @@ -ttyS0::respawn:/neonvm/bin/agetty --8bits --local-line --noissue --noclear --noreset --host console --login-program /neonvm/bin/login --login-pause --autologin root 115200 ttyS0 linux diff --git a/vm-builder/files/agetty-init-arm64 b/vm-builder/files/agetty-init-arm64 deleted file mode 100644 index 713a4f669..000000000 --- a/vm-builder/files/agetty-init-arm64 +++ /dev/null @@ -1 +0,0 @@ -ttyAMA0::respawn:/neonvm/bin/agetty --8bits --local-line --noissue --noclear --noreset --host console --login-program /neonvm/bin/login --login-pause --autologin root 115200 ttyAMA0 linux diff --git a/vm-builder/files/inittab b/vm-builder/files/inittab index e9ef19f1c..92ffeb43d 100644 --- a/vm-builder/files/inittab +++ b/vm-builder/files/inittab @@ -12,5 +12,5 @@ {{ range .InittabCommands }} ::{{.SysvInitAction}}:su -p {{.CommandUser}} -c {{.ShellEscapedCommand}} {{ end }} -{{ .AgettyInitLine }} +{{ .AgettyTTY }}::respawn:/neonvm/bin/agetty --8bits --local-line --noissue --noclear --noreset --host console --login-program /neonvm/bin/login --login-pause --autologin root 115200 {{ .AgettyTTY }} linux ::shutdown:/neonvm/bin/vmshutdown diff --git a/vm-builder/main.go b/vm-builder/main.go index 2cd76d994..7cdd17623 100644 --- a/vm-builder/main.go +++ b/vm-builder/main.go @@ -38,10 +38,6 @@ var ( scriptVmStart string //go:embed files/inittab scriptInitTab string - //go:embed files/agetty-init-amd64 - scriptAgettyInitAmd64 string - //go:embed files/agetty-init-arm64 - scriptAgettyInitArm64 string //go:embed files/vmacpi scriptVmAcpi string //go:embed files/vmshutdown @@ -126,7 +122,7 @@ type TemplatesContext struct { SpecBuild string SpecMerge string InittabCommands []inittabCommand - AgettyInitLine string + AgettyTTY string ShutdownHook string } @@ -312,7 +308,7 @@ func main() { SpecMerge: "", // overridden below if spec != nil InittabCommands: nil, // overridden below if spec != nil ShutdownHook: "", // overridden below if spec != nil - AgettyInitLine: getAgettyInitLine(*targetArch), + AgettyTTY: getAgettyTTY(*targetArch), } if len(imageSpec.Config.User) != 0 { @@ -565,12 +561,13 @@ func (f file) validate() []error { return errs } -func getAgettyInitLine(targetArch string) string { +// getAgettyTTY returns the tty device name for agetty based on the target architecture. +func getAgettyTTY(targetArch string) string { switch targetArch { case targetArchLinuxAmd64: - return scriptAgettyInitAmd64 + return "ttyS0" case targetArchLinuxArm64: - return scriptAgettyInitArm64 + return "ttyAMA0" default: log.Fatalf("Unsupported target architecture: %q", targetArch) return ""