All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Peter Xu <peterx@redhat.com>, qemu-devel@nongnu.org
Cc: peterx@redhat.com, Lukas Straub <lukasstraub2@web.de>,
	Prasad Pandit <ppandit@redhat.com>,
	Juraj Marcin <jmarcin@redhat.com>
Subject: Re: [PATCH v2 20/24] migration: Introduce qemu_savevm_state_active()
Date: Mon, 02 Feb 2026 12:07:03 -0300	[thread overview]
Message-ID: <874inzrxpk.fsf@suse.de> (raw)
In-Reply-To: <20260127185254.3954634-21-peterx@redhat.com>

Peter Xu <peterx@redhat.com> writes:

> Introduce this helper to detect if a SaveStateEntry is active.
>
> Note that this helper can actually also be used in loadvm paths, but let's
> stick with this name for now because we still use SaveStateEntry for the
> shared structure that both savevm/loadvm uses, where this name still suites.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  migration/savevm.c | 63 ++++++++++++++++++++--------------------------
>  1 file changed, 27 insertions(+), 36 deletions(-)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index b04a21ffc9..c16951b532 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1071,6 +1071,16 @@ void qemu_savevm_state_end(QEMUFile *f)
>      qemu_put_byte(f, QEMU_VM_EOF);
>  }
>  
> +static inline bool qemu_savevm_state_active(SaveStateEntry *se)
> +{
> +    /* When no is_active() hook, always treat it as ACTIVE */
> +    if (!se->ops->is_active) {
> +        return true;
> +    }
> +
> +    return se->ops->is_active(se->opaque);
> +}
> +
>  /**
>   * qemu_savevm_command_send: Send a 'QEMU_VM_COMMAND' type element with the
>   *                           command and associated data.
> @@ -1352,12 +1362,9 @@ int qemu_savevm_state_prepare(Error **errp)
>          if (!se->ops || !se->ops->save_prepare) {
>              continue;
>          }
> -        if (se->ops->is_active) {
> -            if (!se->ops->is_active(se->opaque)) {
> -                continue;
> -            }
> +        if (!qemu_savevm_state_active(se)) {
> +            continue;
>          }
> -
>          ret = se->ops->save_prepare(se->opaque, errp);
>          if (ret < 0) {
>              return ret;
> @@ -1397,10 +1404,8 @@ static int qemu_savevm_state_setup(QEMUFile *f, Error **errp)
>          if (!se->ops || !se->ops->save_setup) {
>              continue;
>          }
> -        if (se->ops->is_active) {
> -            if (!se->ops->is_active(se->opaque)) {
> -                continue;
> -            }
> +        if (!qemu_savevm_state_active(se)) {
> +            continue;
>          }
>          save_section_header(f, se, QEMU_VM_SECTION_START);
>          ret = se->ops->save_setup(f, se->opaque, errp);
> @@ -1450,10 +1455,8 @@ int qemu_savevm_state_resume_prepare(MigrationState *s)
>          if (!se->ops || !se->ops->resume_prepare) {
>              continue;
>          }
> -        if (se->ops->is_active) {
> -            if (!se->ops->is_active(se->opaque)) {
> -                continue;
> -            }
> +        if (!qemu_savevm_state_active(se)) {
> +            continue;
>          }
>          ret = se->ops->resume_prepare(s, se->opaque);
>          if (ret < 0) {
> @@ -1481,8 +1484,7 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy)
>          if (!se->ops || !se->ops->save_live_iterate) {
>              continue;
>          }
> -        if (se->ops->is_active &&
> -            !se->ops->is_active(se->opaque)) {
> +        if (!qemu_savevm_state_active(se)) {
>              continue;
>          }
>          if (se->ops->is_active_iterate &&
> @@ -1543,10 +1545,8 @@ static int qemu_savevm_complete(SaveStateEntry *se, QEMUFile *f)
>  {
>      int ret;
>  
> -    if (se->ops->is_active) {
> -        if (!se->ops->is_active(se->opaque)) {
> -            return 0;
> -        }
> +    if (!qemu_savevm_state_active(se)) {
> +        return 0;
>      }
>  
>      trace_savevm_section_start(se->idstr, se->section_id);
> @@ -1596,10 +1596,8 @@ bool qemu_savevm_state_postcopy_prepare(QEMUFile *f, Error **errp)
>              continue;
>          }
>  
> -        if (se->ops->is_active) {
> -            if (!se->ops->is_active(se->opaque)) {
> -                continue;
> -            }
> +        if (!qemu_savevm_state_active(se)) {
> +            continue;
>          }
>  
>          trace_savevm_section_start(se->idstr, se->section_id);
> @@ -1785,10 +1783,8 @@ void qemu_savevm_state_pending_estimate(uint64_t *must_precopy,
>          if (!se->ops || !se->ops->state_pending_estimate) {
>              continue;
>          }
> -        if (se->ops->is_active) {
> -            if (!se->ops->is_active(se->opaque)) {
> -                continue;
> -            }
> +        if (!qemu_savevm_state_active(se)) {
> +            continue;
>          }
>          se->ops->state_pending_estimate(se->opaque, must_precopy, can_postcopy);
>      }
> @@ -1806,10 +1802,8 @@ void qemu_savevm_state_pending_exact(uint64_t *must_precopy,
>          if (!se->ops || !se->ops->state_pending_exact) {
>              continue;
>          }
> -        if (se->ops->is_active) {
> -            if (!se->ops->is_active(se->opaque)) {
> -                continue;
> -            }
> +        if (!qemu_savevm_state_active(se)) {
> +            continue;
>          }
>          se->ops->state_pending_exact(se->opaque, must_precopy, can_postcopy);
>      }
> @@ -2829,12 +2823,9 @@ static int qemu_loadvm_state_setup(QEMUFile *f, Error **errp)
>          if (!se->ops || !se->ops->load_setup) {
>              continue;
>          }
> -        if (se->ops->is_active) {
> -            if (!se->ops->is_active(se->opaque)) {
> -                continue;
> -            }
> +        if (!qemu_savevm_state_active(se)) {
> +            continue;
>          }
> -
>          ret = se->ops->load_setup(f, se->opaque, errp);
>          if (ret < 0) {
>              error_prepend(errp, "Load state of device %s failed: ",

Reviewed-by: Fabiano Rosas <farosas@suse.de>


  reply	other threads:[~2026-02-02 15:07 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 18:52 [PATCH v2 00/24] migration: small cleanup series Peter Xu
2026-01-27 18:52 ` [PATCH v2 01/24] migration: Introduce qemu_savevm_send_* helpers Peter Xu
2026-01-27 18:52 ` [PATCH v2 02/24] migration: Use qemu_savevm_send_header() in qemu_save_device_state() Peter Xu
2026-01-27 18:52 ` [PATCH v2 03/24] migration: Remove one migration_in_colo_state() occurance Peter Xu
2026-01-27 18:52 ` [PATCH v2 04/24] migration/savevm: Remove SaveStateEntry.is_ram Peter Xu
2026-01-27 18:52 ` [PATCH v2 05/24] migration/colo: Unwrap qemu_savevm_live_state() Peter Xu
2026-01-27 18:52 ` [PATCH v2 06/24] migration: Remove call to send switchover start event in colo/savevm Peter Xu
2026-01-28 15:07   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 07/24] colo: Forbid VM resume during checkpointing Peter Xu
2026-01-27 18:52 ` [PATCH v2 08/24] migration/colo: Use the RAM iterable helper directly Peter Xu
2026-01-27 18:52 ` [PATCH v2 09/24] migration/colo: Document qemu_fflush(fb) Peter Xu
2026-01-28 15:08   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 10/24] migration: Drop iterable_only in qemu_savevm_state_complete_precopy Peter Xu
2026-01-27 18:52 ` [PATCH v2 11/24] migration: Drop qemu_file_set_error() when save non-iterable fails Peter Xu
2026-01-28 15:08   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 12/24] migration/colo: Send device states without copying buffer Peter Xu
2026-01-28 15:12   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 13/24] migration/postcopy: " Peter Xu
2026-01-28 15:18   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 14/24] migration: Introduce qemu_savevm_state_end() Peter Xu
2026-01-28 15:22   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 15/24] migration: Provide helper for save vm description Peter Xu
2026-01-28 15:22   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 16/24] migration: Split qemu_savevm_state_complete_precopy_non_iterable() Peter Xu
2026-01-28 15:22   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 17/24] migration: qemu_savevm_state_complete_precopy() take MigrationState* Peter Xu
2026-01-28 15:22   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 18/24] migration: Cleanup error propagates in qemu_savevm_state_setup() Peter Xu
2026-01-28 15:23   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 19/24] migration: Refactor qemu_savevm_state_setup() Peter Xu
2026-01-28 19:35   ` Fabiano Rosas
2026-01-28 20:36     ` Peter Xu
2026-01-28 21:36       ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 20/24] migration: Introduce qemu_savevm_state_active() Peter Xu
2026-02-02 15:07   ` Fabiano Rosas [this message]
2026-01-27 18:52 ` [PATCH v2 21/24] migration/bg-snapshot: Cleanup error paths Peter Xu
2026-01-28 19:45   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 22/24] migration: Make qemu_savevm_state_non_iterable() take errp Peter Xu
2026-01-28 19:52   ` Fabiano Rosas
2026-01-27 18:52 ` [PATCH v2 23/24] migration: Simplify qemu_save_device_state() Peter Xu
2026-01-28 19:55   ` Fabiano Rosas
2026-02-02 14:28     ` Peter Xu
2026-01-27 18:52 ` [PATCH v2 24/24] migration/colo/xen: Use generic helpers in qemu_save_device_state() Peter Xu
2026-02-02 15:14   ` Fabiano Rosas
2026-01-30 18:22 ` [PATCH v2 00/24] migration: small cleanup series Lukas Straub

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=874inzrxpk.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=jmarcin@redhat.com \
    --cc=lukasstraub2@web.de \
    --cc=peterx@redhat.com \
    --cc=ppandit@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.