Skip to content

Commit 5cb3583

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 119d1dd commit 5cb3583

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
@@ -109,6 +109,8 @@ func Prepare(ctx context.Context, inst *store.Instance) (*Prepared, error) {
109109
kernel := filepath.Join(inst.Dir, filenames.Kernel)
110110
kernelCmdline := filepath.Join(inst.Dir, filenames.KernelCmdline)
111111
initrd := filepath.Join(inst.Dir, filenames.Initrd)
112+
entrypoint := filepath.Join(inst.Dir, filenames.Entrypoint)
113+
stopsignal := filepath.Join(inst.Dir, filenames.StopSignal)
112114
if _, err := os.Stat(baseDisk); errors.Is(err, os.ErrNotExist) {
113115
var ensuredBaseDisk bool
114116
errs := make([]error, len(inst.Config.Images))
@@ -137,6 +139,18 @@ func Prepare(ctx context.Context, inst *store.Instance) (*Prepared, error) {
137139
continue
138140
}
139141
}
142+
if f.Entrypoint != nil {
143+
if err := os.WriteFile(entrypoint, []byte(*f.Entrypoint), 0o644); err != nil {
144+
errs[i] = err
145+
continue
146+
}
147+
}
148+
if f.Stopsignal != nil {
149+
if err := os.WriteFile(stopsignal, []byte(*f.Stopsignal), 0o644); err != nil {
150+
errs[i] = err
151+
continue
152+
}
153+
}
140154
ensuredBaseDisk = true
141155
break
142156
}

pkg/limayaml/limayaml.go

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

139139
type Image struct {
140-
File `yaml:",inline"`
141-
Kernel *Kernel `yaml:"kernel,omitempty" json:"kernel,omitempty"`
142-
Initrd *File `yaml:"initrd,omitempty" json:"initrd,omitempty"`
140+
File `yaml:",inline"`
141+
Kernel *Kernel `yaml:"kernel,omitempty" json:"kernel,omitempty"`
142+
Initrd *File `yaml:"initrd,omitempty" json:"initrd,omitempty"`
143+
Entrypoint *string `yaml:"entrypoint,omitempty" json:"entrypoint,omitempty"`
144+
Stopsignal *string `yaml:"stopsignal,omitempty" json:"stopsignal,omitempty"`
143145
}
144146

145147
type Disk struct {

pkg/store/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"

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)