update ABI initially for build on bullseye

much moving around, no actual relevant changes FWICT

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-07-05 20:55:24 +02:00
parent 1c83461793
commit 2ddf3f7e8f

View File

@ -37,123 +37,21 @@
/** /**
* Opaque handle for backups jobs * Opaque handle for backups jobs
*/ */
typedef struct { typedef struct ProxmoxBackupHandle {
} ProxmoxBackupHandle; } ProxmoxBackupHandle;
/** /**
* Opaque handle for restore jobs * Opaque handle for restore jobs
*/ */
typedef struct { typedef struct ProxmoxRestoreHandle {
} ProxmoxRestoreHandle; } ProxmoxRestoreHandle;
/** /**
* Abort a running backup task * Return a read-only pointer to a string containing the version of the library.
*
* This stops the current backup task. It is still necessary to call
* proxmox_backup_disconnect() to close the connection and free
* allocated memory.
*/ */
void proxmox_backup_abort(ProxmoxBackupHandle *handle, const char *reason); const char *proxmox_backup_qemu_version(void);
/**
* Add a configuration blob to the backup (sync)
*/
int proxmox_backup_add_config(ProxmoxBackupHandle *handle,
const char *name,
const uint8_t *data,
uint64_t size,
char **error);
/**
* Add a configuration blob to the backup
*
* Create and upload a data blob "<name>.blob".
*/
void proxmox_backup_add_config_async(ProxmoxBackupHandle *handle,
const char *name,
const uint8_t *data,
uint64_t size,
void (*callback)(void*),
void *callback_data,
int *result,
char **error);
/**
* Check if we can do incremental backups.
*
* This method compares the csum from last backup manifest with the
* checksum stored locally.
*/
int proxmox_backup_check_incremental(ProxmoxBackupHandle *handle,
const char *device_name,
uint64_t size);
/**
* Close a registered image (sync)
*/
int proxmox_backup_close_image(ProxmoxBackupHandle *handle, uint8_t dev_id, char **error);
/**
* Close a registered image
*
* Mark the image as closed. Further writes are not possible.
*/
void proxmox_backup_close_image_async(ProxmoxBackupHandle *handle,
uint8_t dev_id,
void (*callback)(void*),
void *callback_data,
int *result,
char **error);
/**
* Open connection to the backup server (sync)
*
* Returns:
* 0 ... Sucecss (no prevbious backup)
* 1 ... Success (found previous backup)
* -1 ... Error
*/
int proxmox_backup_connect(ProxmoxBackupHandle *handle, char **error);
/**
* Open connection to the backup server
*
* Returns:
* 0 ... Sucecss (no prevbious backup)
* 1 ... Success (found previous backup)
* -1 ... Error
*/
void proxmox_backup_connect_async(ProxmoxBackupHandle *handle,
void (*callback)(void*),
void *callback_data,
int *result,
char **error);
/**
* Disconnect and free allocated memory
*
* The handle becomes invalid after this call.
*/
void proxmox_backup_disconnect(ProxmoxBackupHandle *handle);
/**
* Finish the backup (sync)
*/
int proxmox_backup_finish(ProxmoxBackupHandle *handle, char **error);
/**
* Finish the backup
*
* Finish the backup by creating and uploading the backup manifest.
* All registered images have to be closed before calling this.
*/
void proxmox_backup_finish_async(ProxmoxBackupHandle *handle,
void (*callback)(void*),
void *callback_data,
int *result,
char **error);
/** /**
* Free returned error messages * Free returned error messages
@ -164,12 +62,23 @@ void proxmox_backup_finish_async(ProxmoxBackupHandle *handle,
*/ */
void proxmox_backup_free_error(char *ptr); void proxmox_backup_free_error(char *ptr);
/**
* Returns the text presentation (relative path) for a backup snapshot
*
* The resturned value is allocated with strdup(), and can be freed
* with free().
*/
const char *proxmox_backup_snapshot_string(const char *backup_type,
const char *backup_id,
int64_t backup_time,
char **error);
/** /**
* Create a new instance * Create a new instance
* *
* Uses `PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE` if `chunk_size` is zero. * Uses `PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE` if `chunk_size` is zero.
*/ */
ProxmoxBackupHandle *proxmox_backup_new(const char *repo, struct ProxmoxBackupHandle *proxmox_backup_new(const char *repo,
const char *backup_id, const char *backup_id,
uint64_t backup_time, uint64_t backup_time,
uint64_t chunk_size, uint64_t chunk_size,
@ -183,14 +92,52 @@ ProxmoxBackupHandle *proxmox_backup_new(const char *repo,
char **error); char **error);
/** /**
* Return a read-only pointer to a string containing the version of the library. * Open connection to the backup server (sync)
*
* Returns:
* 0 ... Sucecss (no prevbious backup)
* 1 ... Success (found previous backup)
* -1 ... Error
*/ */
const char *proxmox_backup_qemu_version(void); int proxmox_backup_connect(struct ProxmoxBackupHandle *handle, char **error);
/**
* Open connection to the backup server
*
* Returns:
* 0 ... Sucecss (no prevbious backup)
* 1 ... Success (found previous backup)
* -1 ... Error
*/
void proxmox_backup_connect_async(struct ProxmoxBackupHandle *handle,
void (*callback)(void*),
void *callback_data,
int *result,
char **error);
/**
* Abort a running backup task
*
* This stops the current backup task. It is still necessary to call
* proxmox_backup_disconnect() to close the connection and free
* allocated memory.
*/
void proxmox_backup_abort(struct ProxmoxBackupHandle *handle, const char *reason);
/**
* Check if we can do incremental backups.
*
* This method compares the csum from last backup manifest with the
* checksum stored locally.
*/
int proxmox_backup_check_incremental(struct ProxmoxBackupHandle *handle,
const char *device_name,
uint64_t size);
/** /**
* Register a backup image (sync) * Register a backup image (sync)
*/ */
int proxmox_backup_register_image(ProxmoxBackupHandle *handle, int proxmox_backup_register_image(struct ProxmoxBackupHandle *handle,
const char *device_name, const char *device_name,
uint64_t size, uint64_t size,
bool incremental, bool incremental,
@ -203,7 +150,7 @@ int proxmox_backup_register_image(ProxmoxBackupHandle *handle,
* ('<device_name>.img.fidx'). The returned integer is the dev_id * ('<device_name>.img.fidx'). The returned integer is the dev_id
* parameter for the proxmox_backup_write_data_async() method. * parameter for the proxmox_backup_write_data_async() method.
*/ */
void proxmox_backup_register_image_async(ProxmoxBackupHandle *handle, void proxmox_backup_register_image_async(struct ProxmoxBackupHandle *handle,
const char *device_name, const char *device_name,
uint64_t size, uint64_t size,
bool incremental, bool incremental,
@ -213,14 +160,26 @@ void proxmox_backup_register_image_async(ProxmoxBackupHandle *handle,
char **error); char **error);
/** /**
* Returns the text presentation (relative path) for a backup snapshot * Add a configuration blob to the backup (sync)
*
* The resturned value is allocated with strdup(), and can be freed
* with free().
*/ */
const char *proxmox_backup_snapshot_string(const char *backup_type, int proxmox_backup_add_config(struct ProxmoxBackupHandle *handle,
const char *backup_id, const char *name,
int64_t backup_time, const uint8_t *data,
uint64_t size,
char **error);
/**
* Add a configuration blob to the backup
*
* Create and upload a data blob "<name>.blob".
*/
void proxmox_backup_add_config_async(struct ProxmoxBackupHandle *handle,
const char *name,
const uint8_t *data,
uint64_t size,
void (*callback)(void*),
void *callback_data,
int *result,
char **error); char **error);
/** /**
@ -236,7 +195,7 @@ const char *proxmox_backup_snapshot_string(const char *backup_type,
* 0: successful, chunk already exists on server, so it was resued * 0: successful, chunk already exists on server, so it was resued
* size: successful, chunk uploaded * size: successful, chunk uploaded
*/ */
int proxmox_backup_write_data(ProxmoxBackupHandle *handle, int proxmox_backup_write_data(struct ProxmoxBackupHandle *handle,
uint8_t dev_id, uint8_t dev_id,
const uint8_t *data, const uint8_t *data,
uint64_t offset, uint64_t offset,
@ -259,7 +218,7 @@ int proxmox_backup_write_data(ProxmoxBackupHandle *handle,
* 0: successful, chunk already exists on server, so it was resued * 0: successful, chunk already exists on server, so it was resued
* size: successful, chunk uploaded * size: successful, chunk uploaded
*/ */
void proxmox_backup_write_data_async(ProxmoxBackupHandle *handle, void proxmox_backup_write_data_async(struct ProxmoxBackupHandle *handle,
uint8_t dev_id, uint8_t dev_id,
const uint8_t *data, const uint8_t *data,
uint64_t offset, uint64_t offset,
@ -270,42 +229,34 @@ void proxmox_backup_write_data_async(ProxmoxBackupHandle *handle,
char **error); char **error);
/** /**
* Serialize all state data into a byte buffer. Can be loaded again with * Close a registered image (sync)
* proxmox_import_state. Use for migration for example. */
int proxmox_backup_close_image(struct ProxmoxBackupHandle *handle, uint8_t dev_id, char **error);
/**
* Close a registered image
* *
* Length of the returned buffer is written to buf_size. Returned buffer must * Mark the image as closed. Further writes are not possible.
* be freed with proxmox_free_state_buf.
*/ */
uint8_t *proxmox_export_state(uintptr_t *buf_size); void proxmox_backup_close_image_async(struct ProxmoxBackupHandle *handle,
uint8_t dev_id,
void (*callback)(void*),
void *callback_data,
int *result,
char **error);
/** /**
* Free a buffer acquired from proxmox_export_state. * Finish the backup (sync)
*/ */
void proxmox_free_state_buf(uint8_t *buf); int proxmox_backup_finish(struct ProxmoxBackupHandle *handle, char **error);
/** /**
* Load state serialized by proxmox_export_state. If loading fails, a message * Finish the backup
* will be logged to stderr, but the function will not fail.
*/
void proxmox_import_state(const uint8_t *buf, uintptr_t buf_size);
/**
* Open connection to the backup server (sync)
* *
* Returns: * Finish the backup by creating and uploading the backup manifest.
* 0 ... Sucecss (no prevbious backup) * All registered images have to be closed before calling this.
* -1 ... Error
*/ */
int proxmox_restore_connect(ProxmoxRestoreHandle *handle, char **error); void proxmox_backup_finish_async(struct ProxmoxBackupHandle *handle,
/**
* Open connection to the backup server (async)
*
* Returns:
* 0 ... Sucecss (no prevbious backup)
* -1 ... Error
*/
void proxmox_restore_connect_async(ProxmoxRestoreHandle *handle,
void (*callback)(void*), void (*callback)(void*),
void *callback_data, void *callback_data,
int *result, int *result,
@ -316,29 +267,12 @@ void proxmox_restore_connect_async(ProxmoxRestoreHandle *handle,
* *
* The handle becomes invalid after this call. * The handle becomes invalid after this call.
*/ */
void proxmox_restore_disconnect(ProxmoxRestoreHandle *handle); void proxmox_backup_disconnect(struct ProxmoxBackupHandle *handle);
/**
* Retrieve the length of a given archive handle in bytes
*/
long proxmox_restore_get_image_length(ProxmoxRestoreHandle *handle, uint8_t aid, char **error);
/**
* Restore an image (sync)
*
* Image data is downloaded and sequentially dumped to the callback.
*/
int proxmox_restore_image(ProxmoxRestoreHandle *handle,
const char *archive_name,
int (*callback)(void*, uint64_t, const unsigned char*, uint64_t),
void *callback_data,
char **error,
bool verbose);
/** /**
* Connect the the backup server for restore (sync) * Connect the the backup server for restore (sync)
*/ */
ProxmoxRestoreHandle *proxmox_restore_new(const char *repo, struct ProxmoxRestoreHandle *proxmox_restore_new(const char *repo,
const char *snapshot, const char *snapshot,
const char *password, const char *password,
const char *keyfile, const char *keyfile,
@ -346,23 +280,71 @@ ProxmoxRestoreHandle *proxmox_restore_new(const char *repo,
const char *fingerprint, const char *fingerprint,
char **error); char **error);
/**
* Open connection to the backup server (sync)
*
* Returns:
* 0 ... Sucecss (no prevbious backup)
* -1 ... Error
*/
int proxmox_restore_connect(struct ProxmoxRestoreHandle *handle, char **error);
/**
* Open connection to the backup server (async)
*
* Returns:
* 0 ... Sucecss (no prevbious backup)
* -1 ... Error
*/
void proxmox_restore_connect_async(struct ProxmoxRestoreHandle *handle,
void (*callback)(void*),
void *callback_data,
int *result,
char **error);
/**
* Disconnect and free allocated memory
*
* The handle becomes invalid after this call.
*/
void proxmox_restore_disconnect(struct ProxmoxRestoreHandle *handle);
/**
* Restore an image (sync)
*
* Image data is downloaded and sequentially dumped to the callback.
*/
int proxmox_restore_image(struct ProxmoxRestoreHandle *handle,
const char *archive_name,
int (*callback)(void*, uint64_t, const unsigned char*, uint64_t),
void *callback_data,
char **error,
bool verbose);
/** /**
* Retrieve the ID of a handle used to access data in the given archive (sync) * Retrieve the ID of a handle used to access data in the given archive (sync)
*/ */
int proxmox_restore_open_image(ProxmoxRestoreHandle *handle, int proxmox_restore_open_image(struct ProxmoxRestoreHandle *handle,
const char *archive_name, const char *archive_name,
char **error); char **error);
/** /**
* Retrieve the ID of a handle used to access data in the given archive (async) * Retrieve the ID of a handle used to access data in the given archive (async)
*/ */
void proxmox_restore_open_image_async(ProxmoxRestoreHandle *handle, void proxmox_restore_open_image_async(struct ProxmoxRestoreHandle *handle,
const char *archive_name, const char *archive_name,
void (*callback)(void*), void (*callback)(void*),
void *callback_data, void *callback_data,
int *result, int *result,
char **error); char **error);
/**
* Retrieve the length of a given archive handle in bytes
*/
long proxmox_restore_get_image_length(struct ProxmoxRestoreHandle *handle,
uint8_t aid,
char **error);
/** /**
* Read data from the backup image at the given offset (sync) * Read data from the backup image at the given offset (sync)
* *
@ -373,7 +355,7 @@ void proxmox_restore_open_image_async(ProxmoxRestoreHandle *handle,
* Note: It is not an error for a successful call to transfer fewer * Note: It is not an error for a successful call to transfer fewer
* bytes than requested. * bytes than requested.
*/ */
int proxmox_restore_read_image_at(ProxmoxRestoreHandle *handle, int proxmox_restore_read_image_at(struct ProxmoxRestoreHandle *handle,
uint8_t aid, uint8_t aid,
uint8_t *data, uint8_t *data,
uint64_t offset, uint64_t offset,
@ -393,7 +375,7 @@ int proxmox_restore_read_image_at(ProxmoxRestoreHandle *handle,
* Note: The call will only ever transfer less than 'size' bytes if * Note: The call will only ever transfer less than 'size' bytes if
* the end of the file has been reached. * the end of the file has been reached.
*/ */
void proxmox_restore_read_image_at_async(ProxmoxRestoreHandle *handle, void proxmox_restore_read_image_at_async(struct ProxmoxRestoreHandle *handle,
uint8_t aid, uint8_t aid,
uint8_t *data, uint8_t *data,
uint64_t offset, uint64_t offset,
@ -403,4 +385,24 @@ void proxmox_restore_read_image_at_async(ProxmoxRestoreHandle *handle,
int *result, int *result,
char **error); char **error);
/**
* Serialize all state data into a byte buffer. Can be loaded again with
* proxmox_import_state. Use for migration for example.
*
* Length of the returned buffer is written to buf_size. Returned buffer must
* be freed with proxmox_free_state_buf.
*/
uint8_t *proxmox_export_state(uintptr_t *buf_size);
/**
* Load state serialized by proxmox_export_state. If loading fails, a message
* will be logged to stderr, but the function will not fail.
*/
void proxmox_import_state(const uint8_t *buf, uintptr_t buf_size);
/**
* Free a buffer acquired from proxmox_export_state.
*/
void proxmox_free_state_buf(uint8_t *buf);
#endif /* PROXMOX_BACKUP_QEMU_H */ #endif /* PROXMOX_BACKUP_QEMU_H */