[libvirt PATCH 1/2] qemu: Support enabling migration caps unless a flag is used

Michal Prívozník mprivozn at redhat.com
Wed Dec 15 07:53:45 UTC 2021


On 12/13/21 15:29, Jiri Denemark wrote:
> So far we were enabling specific migration capabilities when a
> corresponding API flag is set. We need to generalize our code to be able
> to enable some migration capabilities unless a particular API flag is
> used.
> 
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
>  src/qemu/qemu_migration_params.c | 33 +++++++++++++++++++++++---------
>  1 file changed, 24 insertions(+), 9 deletions(-)
> 
> diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
> index 837ee6d635..dfe0253487 100644
> --- a/src/qemu/qemu_migration_params.c
> +++ b/src/qemu/qemu_migration_params.c
> @@ -47,6 +47,11 @@ typedef enum {
>      QEMU_MIGRATION_PARAM_TYPE_STRING,
>  } qemuMigrationParamType;
>  
> +typedef enum {
> +    QEMU_MIGRATION_FLAG_REQUIRED,
> +    QEMU_MIGRATION_FLAG_FORBIDDEN,
> +} qemuMigrationFlagMatch;
> +
>  typedef struct _qemuMigrationParamValue qemuMigrationParamValue;
>  struct _qemuMigrationParamValue {
>      bool set;
> @@ -119,6 +124,7 @@ struct _qemuMigrationParamsAlwaysOnItem {
>  
>  typedef struct _qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMapItem;
>  struct _qemuMigrationParamsFlagMapItem {
> +    qemuMigrationFlagMatch match;
>      virDomainMigrateFlags flag;
>      qemuMigrationCapability cap;
>      int party; /* bit-wise OR of qemuMigrationParty */
> @@ -146,19 +152,23 @@ static const qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOn[] = {
>  
>  /* Translation from virDomainMigrateFlags to qemuMigrationCapability. */
>  static const qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMap[] = {
> -    {VIR_MIGRATE_RDMA_PIN_ALL,
> +    {QEMU_MIGRATION_FLAG_REQUIRED,
> +     VIR_MIGRATE_RDMA_PIN_ALL,
>       QEMU_MIGRATION_CAP_RDMA_PIN_ALL,
>       QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
>  
> -    {VIR_MIGRATE_AUTO_CONVERGE,
> +    {QEMU_MIGRATION_FLAG_REQUIRED,
> +     VIR_MIGRATE_AUTO_CONVERGE,
>       QEMU_MIGRATION_CAP_AUTO_CONVERGE,
>       QEMU_MIGRATION_SOURCE},
>  
> -    {VIR_MIGRATE_POSTCOPY,
> +    {QEMU_MIGRATION_FLAG_REQUIRED,
> +     VIR_MIGRATE_POSTCOPY,
>       QEMU_MIGRATION_CAP_POSTCOPY,
>       QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
>  
> -    {VIR_MIGRATE_PARALLEL,
> +    {QEMU_MIGRATION_FLAG_REQUIRED,
> +     VIR_MIGRATE_PARALLEL,
>       QEMU_MIGRATION_CAP_MULTIFD,
>       QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
>  };
> @@ -553,13 +563,18 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
>          return NULL;
>  
>      for (i = 0; i < G_N_ELEMENTS(qemuMigrationParamsFlagMap); i++) {
> -        qemuMigrationCapability cap = qemuMigrationParamsFlagMap[i].cap;
> +        const qemuMigrationParamsFlagMapItem *item = &qemuMigrationParamsFlagMap[i];
> +        int match;

If you initialize this variable, then ..

> +
> +        if (item->match == QEMU_MIGRATION_FLAG_REQUIRED)
> +            match = item->flag;
> +        else
> +            match = 0;

.. this else branch can be dropped.
>  
> -        if (qemuMigrationParamsFlagMap[i].party & party &&
> -            flags & qemuMigrationParamsFlagMap[i].flag) {
> +        if (item->party & party && (flags & item->flag) == match) {
>              VIR_DEBUG("Enabling migration capability '%s'",
> -                      qemuMigrationCapabilityTypeToString(cap));
> -            ignore_value(virBitmapSetBit(migParams->caps, cap));
> +                      qemuMigrationCapabilityTypeToString(item->cap));
> +            ignore_value(virBitmapSetBit(migParams->caps, item->cap));
>          }
>      }
>  

Michal




More information about the libvir-list mailing list