qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Migration: Make misc.h helpers available for whole VM lifecycle
@ 2024-10-23 18:02 Peter Xu
  2024-10-23 18:02 ` [PATCH v2 1/4] migration: Unexport dirty_bitmap_mig_init() in misc.h Peter Xu
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Peter Xu @ 2024-10-23 18:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: peterx, Alex Williamson, Fabiano Rosas, Avihai Horon,
	Cédric Le Goater

This is a follow up of below patch from Avihai as a replacement:

https://lore.kernel.org/qemu-devel/20241020130108.27148-3-avihaih@nvidia.com/

This is v2 of the series, and it became a more generic rework on how we do
migration object refcounts, so I skipped a changelog because most of this
is new things.

To put it simple, now I introduced another pointer to migration object, and
here's a simple explanation for both after all change applied (copy-paste
from one of the patch):

/*
 * We have two pointers for the global migration objects.  Both of them are
 * initialized early during QEMU starts, but they have different lifecycles.
 *
 * - current_migration
 *
 *   This variable reflects the whole lifecycle of the migration object
 *   (which each QEMU can only have one).  It is valid until the migration
 *   object is destroyed.
 *
 *   This is the object that internal migration so far use.  For example,
 *   internal helper migrate_get_current() references it.
 *
 *   When all migration code can always pass over a MigrationState* around,
 *   this variable can logically be dropped.  But we're not yet there.
 *
 * - global_migration
 *
 *   This is valid only until the migration object is still valid to the
 *   outside-migration world (until migration_shutdown()).
 *
 *   This should normally be always set, cleared or accessed by the main
 *   thread only, rather than the migration thread.
 *
 *   All the exported functions (in include/migration) should reference the
 *   exported migration object only to avoid race conditions, as
 *   current_migration can be freed concurrently by migration thread when
 *   the migration thread holds the last refcount.
 */

It allows all misc.h exported helpers to be used for the whole VM
lifecycle, so as to never crash QEMU with freed migration objects.

Thanks,

Peter Xu (4):
  migration: Unexport dirty_bitmap_mig_init() in misc.h
  migration: Reset current_migration properly
  migration: Add global_migration
  migration: Make all helpers in misc.h safe to use without migration

 include/migration/misc.h | 29 ++++++++----
 migration/migration.h    |  4 ++
 migration/migration.c    | 99 +++++++++++++++++++++++++++++++++++-----
 3 files changed, 113 insertions(+), 19 deletions(-)

-- 
2.45.0



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-10-23 21:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23 18:02 [PATCH v2 0/4] Migration: Make misc.h helpers available for whole VM lifecycle Peter Xu
2024-10-23 18:02 ` [PATCH v2 1/4] migration: Unexport dirty_bitmap_mig_init() in misc.h Peter Xu
2024-10-23 18:02 ` [PATCH v2 2/4] migration: Reset current_migration properly Peter Xu
2024-10-23 18:02 ` [PATCH v2 3/4] migration: Add global_migration Peter Xu
2024-10-23 18:02 ` [PATCH v2 4/4] migration: Make all helpers in misc.h safe to use without migration Peter Xu
2024-10-23 18:19   ` Peter Xu
2024-10-23 19:25 ` [PATCH v2 0/4] Migration: Make misc.h helpers available for whole VM lifecycle Peter Xu
2024-10-23 19:32 ` Fabiano Rosas
2024-10-23 20:03   ` Peter Xu
2024-10-23 21:03     ` Fabiano Rosas
2024-10-23 21:43       ` Peter Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).