proxmox_restore_image() is synchronous and only hands the pointer back
to the callback, so the lifetime is the enclosing scope. Dropping the
heap allocation also drops its missing free and calloc() call, which is
discouraged in QEMU.

Signed-off-by: Erik Fastermann <[email protected]>
---
 ...s-restore-new-command-to-restore-from-p.patch | 16 +++++++++-------
 ...dd-no-cache-flag-to-skip-host-page-cach.patch |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git 
a/debian/patches/pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
 
b/debian/patches/pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
index 6d5bb42..bd11662 100644
--- 
a/debian/patches/pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
+++ 
b/debian/patches/pve/0030-PVE-Backup-pbs-restore-new-command-to-restore-from-p.patch
@@ -7,6 +7,8 @@ Subject: [PATCH] PVE-Backup: pbs-restore - new command to 
restore from proxmox
 Signed-off-by: Thomas Lamprecht <[email protected]>
 [WB: add namespace support]
 Signed-off-by: Wolfgang Bumiller <[email protected]>
+[EF: keep callback data on the stack]
+Signed-off-by: Erik Fastermann <[email protected]>
 ---
  meson.build   |   4 +
  pbs-restore.c | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -30,7 +32,7 @@ index 1eee80f7d8..b7a8702711 100644
    foreach exe: [ 'qemu-img', 'qemu-io', 'qemu-nbd', 'qemu-storage-daemon']
 diff --git a/pbs-restore.c b/pbs-restore.c
 new file mode 100644
-index 0000000000..f165f418af
+index 0000000000..f5e3552193
 --- /dev/null
 +++ b/pbs-restore.c
 @@ -0,0 +1,236 @@
@@ -240,11 +242,11 @@ index 0000000000..f165f418af
 +        return -1;
 +    }
 +
-+    CallbackData *callback_data = calloc(sizeof(CallbackData), 1);
-+
-+    callback_data->target = blk;
-+    callback_data->skip_zero = skip_zero;
-+    callback_data->last_offset = 0;
++    CallbackData callback_data = {
++        .target = blk,
++        .skip_zero = skip_zero,
++        .last_offset = 0,
++    };
 +
 +    // blk_set_enable_write_cache(blk, !writethrough);
 +
@@ -256,7 +258,7 @@ index 0000000000..f165f418af
 +        conn,
 +        archive_name,
 +        write_callback,
-+        callback_data,
++        &callback_data,
 +        &pbs_error,
 +        verbose);
 +
diff --git 
a/debian/patches/pve/0047-pbs-restore-add-no-cache-flag-to-skip-host-page-cach.patch
 
b/debian/patches/pve/0047-pbs-restore-add-no-cache-flag-to-skip-host-page-cach.patch
index 3ef6e69..7b79722 100644
--- 
a/debian/patches/pve/0047-pbs-restore-add-no-cache-flag-to-skip-host-page-cach.patch
+++ 
b/debian/patches/pve/0047-pbs-restore-add-no-cache-flag-to-skip-host-page-cach.patch
@@ -25,7 +25,7 @@ Signed-off-by: Christian Ebner <[email protected]>
  1 file changed, 11 insertions(+)
 
 diff --git a/pbs-restore.c b/pbs-restore.c
-index f165f418af..55a3cb235d 100644
+index f5e3552193..592b20f7ad 100644
 --- a/pbs-restore.c
 +++ b/pbs-restore.c
 @@ -81,6 +81,7 @@ int main(int argc, char **argv)
-- 
2.47.3



Reply via email to