Skip to content

Commit

Permalink
neonvm-builder: apply code review requests
Browse files Browse the repository at this point in the history
Rollback kuttl version
Simplify agetty init line passing
  • Loading branch information
mikhail-sakhnov committed Dec 10, 2024
1 parent f4dce7b commit a2d3587
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion vm-builder/files/agetty-init-amd64

This file was deleted.

1 change: 0 additions & 1 deletion vm-builder/files/agetty-init-arm64

This file was deleted.

2 changes: 1 addition & 1 deletion vm-builder/files/inittab
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 6 additions & 9 deletions vm-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -126,7 +122,7 @@ type TemplatesContext struct {
SpecBuild string
SpecMerge string
InittabCommands []inittabCommand
AgettyInitLine string
AgettyTTY string
ShutdownHook string
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 ""
Expand Down

0 comments on commit a2d3587

Please sign in to comment.