]> git.proxmox.com Git - pve-qemu.git/blobdiff - debian/patches/pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
update submodule and patches to 7.1.0
[pve-qemu.git] / debian / patches / pve / 0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
index 02e78c5867aa1e594d41de6fa695fdf3d0134684..6c61992de163d924f77c95f47efc44eb96b2c417 100644 (file)
@@ -6,39 +6,32 @@ Subject: [PATCH] PVE-Backup: pbs-restore - new command to restore from proxmox
 
 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
 ---
- Makefile      |   4 +-
- pbs-restore.c | 217 ++++++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 220 insertions(+), 1 deletion(-)
+ meson.build   |   4 +
+ pbs-restore.c | 223 ++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 227 insertions(+)
  create mode 100644 pbs-restore.c
 
-diff --git a/Makefile b/Makefile
-index aec216968d..b73da29f24 100644
---- a/Makefile
-+++ b/Makefile
-@@ -479,7 +479,7 @@ dummy := $(call unnest-vars,, \
- include $(SRC_PATH)/tests/Makefile.include
--all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) vma$(EXESUF) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
-+all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) vma$(EXESUF) pbs-restore$(EXESUF) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
- qemu-version.h: FORCE
-       $(call quiet-command, \
-@@ -604,6 +604,8 @@ qemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-o
- qemu-storage-daemon$(EXESUF): qemu-storage-daemon.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(chardev-obj-y) $(io-obj-y) $(qom-obj-y) $(storage-daemon-obj-y) $(COMMON_LDADDS)
- qemu-storage-daemon$(EXESUF): LIBS += -lproxmox_backup_qemu
- vma$(EXESUF): vma.o vma-reader.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
-+pbs-restore$(EXESUF): pbs-restore.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
-+pbs-restore$(EXESUF): LIBS += -lproxmox_backup_qemu
- qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
+diff --git a/meson.build b/meson.build
+index 0bc2fb5b10..f48d2e0457 100644
+--- a/meson.build
++++ b/meson.build
+@@ -3613,6 +3613,10 @@ if have_tools
+   vma = executable('vma', files('vma.c', 'vma-reader.c') + genh,
+                    dependencies: [authz, block, crypto, io, qom], install: true)
  
++  pbs_restore = executable('pbs-restore', files('pbs-restore.c') + genh,
++                  dependencies: [authz, block, crypto, io, qom,
++                    libproxmox_backup_qemu], install: true)
++
+   subdir('storage-daemon')
+   subdir('contrib/rdmacm-mux')
+   subdir('contrib/elf2dmp')
 diff --git a/pbs-restore.c b/pbs-restore.c
 new file mode 100644
-index 0000000000..4bf37ef1fa
+index 0000000000..2f834cf42e
 --- /dev/null
 +++ b/pbs-restore.c
-@@ -0,0 +1,217 @@
+@@ -0,0 +1,223 @@
 +/*
 + * Qemu image restore helper for Proxmox Backup
 + *
@@ -57,7 +50,6 @@ index 0000000000..4bf37ef1fa
 +#include <getopt.h>
 +#include <string.h>
 +
-+#include "qemu-common.h"
 +#include "qemu/module.h"
 +#include "qemu/error-report.h"
 +#include "qemu/main-loop.h"
@@ -103,7 +95,7 @@ index 0000000000..4bf37ef1fa
 +        }
 +        res = blk_pwrite_zeroes(callback_data->target, offset, data_len, 0);
 +    } else {
-+        res = blk_pwrite(callback_data->target, offset, data, data_len, 0);
++        res = blk_pwrite(callback_data->target, offset, data_len, data, 0);
 +    }
 +
 +    if (res < 0) {
@@ -202,13 +194,19 @@ index 0000000000..4bf37ef1fa
 +        fprintf(stderr, "connecting to repository '%s'\n", repository);
 +    }
 +    char *pbs_error = NULL;
-+    ProxmoxRestoreHandle *conn = proxmox_restore_connect(
++    ProxmoxRestoreHandle *conn = proxmox_restore_new(
 +        repository, snapshot, password, keyfile, key_password, fingerprint, &pbs_error);
 +    if (conn == NULL) {
 +        fprintf(stderr, "restore failed: %s\n", pbs_error);
 +        return -1;
 +    }
 +
++    int res = proxmox_restore_connect(conn, &pbs_error);
++    if (res < 0 || pbs_error) {
++        fprintf(stderr, "restore failed (connection error): %s\n", pbs_error);
++        return -1;
++    }
++
 +    QDict *options = qdict_new();
 +
 +    if (format) {
@@ -239,7 +237,7 @@ index 0000000000..4bf37ef1fa
 +        fprintf(stderr, "starting to restore snapshot '%s'\n", snapshot);
 +        fflush(stderr); // ensure we do not get printed after the progress log
 +    }
-+    int res = proxmox_restore_image(
++    res = proxmox_restore_image(
 +        conn,
 +        archive_name,
 +        write_callback,
@@ -248,6 +246,7 @@ index 0000000000..4bf37ef1fa
 +        verbose);
 +
 +    proxmox_restore_disconnect(conn);
++    blk_unref(blk);
 +
 +    if (res < 0) {
 +        fprintf(stderr, "restore failed: %s\n", pbs_error);