From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Alex Williamson" <alex.williamson@redhat.com>,
"Fabiano Rosas" <farosas@suse.de>,
"Avihai Horon" <avihaih@nvidia.com>,
"Cédric Le Goater" <clg@redhat.com>
Subject: Re: [PATCH v2 0/4] Migration: Make misc.h helpers available for whole VM lifecycle
Date: Wed, 23 Oct 2024 15:25:54 -0400 [thread overview]
Message-ID: <ZxlNwoyaJ6mya8_H@x1n> (raw)
In-Reply-To: <20241023180216.1072575-1-peterx@redhat.com>
On Wed, Oct 23, 2024 at 02:02:12PM -0400, Peter Xu wrote:
> 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(-)
Sent too soon. This breaks device-introspect-test.. Sorry. I'll look at
that and repost.
Meanwhile please still comment on the idea, especially when one disagrees.
--
Peter Xu
next prev parent reply other threads:[~2024-10-23 19:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Peter Xu [this message]
2024-10-23 19:32 ` [PATCH v2 0/4] Migration: Make misc.h helpers available for whole VM lifecycle Fabiano Rosas
2024-10-23 20:03 ` Peter Xu
2024-10-23 21:03 ` Fabiano Rosas
2024-10-23 21:43 ` 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=ZxlNwoyaJ6mya8_H@x1n \
--to=peterx@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=avihaih@nvidia.com \
--cc=clg@redhat.com \
--cc=farosas@suse.de \
--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.