mirror of
https://git.proxmox.com/git/proxmox-backup-qemu
synced 2025-10-04 14:38:47 +00:00
allow to set chunk_size, and define PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE
This commit is contained in:
parent
070e55bc37
commit
056dd8fc80
@ -25,7 +25,7 @@ void main(int argc, char **argv) {
|
||||
char *fingerprint = getenv("PBS_FINGERPRINT");
|
||||
|
||||
ProxmoxBackupHandle *pbs = proxmox_backup_new
|
||||
(repository, backup_id, backup_time, password, NULL, NULL, fingerprint, &pbs_error);
|
||||
(repository, backup_id, backup_time, PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE, password, NULL, NULL, fingerprint, &pbs_error);
|
||||
|
||||
if (pbs == NULL) {
|
||||
fprintf(stderr, "proxmox_backup_new failed - %s\n", pbs_error);
|
||||
@ -50,11 +50,9 @@ void main(int argc, char **argv) {
|
||||
|
||||
|
||||
int img_chunks = 16;
|
||||
int chunk_size = 1024*1024*4;
|
||||
|
||||
// fixme: chunk size ??
|
||||
printf("register_image\n");
|
||||
int dev_id = proxmox_backup_register_image(pbs, "scsi-drive0", chunk_size*img_chunks, &pbs_error);
|
||||
int dev_id = proxmox_backup_register_image(pbs, "scsi-drive0", PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE*img_chunks, &pbs_error);
|
||||
if (dev_id < 0) {
|
||||
fprintf(stderr, "proxmox_backup_register_image failed - %s\n", pbs_error);
|
||||
proxmox_backup_free_error(pbs_error);
|
||||
@ -63,7 +61,7 @@ void main(int argc, char **argv) {
|
||||
|
||||
for (int i = 0; i < img_chunks; i++) {
|
||||
printf("write a single chunk %d\n", i);
|
||||
proxmox_backup_write_data(pbs, dev_id, NULL, i*chunk_size, chunk_size, &pbs_error);
|
||||
proxmox_backup_write_data(pbs, dev_id, NULL, i*PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE, PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE, &pbs_error);
|
||||
}
|
||||
|
||||
printf("close_image\n");
|
||||
|
@ -24,6 +24,8 @@ use worker_task::*;
|
||||
mod restore;
|
||||
use restore::*;
|
||||
|
||||
pub const PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE: u64 = 1024*1024*4;
|
||||
|
||||
/// Free returned error messages
|
||||
///
|
||||
/// All calls can return error messages, but they are allocated using
|
||||
@ -105,12 +107,15 @@ impl GotResultCondition {
|
||||
}
|
||||
|
||||
/// Create a new instance
|
||||
///
|
||||
/// Uses `PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE` if `chunk_size` is zero.
|
||||
#[no_mangle]
|
||||
#[allow(clippy::not_unsafe_ptr_arg_deref)]
|
||||
pub extern "C" fn proxmox_backup_new(
|
||||
repo: *const c_char,
|
||||
backup_id: *const c_char,
|
||||
backup_time: u64,
|
||||
chunk_size: u64,
|
||||
password: *const c_char,
|
||||
keyfile: *const c_char,
|
||||
key_password: *const c_char,
|
||||
@ -154,7 +159,7 @@ pub extern "C" fn proxmox_backup_new(
|
||||
host: repo.host().to_owned(),
|
||||
user: repo.user().to_owned(),
|
||||
store: repo.store().to_owned(),
|
||||
chunk_size: 4*1024*1024,
|
||||
chunk_size: if chunk_size > 0 { chunk_size } else { PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE },
|
||||
backup_id,
|
||||
password,
|
||||
backup_time,
|
||||
|
Loading…
Reference in New Issue
Block a user