file restore: use proxmox-systemd crate

Some systemd code got split out from proxmox-sys and left there
re-exported with a deprecation marker, use the newer crate, the
workspace already depends on proxmox-systemd anyway.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2024-08-07 20:53:18 +02:00
parent 1c395ad195
commit 05d22be1cf
2 changed files with 6 additions and 4 deletions

View File

@ -24,6 +24,7 @@ proxmox-lang.workspace=true
proxmox-router = { workspace = true, features = [ "cli" ] }
proxmox-schema = { workspace = true, features = [ "api-macro" ] }
proxmox-sys = { workspace = true, features = [ "logrotate" ] }
proxmox-systemd.workspace = true
proxmox-time.workspace = true
proxmox-uuid.workspace = true

View File

@ -12,6 +12,7 @@ use serde::{Deserialize, Serialize};
use serde_json::json;
use proxmox_sys::fs::lock_file;
use proxmox_systemd;
use pbs_api_types::{file_restore::FileRestoreFormat, BackupDir, BackupNamespace};
use pbs_client::{BackupRepository, VsockClient, DEFAULT_VSOCK_PORT};
@ -88,7 +89,7 @@ fn make_name(repo: &BackupRepository, ns: &BackupNamespace, snap: &BackupDir) ->
} else {
format!("qemu_{repo}:{ns}/{snap}")
};
proxmox_sys::systemd::escape_unit(full, false)
proxmox_systemd::escape_unit(full, false)
}
/// remove non-responsive VMs from given map, returns 'true' if map was modified
@ -309,7 +310,7 @@ impl BlockRestoreDriver for QemuBlockDriver {
let resp = client
.get("api2/json/status", Some(json!({"keep-timeout": true})))
.await;
let name = proxmox_sys::systemd::unescape_unit(n)
let name = proxmox_systemd::unescape_unit(n)
.unwrap_or_else(|_| "<invalid name>".to_owned());
let mut extra = json!({"pid": s.pid, "cid": s.cid});
@ -344,7 +345,7 @@ impl BlockRestoreDriver for QemuBlockDriver {
fn stop(&self, id: String) -> Async<Result<(), Error>> {
async move {
let name = proxmox_sys::systemd::escape_unit(&id, false);
let name = proxmox_systemd::escape_unit(&id, false);
let mut map = VMStateMap::load()?;
let map_mod = cleanup_map(&mut map.map).await;
match map.map.get(&name) {
@ -374,7 +375,7 @@ impl BlockRestoreDriver for QemuBlockDriver {
match VMStateMap::load_read_only() {
Ok(state) => state
.iter()
.filter_map(|(name, _)| proxmox_sys::systemd::unescape_unit(name).ok())
.filter_map(|(name, _)| proxmox_systemd::unescape_unit(name).ok())
.collect(),
Err(_) => Vec::new(),
}