details: SnapRestoreDetails,
img_file: String,
path: Vec<u8>,
+ dynamic_memory: bool,
) -> Async<Result<Vec<ArchiveEntry>, Error>>;
/// pxar=true:
path: Vec<u8>,
format: Option<FileRestoreFormat>,
zstd: bool,
+ dynamic_memory: bool,
) -> Async<Result<Box<dyn tokio::io::AsyncRead + Unpin + Send>, Error>>;
/// Return status of all running/mapped images, result value is (id, extra data), where id must
details: SnapRestoreDetails,
img_file: String,
path: Vec<u8>,
+ dynamic_memory: bool,
) -> Result<Vec<ArchiveEntry>, Error> {
let driver = driver.unwrap_or(DEFAULT_DRIVER).resolve();
- driver.data_list(details, img_file, path).await
+ driver
+ .data_list(details, img_file, path, dynamic_memory)
+ .await
}
pub async fn data_extract(
path: Vec<u8>,
format: Option<FileRestoreFormat>,
zstd: bool,
+ dynamic_memory: bool,
) -> Result<Box<dyn tokio::io::AsyncRead + Send + Unpin>, Error> {
let driver = driver.unwrap_or(DEFAULT_DRIVER).resolve();
driver
- .data_extract(details, img_file, path, format, zstd)
+ .data_extract(details, img_file, path, format, zstd, dynamic_memory)
.await
}
details: SnapRestoreDetails,
img_file: String,
mut path: Vec<u8>,
+ dynamic_memory: bool,
) -> Async<Result<Vec<ArchiveEntry>, Error>> {
async move {
let (cid, client) = ensure_running(&details).await?;
if !path.is_empty() && path[0] != b'/' {
path.insert(0, b'/');
}
- if path_is_zfs(&path) {
+ if path_is_zfs(&path) && dynamic_memory {
if let Err(err) = set_dynamic_memory(cid, None).await {
log::error!("could not increase memory: {err}");
}
mut path: Vec<u8>,
format: Option<FileRestoreFormat>,
zstd: bool,
+ dynamic_memory: bool,
) -> Async<Result<Box<dyn tokio::io::AsyncRead + Unpin + Send>, Error>> {
async move {
let (cid, client) = ensure_running(&details).await?;
if !path.is_empty() && path[0] != b'/' {
path.insert(0, b'/');
}
- if path_is_zfs(&path) {
+ if path_is_zfs(&path) && dynamic_memory {
if let Err(err) = set_dynamic_memory(cid, None).await {
log::error!("could not increase memory: {err}");
}
None
}
+#[allow(clippy::too_many_arguments)]
async fn list_files(
repo: BackupRepository,
namespace: BackupNamespace,
crypt_config: Option<Arc<CryptConfig>>,
keyfile: Option<String>,
driver: Option<BlockDriverType>,
+ dynamic_memory: bool,
) -> Result<Vec<ArchiveEntry>, Error> {
let client = connect(&repo)?;
let client = BackupReader::start(
snapshot,
keyfile,
};
- data_list(driver, details, file, path).await
+ data_list(driver, details, file, path, dynamic_memory).await
}
}
}
minimum: 1,
optional: true,
},
+ "dynamic-memory": {
+ type: Boolean,
+ description: "If enabled, automatically increases memory for started vms in case of accessing a zpool inside.",
+ default: false,
+ optional: true,
+ },
}
},
returns: {
path: String,
base64: bool,
timeout: Option<u64>,
+ dynamic_memory: bool,
param: Value,
) -> Result<(), Error> {
let repo = extract_repository_from_value(¶m)?;
let result = if let Some(timeout) = timeout {
match tokio::time::timeout(
std::time::Duration::from_secs(timeout),
- list_files(repo, ns, snapshot, path, crypt_config, keyfile, driver),
+ list_files(
+ repo,
+ ns,
+ snapshot,
+ path,
+ crypt_config,
+ keyfile,
+ driver,
+ dynamic_memory,
+ ),
)
.await
{
Err(_) => Err(http_err!(SERVICE_UNAVAILABLE, "list not finished in time")),
}
} else {
- list_files(repo, ns, snapshot, path, crypt_config, keyfile, driver).await
+ list_files(
+ repo,
+ ns,
+ snapshot,
+ path,
+ crypt_config,
+ keyfile,
+ driver,
+ dynamic_memory,
+ )
+ .await
};
let output_format = get_output_format(¶m);
type: BlockDriverType,
optional: true,
},
+ "dynamic-memory": {
+ type: Boolean,
+ description: "If enabled, automatically increases memory for started vms in case of accessing a zpool inside.",
+ default: false,
+ optional: true,
+ },
}
}
)]
target: Option<String>,
format: Option<FileRestoreFormat>,
zstd: bool,
+ dynamic_memory: bool,
param: Value,
) -> Result<(), Error> {
let repo = extract_repository_from_value(¶m)?;
path.clone(),
Some(FileRestoreFormat::Pxar),
false,
+ dynamic_memory,
)
.await?;
let decoder = Decoder::from_tokio(reader).await?;
format_err!("unable to remove temporary .pxarexclude-cli file - {}", e)
})?;
} else {
- let mut reader =
- data_extract(driver, details, file, path.clone(), format, zstd).await?;
+ let mut reader = data_extract(
+ driver,
+ details,
+ file,
+ path.clone(),
+ format,
+ zstd,
+ dynamic_memory,
+ )
+ .await?;
tokio::io::copy(&mut reader, &mut tokio::io::stdout()).await?;
}
}