Skip to content

Commit b66482c

Browse files
committed
feat: allow disabling injection of extra cmdline in cluster create
The command `talosctl cluster create` injects some extra cmdline though SMBIOS OEM variable `io.systemd.stub.kernel-cmdline-extra` when systemd-boot is used (e.g., when UEFI is enabled). Introduce a new flag to optionally disable this behavior. This allows getting more consistent behavior when testing with a mixed set of UKI and non-UKI machines. Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
1 parent 704b5f9 commit b66482c

File tree

7 files changed

+64
-42
lines changed

7 files changed

+64
-42
lines changed

cmd/talosctl/cmd/mgmt/cluster/create/clusterops/configmaker/internal/makers/qemu.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ func (m *Qemu) AddExtraGenOps() error {
177177
func (m *Qemu) AddExtraProvisionOpts() error {
178178
m.ProvisionOps = slices.Concat(m.ProvisionOps, []provision.Option{
179179
provision.WithBootlader(m.EOps.BootloaderEnabled),
180+
provision.WithSkipInjectingExtraCmdline(m.EOps.SkipInjectingExtraCmdline),
180181
provision.WithUEFI(m.EOps.UefiEnabled),
181182
provision.WithTPM1_2(m.EOps.Tpm1_2Enabled),
182183
provision.WithTPM2(m.EOps.Tpm2Enabled),

cmd/talosctl/cmd/mgmt/cluster/create/clusterops/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ type Qemu struct {
105105
NodeDiskImagePath string
106106
NodeIPXEBootScript string
107107
BootloaderEnabled bool
108+
SkipInjectingExtraCmdline bool
108109
UefiEnabled bool
109110
Tpm1_2Enabled bool
110111
Tpm2Enabled bool

cmd/talosctl/cmd/mgmt/cluster/create/cmd_dev.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func getCreateCmd(cmdName string, hidden bool) *cobra.Command {
4747
diskBlockSizeFlag = "disk-block-size"
4848
useVIPFlag = "use-vip"
4949
bootloaderEnabledFlag = "with-bootloader"
50+
skipInjectingExtraCmdlineFlag = "skip-injecting-extra-cmdline"
5051
controlPlanePortFlag = "control-plane-port"
5152
firewallFlag = "with-firewall"
5253
tpmEnabledFlag = "with-tpm1_2"
@@ -210,6 +211,8 @@ func getCreateCmd(cmdName string, hidden bool) *cobra.Command {
210211
qemu.StringVar(&qOps.NodeDiskImagePath, nodeDiskImagePathFlag, qOps.NodeDiskImagePath, "disk image to use")
211212
qemu.StringVar(&qOps.NodeIPXEBootScript, nodeIPXEBootScriptFlag, qOps.NodeIPXEBootScript, "iPXE boot script (URL) to use")
212213
qemu.BoolVar(&qOps.BootloaderEnabled, bootloaderEnabledFlag, qOps.BootloaderEnabled, "enable bootloader to load kernel and initramfs from disk image after install")
214+
qemu.BoolVar(&qOps.SkipInjectingExtraCmdline, skipInjectingExtraCmdlineFlag, qOps.SkipInjectingExtraCmdline,
215+
"skip injecting extra kernel cmdline parameters via EFI vars through bootloader")
213216
qemu.BoolVar(&qOps.UefiEnabled, uefiEnabledFlag, qOps.UefiEnabled, "enable UEFI on x86_64 architecture")
214217
qemu.BoolVar(&qOps.Tpm1_2Enabled, tpmEnabledFlag, qOps.Tpm1_2Enabled, "enable TPM 1.2 emulation support using swtpm")
215218
qemu.BoolVar(&qOps.Tpm2Enabled, tpm2EnabledFlag, qOps.Tpm2Enabled, "enable TPM 2.0 emulation support using swtpm")

pkg/provision/options.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,15 @@ func WithSiderolinkAgent(v bool) Option {
196196
}
197197
}
198198

199+
// WithSkipInjectingExtraCmdline prevents injecting extra kernel args into EFI vars.
200+
func WithSkipInjectingExtraCmdline(v bool) Option {
201+
return func(o *Options) error {
202+
o.SkipInjectingExtraCmdline = v
203+
204+
return nil
205+
}
206+
}
207+
199208
// Options describes Provisioner parameters.
200209
type Options struct {
201210
LogWriter io.Writer
@@ -207,6 +216,9 @@ type Options struct {
207216
// Enable bootloader by booting from disk image after install.
208217
BootloaderEnabled bool
209218

219+
// SkipInjectingExtraCmdline prevents injecting extra kernel args, e.g., console=ttyS0, into the EFI vars. Only applies when UEFI is enabled.
220+
SkipInjectingExtraCmdline bool
221+
210222
// Enable UEFI (for amd64), arm64 can only boot UEFI
211223
UEFIEnabled bool
212224
// Enable TPM 1.2 emulation using swtpm.

pkg/provision/providers/qemu/launch.go

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,29 @@ type LaunchConfig struct {
3030
StatePath string
3131

3232
// VM options
33-
DiskPaths []string
34-
DiskDrivers []string
35-
DiskBlockSizes []uint
36-
VCPUCount int64
37-
MemSize int64
38-
KernelImagePath string
39-
InitrdPath string
40-
ISOPath string
41-
USBPath string
42-
UKIPath string
43-
ExtraISOPath string
44-
PFlashImages []string
45-
KernelArgs string
46-
MonitorPath string
47-
DefaultBootOrder string
48-
BootloaderEnabled bool
49-
TPMConfig tpmConfig
50-
NodeUUID uuid.UUID
51-
BadRTC bool
52-
ArchitectureData Arch
53-
WithDebugShell bool
54-
IOMMUEnabled bool
33+
DiskPaths []string
34+
DiskDrivers []string
35+
DiskBlockSizes []uint
36+
VCPUCount int64
37+
MemSize int64
38+
KernelImagePath string
39+
InitrdPath string
40+
ISOPath string
41+
USBPath string
42+
UKIPath string
43+
ExtraISOPath string
44+
PFlashImages []string
45+
KernelArgs string
46+
MonitorPath string
47+
DefaultBootOrder string
48+
BootloaderEnabled bool
49+
TPMConfig tpmConfig
50+
NodeUUID uuid.UUID
51+
BadRTC bool
52+
ArchitectureData Arch
53+
WithDebugShell bool
54+
IOMMUEnabled bool
55+
SkipInjectingExtraCmdline bool
5556

5657
// Talos config
5758
Config string
@@ -314,9 +315,11 @@ func launchVM(config *LaunchConfig) error {
314315
}
315316
}
316317

317-
args = append(args,
318-
"-smbios", fmt.Sprintf("type=11,value=%s=%s", constants.SDStubCmdlineExtraOEMVar, config.sdStubExtraCmdline),
319-
)
318+
if !config.SkipInjectingExtraCmdline {
319+
args = append(args,
320+
"-smbios", fmt.Sprintf("type=11,value=%s=%s", constants.SDStubCmdlineExtraOEMVar, config.sdStubExtraCmdline),
321+
)
322+
}
320323

321324
if config.BadRTC {
322325
args = append(args,

pkg/provision/providers/qemu/node.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -163,23 +163,24 @@ func (p *provisioner) createNode(ctx context.Context, state *provision.State, cl
163163
DiskBlockSizes: xslices.Map(nodeReq.Disks, func(disk *provision.Disk) uint {
164164
return disk.BlockSize
165165
}),
166-
VCPUCount: vcpuCount,
167-
MemSize: memSize,
168-
KernelArgs: cmdline.String(),
169-
ExtraISOPath: extraISOPath,
170-
PFlashImages: pflashImages,
171-
MonitorPath: state.GetRelativePath(fmt.Sprintf("%s.monitor", nodeReq.Name)),
172-
BadRTC: nodeReq.BadRTC,
173-
DefaultBootOrder: defaultBootOrder,
174-
BootloaderEnabled: opts.BootloaderEnabled,
175-
NodeUUID: nodeUUID,
176-
Config: nodeConfig,
177-
TFTPServer: nodeReq.TFTPServer,
178-
IPXEBootFileName: nodeReq.IPXEBootFilename,
179-
APIBindAddress: apiBind,
180-
WithDebugShell: opts.WithDebugShell,
181-
IOMMUEnabled: opts.IOMMUEnabled,
182-
Network: getLaunchNetworkConfig(state, clusterReq, nodeReq),
166+
VCPUCount: vcpuCount,
167+
MemSize: memSize,
168+
KernelArgs: cmdline.String(),
169+
ExtraISOPath: extraISOPath,
170+
PFlashImages: pflashImages,
171+
MonitorPath: state.GetRelativePath(fmt.Sprintf("%s.monitor", nodeReq.Name)),
172+
BadRTC: nodeReq.BadRTC,
173+
DefaultBootOrder: defaultBootOrder,
174+
BootloaderEnabled: opts.BootloaderEnabled,
175+
SkipInjectingExtraCmdline: opts.SkipInjectingExtraCmdline,
176+
NodeUUID: nodeUUID,
177+
Config: nodeConfig,
178+
TFTPServer: nodeReq.TFTPServer,
179+
IPXEBootFileName: nodeReq.IPXEBootFilename,
180+
APIBindAddress: apiBind,
181+
WithDebugShell: opts.WithDebugShell,
182+
IOMMUEnabled: opts.IOMMUEnabled,
183+
Network: getLaunchNetworkConfig(state, clusterReq, nodeReq),
183184

184185
// Generate a random MAC address.
185186
// On linux this is later overridden to the interface mac.

website/content/v1.12/reference/cli.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ talosctl cluster create dev [flags]
185185
--registry-insecure-skip-verify strings list of registry hostnames to skip TLS verification for
186186
--registry-mirror strings list of registry mirrors to use in format: <registry host>=<mirror URL>
187187
--skip-injecting-config skip injecting config from embedded metadata server, write config files to current directory
188+
--skip-injecting-extra-cmdline skip injecting extra kernel cmdline parameters via EFI vars through bootloader
188189
--skip-k8s-node-readiness-check skip k8s node readiness checks
189190
--skip-kubeconfig skip merging kubeconfig from the created cluster
190191
--talos-version string the desired Talos version to generate config for (default "latest")

0 commit comments

Comments
 (0)