From: Erik Fastermann <e.fastermann@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Erik Fastermann <e.fastermann@proxmox.com>
Subject: [PATCH qemu v2 2/9] pbs-restore: keep callback data on the stack
Date: Mon, 7 Sep 2026 11:47:36 +0200 [thread overview]
Message-ID: <20260907094744.131193-3-e.fastermann@proxmox.com> (raw)
In-Reply-To: <20260907094744.131193-1-e.fastermann@proxmox.com>
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 <e.fastermann@proxmox.com>
---
...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 <t.lamprecht@proxmox.com>
[WB: add namespace support]
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
+[EF: keep callback data on the stack]
+Signed-off-by: Erik Fastermann <e.fastermann@proxmox.com>
---
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 <c.ebner@proxmox.com>
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
next prev parent reply other threads:[~2026-09-07 9:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 9:47 [PATCH qemu v2 0/9] savevm-async: fix stuck paused vm after snapshot Erik Fastermann
2026-09-07 9:47 ` [PATCH qemu v2 1/9] d/patches: normalize header of pbs-restore no-cache patch Erik Fastermann
2026-09-07 9:47 ` Erik Fastermann [this message]
2026-09-07 9:47 ` [PATCH qemu v2 3/9] migration/qemu-file: allocate buffer with g_malloc Erik Fastermann
2026-09-07 9:47 ` [PATCH qemu v2 4/9] migration/pbs-state: check allocation of incoming state buffer Erik Fastermann
2026-09-07 9:47 ` [PATCH qemu v2 5/9] savevm-async: drop QIOChannel reference Erik Fastermann
2026-09-08 14:22 ` Fiona Ebner
2026-09-07 9:47 ` [PATCH qemu v2 6/9] savevm-async: free migration vmdesc Erik Fastermann
2026-09-08 14:22 ` Fiona Ebner
2026-09-07 9:47 ` [PATCH qemu v2 7/9] savevm-async: release resources on start failure path Erik Fastermann
2026-09-07 9:47 ` [PATCH qemu v2 8/9] savevm-async: include reason when file open fails Erik Fastermann
2026-09-07 9:47 ` [PATCH qemu v2 9/9] savevm-async: restore run state from before snapshot Erik Fastermann
2026-09-08 14:22 ` Fiona Ebner
2026-09-08 14:21 ` partially-applied: [PATCH qemu v2 0/9] savevm-async: fix stuck paused vm after snapshot Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260907094744.131193-3-e.fastermann@proxmox.com \
--to=e.fastermann@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox