pve-qemu/debian/patches/pve/0072-PVE-backup-backup-access-api-explicit-bitmap-mode-pa.patch
Thomas Lamprecht cb662eb2c1 pve backup: implement features for external backup providers
This series of patches extends our existing QEMU backup integration
for PVE such that it can be used for a in-development external-backup
plugin API.

This includes among other things an API for backup access and teardown
as well as dirty-bitmap management. See the separate patches for more
details and check [v7] and [v8] of this series on the list. The former
is the last revision by Fiona which was already very advanced,
Wolfgang picked that up and extended/adapted it slightly to match
needs that he found during implementation of a test provider and from
feedback of (future) external backup provider like Bareos and Veritas.
This was mainly done to get the QEMU build out for broad QA, we can
still change things here as long as the rest of the series is not yet
applied.

[v7]: https://lore.proxmox.com/pve-devel/20250401173435.221892-1-f.ebner@proxmox.com/
[v8]: https://lore.proxmox.com/pve-devel/20250403123118.264974-1-w.bumiller@proxmox.com/

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-03 16:48:42 +02:00

85 lines
3.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
Date: Thu, 3 Apr 2025 14:30:50 +0200
Subject: [PATCH] PVE backup: backup-access-api: explicit bitmap-mode parameter
This allows to explicitly request to re-create a bitmap under the same
name.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
[TL: fix trailing whitespace error]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
pve-backup.c | 17 ++++++++++++++++-
qapi/block-core.json | 20 +++++++++++++++++++-
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/pve-backup.c b/pve-backup.c
index 8909842292..18bcf29533 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -1043,7 +1043,16 @@ BackupAccessInfoList *coroutine_fn qmp_backup_access_setup(
error_propagate(errp, local_err);
goto err;
}
- di->requested_bitmap_name = g_strdup(it->value->bitmap_name);
+ if (it->value->bitmap_mode == BACKUP_ACCESS_SETUP_BITMAP_MODE_NONE) {
+ di->bitmap_action = PBS_BITMAP_ACTION_NOT_USED;
+ } else {
+ di->requested_bitmap_name = g_strdup(it->value->bitmap_name);
+ if (it->value->bitmap_mode == BACKUP_ACCESS_SETUP_BITMAP_MODE_NEW) {
+ di->bitmap_action = PBS_BITMAP_ACTION_NEW;
+ } else if (it->value->bitmap_mode == BACKUP_ACCESS_SETUP_BITMAP_MODE_USE) {
+ di->bitmap_action = PBS_BITMAP_ACTION_USED;
+ }
+ }
di_list = g_list_append(di_list, di);
}
bdrv_graph_co_rdunlock();
@@ -1096,6 +1105,12 @@ BackupAccessInfoList *coroutine_fn qmp_backup_access_setup(
&& di->requested_bitmap_name
&& strcmp(di->requested_bitmap_name, old_bitmap_name) == 0;
+ /* special case: if we explicitly requested a *new* bitmap, treat an
+ * existing bitmap as having a different name */
+ if (di->bitmap_action == PBS_BITMAP_ACTION_NEW) {
+ same_bitmap_name = false;
+ }
+
if (old_bitmap_name && !same_bitmap_name) {
BdrvDirtyBitmap *old_bitmap = bdrv_find_dirty_bitmap(di->bs, old_bitmap_name);
if (!old_bitmap) {
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 58586170d9..09beb3217c 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1145,9 +1145,27 @@
# in the result to see if you can actually re-use the bitmap or if it had to
# be newly created.
#
+# @bitmap-mode: used to control whether the bitmap should be reused or
+# recreated.
+#
##
{ 'struct': 'BackupAccessSourceDevice',
- 'data': { 'device': 'str', '*bitmap-name': 'str' } }
+ 'data': { 'device': 'str', '*bitmap-name': 'str',
+ '*bitmap-mode': 'BackupAccessSetupBitmapMode' } }
+
+##
+# @BackupAccessSetupBitmapMode:
+#
+# How to setup a bitmap for a device for @backup-access-setup.
+#
+# @none: do not use a bitmap. Removes an existing bitmap if present.
+#
+# @new: create and use a new bitmap.
+#
+# @use: try to re-use an existing bitmap. Create a new one if it doesn't exist.
+##
+{ 'enum': 'BackupAccessSetupBitmapMode',
+ 'data': ['none', 'new', 'use' ] }
##
# @backup-access-setup: