5
0
mirror of git://git.proxmox.com/git/proxmox-backup.git synced 2025-01-20 14:03:53 +03: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:
Thomas Lamprecht 2023-06-15 18:08:40 +02:00
parent 39531dfc80
commit 950fba5a47
2 changed files with 8 additions and 9 deletions

View File

@ -585,11 +585,10 @@ where
}
fn main() {
let loglevel = match std::env::var("PBS_QEMU_DEBUG") {
Ok(val) if !val.is_empty() => "debug",
_ => "info"
let loglevel = match qemu_helper::debug_mode() {
true => "debug",
false => "info",
};
init_cli_logger("PBS_LOG", loglevel);
let list_cmd_def = CliCommand::new(&API_METHOD_LIST)

View File

@ -194,6 +194,10 @@ pub(crate) async fn hotplug_memory(cid: i32, dimm_mb: usize) -> Result<(), Error
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(
// u16 so we can do wrapping_add without going too high
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");
}
let debug = if let Ok(val) = std::env::var("PBS_QEMU_DEBUG") {
!val.is_empty()
} else {
false
};
let debug = debug_mode();
validate_img_existance(debug)?;