From: Fabiano Rosas <farosas@suse.de>
To: qemu-devel@nongnu.org
Cc: Peter Xu <peterx@redhat.com>
Subject: [PATCH 2/3] migration: Drop iochannel reference during snapshot setup
Date: Thu, 3 Sep 2026 19:05:22 -0300 [thread overview]
Message-ID: <20260903220523.2849019-3-farosas@suse.de> (raw)
In-Reply-To: <20260903220523.2849019-1-farosas@suse.de>
During migration there are usually two references to the iochannel,
one from the channel creation itself and another from the ownership
transfer into QEMUFile.
- The reference from the QEMUFile is decremented at qemu_fclose.
- The original reference is decremented at migration_connect_outgoing()
for regular migration and not at all for snapshots.
The ide-test has recently added migration support and ASAN has
flagged:
Indirect leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x55ca12aac0b9 in realloc
#1 0x7fd97d7e5a05 in g_realloc
#3 0x7fd97d7c98c6 in g_hash_table_new_full
#4 0x55ca14e186f1 in object_initialize_with_type ../qom/object.c:506:23
#5 0x55ca14e1a590 in object_new_with_type ../qom/object.c:706:5
#6 0x55ca14e1a7e8 in object_new ../qom/object.c:722:12
#7 0x55ca12de896f in qio_channel_block_new ../migration/channel-block.c:32:29
#8 0x55ca12ec8f2d in qemu_fopen_bdrv ../migration/savevm.c:172:49
#9 0x55ca12ec8b42 in save_snapshot ../migration/savevm.c:3375:9
#10 0x55ca12ee18e3 in hmp_savevm ../migration/migration-hmp-cmds.c:497:5
Change qemu_fopen_bdrv() to drop the original reference once the
QEMUFile has taken over the object. The xen code already does the
same.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
migration/savevm.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/migration/savevm.c b/migration/savevm.c
index 5b0e89ca7c..8d4bdc28ab 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -168,11 +168,16 @@ static bool qemu_loadvm_thread_pool_wait(MigrationState *s,
static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable)
{
+ QIOChannel *ioc = QIO_CHANNEL(qio_channel_block_new(bs));
+ QEMUFile *f;
+
if (is_writable) {
- return qemu_file_new_output(QIO_CHANNEL(qio_channel_block_new(bs)));
+ f = qemu_file_new_output(ioc);
} else {
- return qemu_file_new_input(QIO_CHANNEL(qio_channel_block_new(bs)));
+ f = qemu_file_new_input(ioc);
}
+ object_unref(ioc);
+ return f;
}
--
2.53.0
next prev parent reply other threads:[~2026-09-03 22:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 22:05 [PATCH 0/3] A few leak fixes for QTest Fabiano Rosas
2026-09-03 22:05 ` [PATCH 1/3] ahci: Fix leak of IRQState Fabiano Rosas
2026-09-03 23:06 ` Denis V. Lunev
2026-09-04 8:31 ` Peter Maydell
2026-09-04 11:01 ` Philippe Mathieu-Daudé
2026-09-03 22:05 ` Fabiano Rosas [this message]
2026-09-04 6:25 ` [PATCH 2/3] migration: Drop iochannel reference during snapshot setup Marc-André Lureau
2026-09-04 13:54 ` Peter Xu
2026-09-03 22:05 ` [PATCH 3/3] migration: Free the JSON writer during snapshots Fabiano Rosas
2026-09-04 12:09 ` Marc-André Lureau
2026-09-04 14:00 ` Peter Xu
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=20260903220523.2849019-3-farosas@suse.de \
--to=farosas@suse.de \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.