[PATCH 1/5] qemuMigrationDstFinishFresh: Avoid multi-line ternary operator in function call

Michal Prívozník mprivozn at redhat.com
Mon Jul 25 13:51:28 UTC 2022


On 7/25/22 14:45, Peter Krempa wrote:
> Rewrite the code using a temporary variable.
> 
> Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> ---
>  src/qemu/qemu_migration.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
> index 20dc91f1ce..800f66349d 100644
> --- a/src/qemu/qemu_migration.c
> +++ b/src/qemu/qemu_migration.c
> @@ -6601,9 +6601,14 @@ qemuMigrationDstFinishFresh(virQEMUDriver *driver,
>          *inPostCopy = true;
> 
>      if (!(flags & VIR_MIGRATE_PAUSED)) {
> -        if (qemuProcessStartCPUs(driver, vm,
> -                                 *inPostCopy ? VIR_DOMAIN_RUNNING_POSTCOPY
> -                                             : VIR_DOMAIN_RUNNING_MIGRATED,
> +        virDomainRunningReason runningReason;
> +
> +        if (inPostCopy)

This needs to dereference the variable, just like the original did.

And what is your opinion on initializing the newly introduced variable
to _MIGRATED and then having this if() to overwrite it to _POSTCOPY?

virDomainRunningReason runningReason = VIR_DOMAIN_RUNNING_MIGRATED;

if (*inPostCopy)
  runningReason = VIR_DOMAIN_RUNNING_POSTCOPY;


Michal



More information about the libvir-list mailing list