mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-05-01 04:05:57 +00: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) => {
|
Err(err) => {
|
||||||
if text {
|
if text {
|
||||||
eprintln!("error getting status from driver '{}' - {}", drv_name, err);
|
eprintln!("error getting status from driver '{drv_name}' - {err}");
|
||||||
} else {
|
} 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
|
/// Autocompletion handler for block mappings
|
||||||
|
@ -84,9 +84,9 @@ impl VMStateMap {
|
|||||||
|
|
||||||
fn make_name(repo: &BackupRepository, ns: &BackupNamespace, snap: &BackupDir) -> String {
|
fn make_name(repo: &BackupRepository, ns: &BackupNamespace, snap: &BackupDir) -> String {
|
||||||
let full = if ns.is_root() {
|
let full = if ns.is_root() {
|
||||||
format!("qemu_{}/{}", repo, snap)
|
format!("qemu_{repo}/{snap}")
|
||||||
} else {
|
} else {
|
||||||
format!("qemu_{}:{}/{}", repo, ns, snap)
|
format!("qemu_{repo}:{ns}/{snap}")
|
||||||
};
|
};
|
||||||
proxmox_sys::systemd::escape_unit(&full, false)
|
proxmox_sys::systemd::escape_unit(&full, false)
|
||||||
}
|
}
|
||||||
@ -321,13 +321,12 @@ impl BlockRestoreDriver for QemuBlockDriver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let err =
|
let err = format!("invalid JSON received from /status call: {status}");
|
||||||
format!("invalid JSON received from /status call: {}", status);
|
|
||||||
extra["error"] = json!(err);
|
extra["error"] = json!(err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(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);
|
extra["error"] = json!(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,7 +362,7 @@ impl BlockRestoreDriver for QemuBlockDriver {
|
|||||||
if map_mod {
|
if map_mod {
|
||||||
map.write()?;
|
map.write()?;
|
||||||
}
|
}
|
||||||
bail!("VM with name '{}' not found", name);
|
bail!("VM with name '{name}' not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -489,8 +489,8 @@ async fn extract(
|
|||||||
// we extracted a .pxarexclude-cli file auto-generated by the VM when encoding the
|
// 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
|
// archive, this file is of no use for the user, so try to remove it
|
||||||
target.push(".pxarexclude-cli");
|
target.push(".pxarexclude-cli");
|
||||||
std::fs::remove_file(target).map_err(|e| {
|
std::fs::remove_file(target).map_err(|err| {
|
||||||
format_err!("unable to remove temporary .pxarexclude-cli file - {}", e)
|
format_err!("unable to remove temporary .pxarexclude-cli file - {err}")
|
||||||
})?;
|
})?;
|
||||||
} else {
|
} else {
|
||||||
let mut reader =
|
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();
|
let mut pidstr = String::new();
|
||||||
pid_file.read_to_string(&mut pidstr)?;
|
pid_file.read_to_string(&mut pidstr)?;
|
||||||
pid = pidstr.trim_end().parse().map_err(|err| {
|
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;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -377,14 +377,14 @@ pub async fn start_vm(
|
|||||||
if out.contains("unable to set guest cid: Address already in use") {
|
if out.contains("unable to set guest cid: Address already in use") {
|
||||||
attempts += 1;
|
attempts += 1;
|
||||||
if attempts >= MAX_CID_TRIES {
|
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
|
// 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
|
// skip special-meaning low values
|
||||||
cid = cid.wrapping_add(1).max(10);
|
cid = cid.wrapping_add(1).max(10);
|
||||||
} else {
|
} else {
|
||||||
log::error!("{}", out);
|
log::error!("{out}");
|
||||||
bail!("Starting VM failed. See output above for more information.");
|
bail!("Starting VM failed. See output above for more information.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user