Skip to content

Commit 6f800f0

Browse files
committed
Add two fields for images exported from containers
The original container image has some optional metadata in the ENTRYPOINT and STOPSIGNAL fields, that could be needed later... But these are not exported in the generic rootfs, by default. Make it possible to pass these at runtime, for instance to select between OpenRC and systemd - or SIGTERM and systemd. Some drivers include their config in the rootfs, like wsl.conf. Signed-off-by: Anders F Björklund <[email protected]>
1 parent 86a7a5a commit 6f800f0

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

pkg/instance/start.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ func Prepare(ctx context.Context, inst *limatype.Instance) (*Prepared, error) {
7474
kernel := filepath.Join(inst.Dir, filenames.Kernel)
7575
kernelCmdline := filepath.Join(inst.Dir, filenames.KernelCmdline)
7676
initrd := filepath.Join(inst.Dir, filenames.Initrd)
77+
entrypoint := filepath.Join(inst.Dir, filenames.Entrypoint)
78+
stopsignal := filepath.Join(inst.Dir, filenames.StopSignal)
7779
if _, err := os.Stat(baseDisk); errors.Is(err, os.ErrNotExist) {
7880
var ensuredBaseDisk bool
7981
errs := make([]error, len(inst.Config.Images))
@@ -102,6 +104,18 @@ func Prepare(ctx context.Context, inst *limatype.Instance) (*Prepared, error) {
102104
continue
103105
}
104106
}
107+
if f.Entrypoint != nil {
108+
if err := os.WriteFile(entrypoint, []byte(*f.Entrypoint), 0o644); err != nil {
109+
errs[i] = err
110+
continue
111+
}
112+
}
113+
if f.Stopsignal != nil {
114+
if err := os.WriteFile(stopsignal, []byte(*f.Stopsignal), 0o644); err != nil {
115+
errs[i] = err
116+
continue
117+
}
118+
}
105119
ensuredBaseDisk = true
106120
break
107121
}

pkg/limatype/filenames/filenames.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const (
4141
Kernel = "kernel"
4242
KernelCmdline = "kernel.cmdline"
4343
Initrd = "initrd"
44+
Entrypoint = "entrypoint"
45+
StopSignal = "stopsignal"
4446
QMPSock = "qmp.sock"
4547
SerialLog = "serial.log" // default serial (ttyS0, but ttyAMA0 on qemu-system-{arm,aarch64})
4648
SerialSock = "serial.sock"

pkg/limatype/lima_yaml.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ type Kernel struct {
146146
}
147147

148148
type Image struct {
149-
File `yaml:",inline"`
150-
Kernel *Kernel `yaml:"kernel,omitempty" json:"kernel,omitempty"`
151-
Initrd *File `yaml:"initrd,omitempty" json:"initrd,omitempty"`
149+
File `yaml:",inline"`
150+
Kernel *Kernel `yaml:"kernel,omitempty" json:"kernel,omitempty"`
151+
Initrd *File `yaml:"initrd,omitempty" json:"initrd,omitempty"`
152+
Entrypoint *string `yaml:"entrypoint,omitempty" json:"entrypoint,omitempty"`
153+
Stopsignal *string `yaml:"stopsignal,omitempty" json:"stopsignal,omitempty"`
152154
}
153155

154156
type Disk struct {

website/content/en/docs/dev/internals.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ kernel:
5252
- `kernel.cmdline`: the kernel cmdline
5353
- `initrd`: the initrd
5454

55+
container:
56+
- `entrypoint`: the entrypoint to use (optional)
57+
- `stopsignal`: the stopsignal to use (optional)
58+
5559
QEMU:
5660
- `qemu.pid`: QEMU PID
5761
- `qmp.sock`: QMP socket

0 commit comments

Comments
 (0)