backup: factor out & clean up gathering device info into helper
Squash the two original patches [0][1] from Fiona, which got send separate to be easier to review, into the big patch that adds the Proxmox backup integration. [0]: https://lists.proxmox.com/pipermail/pve-devel/2024-January/061479.html [1]: https://lists.proxmox.com/pipermail/pve-devel/2024-January/061478.html Originally-by: Fiona Ebner <f.ebner@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
cd7676f3e6
commit
8dd76cc52d
@ -14,6 +14,7 @@ Additionally, allows tracking the current position from the outside
|
||||
(intended to be used for progress tracking).
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
migration/channel-savevm-async.c | 183 +++++++++++++++++++++++++++++++
|
||||
migration/channel-savevm-async.h | 51 +++++++++
|
||||
|
@ -94,11 +94,11 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
monitor/hmp-cmds.c | 72 +++
|
||||
proxmox-backup-client.c | 146 +++++
|
||||
proxmox-backup-client.h | 60 ++
|
||||
pve-backup.c | 1072 ++++++++++++++++++++++++++++++++
|
||||
pve-backup.c | 1089 ++++++++++++++++++++++++++++++++
|
||||
qapi/block-core.json | 229 +++++++
|
||||
qapi/common.json | 14 +
|
||||
qapi/machine.json | 16 +-
|
||||
14 files changed, 1687 insertions(+), 14 deletions(-)
|
||||
14 files changed, 1704 insertions(+), 14 deletions(-)
|
||||
create mode 100644 proxmox-backup-client.c
|
||||
create mode 100644 proxmox-backup-client.h
|
||||
create mode 100644 pve-backup.c
|
||||
@ -586,10 +586,10 @@ index 0000000000..8cbf645b2c
|
||||
+#endif /* PROXMOX_BACKUP_CLIENT_H */
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
new file mode 100644
|
||||
index 0000000000..5ed3c6a310
|
||||
index 0000000000..ae3d137e12
|
||||
--- /dev/null
|
||||
+++ b/pve-backup.c
|
||||
@@ -0,0 +1,1072 @@
|
||||
@@ -0,0 +1,1089 @@
|
||||
+#include "proxmox-backup-client.h"
|
||||
+#include "vma.h"
|
||||
+
|
||||
@ -1173,6 +1173,66 @@ index 0000000000..5ed3c6a310
|
||||
+ aio_co_enter(data->ctx, data->co);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Returns a list of device infos, which needs to be freed by the caller. In
|
||||
+ * case of an error, errp will be set, but the returned value might still be a
|
||||
+ * list.
|
||||
+ */
|
||||
+static GList coroutine_fn *get_device_info(
|
||||
+ const char *devlist,
|
||||
+ Error **errp)
|
||||
+{
|
||||
+ gchar **devs = NULL;
|
||||
+ GList *di_list = NULL;
|
||||
+
|
||||
+ if (devlist) {
|
||||
+ devs = g_strsplit_set(devlist, ",;:", -1);
|
||||
+
|
||||
+ gchar **d = devs;
|
||||
+ while (d && *d) {
|
||||
+ BlockBackend *blk = blk_by_name(*d);
|
||||
+ if (!blk) {
|
||||
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
+ "Device '%s' not found", *d);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ BlockDriverState *bs = blk_bs(blk);
|
||||
+ if (!bdrv_co_is_inserted(bs)) {
|
||||
+ error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, *d);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
+ di->bs = bs;
|
||||
+ di_list = g_list_append(di_list, di);
|
||||
+ d++;
|
||||
+ }
|
||||
+ } else {
|
||||
+ BdrvNextIterator it;
|
||||
+
|
||||
+ for (BlockDriverState *bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
|
||||
+ if (!bdrv_co_is_inserted(bs) || bdrv_is_read_only(bs)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
+ di->bs = bs;
|
||||
+ di_list = g_list_append(di_list, di);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!di_list) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "empty device list");
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
+err:
|
||||
+ if (devs) {
|
||||
+ g_strfreev(devs);
|
||||
+ }
|
||||
+
|
||||
+ return di_list;
|
||||
+}
|
||||
+
|
||||
+UuidInfo coroutine_fn *qmp_backup(
|
||||
+ const char *backup_file,
|
||||
+ const char *password,
|
||||
@ -1198,13 +1258,10 @@ index 0000000000..5ed3c6a310
|
||||
+
|
||||
+ qemu_co_mutex_lock(&backup_state.backup_mutex);
|
||||
+
|
||||
+ BlockBackend *blk;
|
||||
+ BlockDriverState *bs = NULL;
|
||||
+ Error *local_err = NULL;
|
||||
+ uuid_t uuid;
|
||||
+ VmaWriter *vmaw = NULL;
|
||||
+ ProxmoxBackupHandle *pbs = NULL;
|
||||
+ gchar **devs = NULL;
|
||||
+ GList *di_list = NULL;
|
||||
+ GList *l;
|
||||
+ UuidInfo *uuid_info;
|
||||
@ -1222,48 +1279,12 @@ index 0000000000..5ed3c6a310
|
||||
+ /* Todo: try to auto-detect format based on file name */
|
||||
+ format = has_format ? format : BACKUP_FORMAT_VMA;
|
||||
+
|
||||
+ if (devlist) {
|
||||
+ devs = g_strsplit_set(devlist, ",;:", -1);
|
||||
+
|
||||
+ gchar **d = devs;
|
||||
+ while (d && *d) {
|
||||
+ blk = blk_by_name(*d);
|
||||
+ if (blk) {
|
||||
+ bs = blk_bs(blk);
|
||||
+ if (!bdrv_co_is_inserted(bs)) {
|
||||
+ error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, *d);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
+ di->bs = bs;
|
||||
+ di_list = g_list_append(di_list, di);
|
||||
+ } else {
|
||||
+ error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
|
||||
+ "Device '%s' not found", *d);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ d++;
|
||||
+ }
|
||||
+
|
||||
+ } else {
|
||||
+ BdrvNextIterator it;
|
||||
+
|
||||
+ bs = NULL;
|
||||
+ for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
|
||||
+ if (!bdrv_co_is_inserted(bs) || bdrv_is_read_only(bs)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
|
||||
+ di->bs = bs;
|
||||
+ di_list = g_list_append(di_list, di);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!di_list) {
|
||||
+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "empty device list");
|
||||
+ di_list = get_device_info(devlist, &local_err);
|
||||
+ if (local_err) {
|
||||
+ error_propagate(errp, local_err);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ assert(di_list);
|
||||
+
|
||||
+ size_t total = 0;
|
||||
+
|
||||
@ -1551,10 +1572,6 @@ index 0000000000..5ed3c6a310
|
||||
+ g_list_free(di_list);
|
||||
+ backup_state.di_list = NULL;
|
||||
+
|
||||
+ if (devs) {
|
||||
+ g_strfreev(devs);
|
||||
+ }
|
||||
+
|
||||
+ if (vmaw) {
|
||||
+ Error *err = NULL;
|
||||
+ vma_writer_close(vmaw, &err);
|
||||
|
@ -174,10 +174,10 @@ index 0000000000..887e998b9e
|
||||
+ NULL);
|
||||
+}
|
||||
diff --git a/pve-backup.c b/pve-backup.c
|
||||
index 5ed3c6a310..6720e985bc 100644
|
||||
index ae3d137e12..e6b17b797e 100644
|
||||
--- a/pve-backup.c
|
||||
+++ b/pve-backup.c
|
||||
@@ -1065,6 +1065,7 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
@@ -1082,6 +1082,7 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
|
||||
ret->pbs_library_version = g_strdup(proxmox_backup_qemu_version());
|
||||
ret->pbs_dirty_bitmap = true;
|
||||
ret->pbs_dirty_bitmap_savevm = true;
|
||||
|
@ -7,6 +7,7 @@ This reverts commit fc176116cdea816ceb8dd969080b2b95f58edbc0 in
|
||||
preparation to revert 0347a8fd4c3faaedf119be04c197804be40a384b.
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/rbd.c | 42 ++----------------------------------------
|
||||
1 file changed, 2 insertions(+), 40 deletions(-)
|
||||
|
@ -8,6 +8,7 @@ This reverts commit 9e302f64bb407a9bb097b626da97228c2654cfee in
|
||||
preparation to revert 0347a8fd4c3faaedf119be04c197804be40a384b.
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/rbd.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
@ -18,6 +18,7 @@ Upstream bug report:
|
||||
https://gitlab.com/qemu-project/qemu/-/issues/1026
|
||||
|
||||
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/rbd.c | 112 ----------------------------------------------------
|
||||
1 file changed, 112 deletions(-)
|
||||
|
@ -67,6 +67,7 @@ general to not leave unnecessary block nodes lying around.
|
||||
|
||||
Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
block/alloc-track.c | 54 ++++++++++++++-------------------------------
|
||||
1 file changed, 16 insertions(+), 38 deletions(-)
|
||||
|
@ -43,6 +43,7 @@ callbacks that need the BQL and only take the lock if it's not already
|
||||
held.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
include/migration/register.h | 2 +-
|
||||
migration/block-dirty-bitmap.c | 15 ++++++++++++---
|
||||
|
@ -8,6 +8,7 @@ callbacks" for why. This is separate, because a version of that one
|
||||
will hopefully land upstream.
|
||||
|
||||
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||||
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
||||
---
|
||||
migration/savevm-async.c | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
Loading…
Reference in New Issue
Block a user