Stop using kernel IP autoconfig for runtime VMs
Avoid the Alpine boot stall caused by kernel ip= autoconfig running before virtio_net is available. Split runtime and image-build boot args so managed VMs boot without kernel network autoconfig, inject a static guest network config plus bootstrap script into the runtime overlay, and keep image builds on the old path for compatibility with existing base images. Preserve executable bits when patching guest files into ext4 images and add coverage for the new boot-arg split and guest network config generation. Validated with go test ./..., a rebuilt Alpine image, and a fresh alp-fast create/ssh check that brought vm.start down to about 2.7s.
This commit is contained in:
parent
092d848620
commit
14d8563f3c
7 changed files with 186 additions and 28 deletions
|
|
@ -318,6 +318,10 @@ func ReadDebugFSText(ctx context.Context, runner CommandRunner, imagePath, guest
|
|||
}
|
||||
|
||||
func WriteExt4File(ctx context.Context, runner CommandRunner, imagePath, guestPath string, data []byte) error {
|
||||
return WriteExt4FileMode(ctx, runner, imagePath, guestPath, 0o600, data)
|
||||
}
|
||||
|
||||
func WriteExt4FileMode(ctx context.Context, runner CommandRunner, imagePath, guestPath string, mode os.FileMode, data []byte) error {
|
||||
tmp, err := os.CreateTemp("", "banger-ext4-*")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -330,9 +334,20 @@ func WriteExt4File(ctx context.Context, runner CommandRunner, imagePath, guestPa
|
|||
if err := tmp.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Chmod(tmp.Name(), mode); err != nil {
|
||||
return err
|
||||
}
|
||||
_, _ = runner.RunSudo(ctx, "e2rm", imagePath+":"+guestPath)
|
||||
_, err = runner.RunSudo(ctx, "e2cp", tmp.Name(), imagePath+":"+guestPath)
|
||||
return err
|
||||
if _, err := runner.RunSudo(ctx, "e2cp", tmp.Name(), imagePath+":"+guestPath); err != nil {
|
||||
return err
|
||||
}
|
||||
if mode.Perm()&0o111 != 0 {
|
||||
modeValue := fmt.Sprintf("%#o", uint32(0o100000|mode.Perm()))
|
||||
if _, err := runner.RunSudo(ctx, "debugfs", "-w", "-R", "sif "+guestPath+" mode "+modeValue, imagePath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func MountTempDir(ctx context.Context, runner CommandRunner, source string, readOnly bool) (string, func() error, error) {
|
||||
|
|
@ -415,7 +430,14 @@ func UpdateFSTab(existing string) string {
|
|||
return strings.Join(out, "\n") + "\n"
|
||||
}
|
||||
|
||||
func BuildBootArgs(vmName, guestIP, bridgeIP, dns string) string {
|
||||
func BuildBootArgs(vmName string) string {
|
||||
return fmt.Sprintf(
|
||||
"console=ttyS0 reboot=k panic=1 pci=off root=/dev/vda rootfstype=ext4 rw hostname=%s systemd.mask=home.mount systemd.mask=var.mount",
|
||||
vmName,
|
||||
)
|
||||
}
|
||||
|
||||
func BuildBootArgsWithKernelIP(vmName, guestIP, bridgeIP, dns string) string {
|
||||
return fmt.Sprintf(
|
||||
"console=ttyS0 reboot=k panic=1 pci=off root=/dev/vda rootfstype=ext4 rw ip=%s::%s:255.255.255.0:%s:eth0:off:%s hostname=%s systemd.mask=home.mount systemd.mask=var.mount",
|
||||
guestIP,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue