mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-08-05 01:54:08 +00:00
file-restore: factor out detecting debug mode
to avoid that the detection logic gets out of sync Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
39531dfc80
commit
950fba5a47
@ -585,11 +585,10 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let loglevel = match std::env::var("PBS_QEMU_DEBUG") {
|
let loglevel = match qemu_helper::debug_mode() {
|
||||||
Ok(val) if !val.is_empty() => "debug",
|
true => "debug",
|
||||||
_ => "info"
|
false => "info",
|
||||||
};
|
};
|
||||||
|
|
||||||
init_cli_logger("PBS_LOG", loglevel);
|
init_cli_logger("PBS_LOG", loglevel);
|
||||||
|
|
||||||
let list_cmd_def = CliCommand::new(&API_METHOD_LIST)
|
let list_cmd_def = CliCommand::new(&API_METHOD_LIST)
|
||||||
|
@ -194,6 +194,10 @@ pub(crate) async fn hotplug_memory(cid: i32, dimm_mb: usize) -> Result<(), Error
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn debug_mode() -> bool {
|
||||||
|
std::env::var("PBS_QEMU_DEBUG").map(|s| !s.is_empty()).unwrap_or(false)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn start_vm(
|
pub async fn start_vm(
|
||||||
// u16 so we can do wrapping_add without going too high
|
// u16 so we can do wrapping_add without going too high
|
||||||
mut cid: u16,
|
mut cid: u16,
|
||||||
@ -205,11 +209,7 @@ pub async fn start_vm(
|
|||||||
bail!("environment variable PBS_PASSWORD has to be set for QEMU VM restore");
|
bail!("environment variable PBS_PASSWORD has to be set for QEMU VM restore");
|
||||||
}
|
}
|
||||||
|
|
||||||
let debug = if let Ok(val) = std::env::var("PBS_QEMU_DEBUG") {
|
let debug = debug_mode();
|
||||||
!val.is_empty()
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
validate_img_existance(debug)?;
|
validate_img_existance(debug)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user