mirror of
git://git.proxmox.com/git/proxmox-backup.git
synced 2025-02-25 17:57:35 +03:00
file-restore: move various formats to inline-string macros
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
7fa5be8b3f
commit
2aaf3ef1e5
@ -163,9 +163,9 @@ pub async fn status(driver: Option<BlockDriverType>, param: Value) -> Result<(),
|
||||
}
|
||||
Err(err) => {
|
||||
if text {
|
||||
eprintln!("error getting status from driver '{}' - {}", drv_name, err);
|
||||
eprintln!("error getting status from driver '{drv_name}' - {err}");
|
||||
} else {
|
||||
ret[drv_name] = json!({ "error": format!("{}", err) });
|
||||
ret[drv_name] = json!({ "error": format!("{err}") });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -197,7 +197,7 @@ pub async fn stop(name: String) -> Result<(), Error> {
|
||||
}
|
||||
}
|
||||
|
||||
bail!("no mapping with name '{}' found", name);
|
||||
bail!("no mapping with name '{name}' found");
|
||||
}
|
||||
|
||||
/// Autocompletion handler for block mappings
|
||||
|
@ -84,9 +84,9 @@ impl VMStateMap {
|
||||
|
||||
fn make_name(repo: &BackupRepository, ns: &BackupNamespace, snap: &BackupDir) -> String {
|
||||
let full = if ns.is_root() {
|
||||
format!("qemu_{}/{}", repo, snap)
|
||||
format!("qemu_{repo}/{snap}")
|
||||
} else {
|
||||
format!("qemu_{}:{}/{}", repo, ns, snap)
|
||||
format!("qemu_{repo}:{ns}/{snap}")
|
||||
};
|
||||
proxmox_sys::systemd::escape_unit(&full, false)
|
||||
}
|
||||
@ -321,13 +321,12 @@ impl BlockRestoreDriver for QemuBlockDriver {
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let err =
|
||||
format!("invalid JSON received from /status call: {}", status);
|
||||
let err = format!("invalid JSON received from /status call: {status}");
|
||||
extra["error"] = json!(err);
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
let err = format!("error during /status API call: {}", err);
|
||||
let err = format!("error during /status API call: {err}");
|
||||
extra["error"] = json!(err);
|
||||
}
|
||||
}
|
||||
@ -363,7 +362,7 @@ impl BlockRestoreDriver for QemuBlockDriver {
|
||||
if map_mod {
|
||||
map.write()?;
|
||||
}
|
||||
bail!("VM with name '{}' not found", name);
|
||||
bail!("VM with name '{name}' not found");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -489,8 +489,8 @@ async fn extract(
|
||||
// we extracted a .pxarexclude-cli file auto-generated by the VM when encoding the
|
||||
// archive, this file is of no use for the user, so try to remove it
|
||||
target.push(".pxarexclude-cli");
|
||||
std::fs::remove_file(target).map_err(|e| {
|
||||
format_err!("unable to remove temporary .pxarexclude-cli file - {}", e)
|
||||
std::fs::remove_file(target).map_err(|err| {
|
||||
format_err!("unable to remove temporary .pxarexclude-cli file - {err}")
|
||||
})?;
|
||||
} else {
|
||||
let mut reader =
|
||||
@ -499,7 +499,7 @@ async fn extract(
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
bail!("cannot extract '{}'", orig_path);
|
||||
bail!("cannot extract '{orig_path}'");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ pub async fn start_vm(
|
||||
let mut pidstr = String::new();
|
||||
pid_file.read_to_string(&mut pidstr)?;
|
||||
pid = pidstr.trim_end().parse().map_err(|err| {
|
||||
format_err!("cannot parse PID returned by QEMU ('{}'): {}", &pidstr, err)
|
||||
format_err!("cannot parse PID returned by QEMU ('{pidstr}'): {err}")
|
||||
})?;
|
||||
break;
|
||||
} else {
|
||||
@ -377,14 +377,14 @@ pub async fn start_vm(
|
||||
if out.contains("unable to set guest cid: Address already in use") {
|
||||
attempts += 1;
|
||||
if attempts >= MAX_CID_TRIES {
|
||||
bail!("CID '{}' in use, but max attempts reached, aborting", cid);
|
||||
bail!("CID '{cid}' in use, but max attempts reached, aborting");
|
||||
}
|
||||
// CID in use, try next higher one
|
||||
log::info!("CID '{}' in use by other VM, attempting next one", cid);
|
||||
log::info!("CID '{cid}' in use by other VM, attempting next one");
|
||||
// skip special-meaning low values
|
||||
cid = cid.wrapping_add(1).max(10);
|
||||
} else {
|
||||
log::error!("{}", out);
|
||||
log::error!("{out}");
|
||||
bail!("Starting VM failed. See output above for more information.");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user