Re: [libvirt PATCH 54/80] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Begin phase

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 10, 2022 at 05:21:15PM +0200, Jiri Denemark wrote:
> Mostly we just need to check whether the domain is in a failed post-copy
> migration that can be resumed.
> 
> Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
> ---
>  src/qemu/qemu_migration.c | 143 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 143 insertions(+)
> 
> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
> index c111dd8686..99b1d4b88b 100644
> --- a/src/qemu/qemu_migration.c
> +++ b/src/qemu/qemu_migration.c
> @@ -2717,6 +2717,143 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver,
>                                      flags);
>  }
>  
> +
> +static bool
> +qemuMigrationAnyCanResume(virDomainObj *vm,
> +                          virDomainAsyncJob job,
> +                          unsigned long flags,
> +                          qemuMigrationJobPhase expectedPhase)
> +{
> +    qemuDomainObjPrivate *priv = vm->privateData;
> +
> +    VIR_DEBUG("vm=%p, job=%s, flags=0x%lx, expectedPhase=%s",
> +              vm, virDomainAsyncJobTypeToString(job), flags,
> +              qemuDomainAsyncJobPhaseToString(VIR_ASYNC_JOB_MIGRATION_OUT,
> +                                              expectedPhase));
> +
> +    if (!(flags & VIR_MIGRATE_POSTCOPY)) {
> +        virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
> +                       _("resuming failed post-copy migration requires "
> +                         "post-copy to be enabled"));
> +        return false;
> +    }
> +
> +    /* This should never happen since POSTCOPY_RESUME is newer than
> +     * CHANGE_PROTECTION, but let's check it anyway in case we're talking to
> +     * a weired client.
> +     */
> +    if (job == VIR_ASYNC_JOB_MIGRATION_OUT &&
> +        expectedPhase < QEMU_MIGRATION_PHASE_PERFORM_RESUME &&
> +        !(flags & VIR_MIGRATE_CHANGE_PROTECTION)) {
> +        virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
> +                       _("resuming failed post-copy migration requires "
> +                         "change protection"));
> +        return NULL;

s/return NULL/return false/

> +    }
> +
> +    if (!qemuMigrationJobIsActive(vm, job))
> +        return false;
> +
> +    if (priv->job.asyncOwner != 0 &&
> +        priv->job.asyncOwner != virThreadSelfID()) {
> +        virReportError(VIR_ERR_OPERATION_INVALID,
> +                       _("migration of domain %s is being actively monitored "
> +                         "by another thread"),
> +                       vm->def->name);
> +        return false;
> +    }
> +
> +    if (!virDomainObjIsPostcopy(vm, priv->job.current->operation)) {
> +        virReportError(VIR_ERR_OPERATION_INVALID,
> +                       _("migration of domain %s is not in post-copy phase"),
> +                       vm->def->name);
> +        return false;
> +    }
> +
> +    if (priv->job.phase < QEMU_MIGRATION_PHASE_POSTCOPY_FAILED &&
> +        !virDomainObjIsFailedPostcopy(vm)) {
> +        virReportError(VIR_ERR_OPERATION_INVALID,
> +                       _("post-copy migration of domain %s has not failed"),
> +                       vm->def->name);
> +        return false;
> +    }
> +
> +    if (priv->job.phase > expectedPhase) {
> +        virReportError(VIR_ERR_OPERATION_INVALID,
> +                       _("resuming failed post-copy migration of domain %s "
> +                         "already in progress"),
> +                       vm->def->name);
> +        return false;
> +    }
> +
> +    return true;
> +}

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux