Skip to content

Commit 3cbb4cf

Browse files
committed
to-disk: Add --install-log
To help debug installs. Signed-off-by: Colin Walters <[email protected]>
1 parent dc40455 commit 3cbb4cf

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

crates/kit/src/libvirt/run.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ pub fn run(global_opts: &crate::libvirt::LibvirtOptions, opts: LibvirtRunOpts) -
144144
disk_size: Some(opts.disk_size.clone()),
145145
format: crate::to_disk::Format::Raw, // Default to raw format
146146
install: opts.install.clone(),
147+
install_log: None,
147148
common: CommonVmOpts {
148149
memory: opts.memory.clone(),
149150
vcpus: Some(opts.cpus),

crates/kit/src/libvirt/upload.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ pub fn run(global_opts: &crate::libvirt::LibvirtOptions, opts: LibvirtUploadOpts
217217
format: crate::to_disk::Format::Raw, // Default to raw format
218218
disk_size: Some(disk_size.to_string()),
219219
label: Default::default(),
220+
install_log: None,
220221
common: crate::run_ephemeral::CommonVmOpts {
221222
memory: opts.memory.clone(),
222223
vcpus: opts.vcpus,

crates/kit/src/libvirt_upload_disk.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ pub fn run(opts: LibvirtUploadDiskOpts) -> Result<()> {
288288
disk_size: Some(disk_size.to_string()),
289289
format: crate::to_disk::Format::Raw, // Default to raw format
290290
label: Default::default(),
291+
install_log: None,
291292
common: crate::run_ephemeral::CommonVmOpts {
292293
memory: opts.memory.clone(),
293294
vcpus: opts.vcpus,

crates/kit/src/to_disk.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ pub struct ToDiskOpts {
139139
#[clap(flatten)]
140140
pub common: CommonVmOpts,
141141

142+
/// Configure logging for `bootc install` by setting the `RUST_LOG` environment variable.
143+
#[clap(long)]
144+
pub install_log: Option<String>,
145+
142146
#[clap(
143147
long = "label",
144148
help = "Add metadata to the container in key=value form"
@@ -184,6 +188,14 @@ impl ToDiskOpts {
184188
.map_err(|e| eyre!("Failed to quote source imgref '{}': {}", source_imgref, e))?
185189
.to_string();
186190

191+
let install_log = self
192+
.install_log
193+
.as_deref()
194+
.map(|v| shlex::try_quote(v))
195+
.transpose()?
196+
.map(|v| format!("RUST_LOG={v}"))
197+
.unwrap_or_default();
198+
187199
// Create the complete script by substituting variables directly
188200
let script = indoc! {r#"
189201
set -euo pipefail
@@ -198,6 +210,7 @@ impl ToDiskOpts {
198210
199211
# Execute bootc installation
200212
env STORAGE_OPTS=additionalimagestore=/run/virtiofs-mnt-hoststorage/ \
213+
{INSTALL_LOG} \
201214
bootc install to-disk \
202215
--generic-image \
203216
--skip-fetch-check \
@@ -208,6 +221,7 @@ impl ToDiskOpts {
208221
echo "Installation completed successfully!"
209222
"#}
210223
.replace("{SOURCE_IMGREF}", &quoted_source_imgref)
224+
.replace("{INSTALL_LOG}", &install_log)
211225
.replace("{BOOTC_ARGS}", &bootc_args);
212226

213227
Ok(vec!["/bin/bash".to_string(), "-c".to_string(), script])
@@ -492,6 +506,7 @@ mod tests {
492506
source_image: "test:latest".to_string(),
493507
target_disk: "/tmp/test.img".into(),
494508
label: Default::default(),
509+
install_log: None,
495510
install: InstallOptions {
496511
filesystem: Some("ext4".to_string()),
497512
..Default::default()
@@ -510,6 +525,7 @@ mod tests {
510525
source_image: "test:latest".to_string(),
511526
target_disk: "/tmp/test.img".into(),
512527
label: Default::default(),
528+
install_log: None,
513529
install: InstallOptions {
514530
filesystem: Some("ext4".to_string()),
515531
..Default::default()

docs/src/man/bcvk-to-disk.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ The installation process:
103103

104104
Generate SSH keypair and inject via systemd credentials
105105

106+
**--install-log**=*INSTALL_LOG*
107+
108+
Configure logging for `bootc install` by setting the `RUST_LOG` environment variable
109+
106110
**--label**=*LABEL*
107111

108112
Add metadata to the container in key=value form

0 commit comments

Comments
 (0)