qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 2/9] vfio: Fix compilation errors caused by VFIO migration v1


From: Alex Williamson
Subject: Re: [PATCH 2/9] vfio: Fix compilation errors caused by VFIO migration v1 deprecation
Date: Thu, 12 May 2022 11:57:10 -0600

On Thu, 12 May 2022 18:43:13 +0300
Avihai Horon <avihaih@nvidia.com> wrote:

> VFIO migration protocol v1 was deprecated and as part of it some of the
> uAPI definitions were renamed. This caused compilation errors.
> Fix them.
> 
> Signed-off-by: Avihai Horon <avihaih@nvidia.com>
> ---
>  hw/vfio/common.c    |  6 +++---
>  hw/vfio/migration.c | 29 ++++++++++++++++-------------
>  2 files changed, 19 insertions(+), 16 deletions(-)
> 
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 159f910421..29982c7af8 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -355,7 +355,7 @@ static bool vfio_devices_all_dirty_tracking(VFIOContainer 
> *container)
>              }
>  
>              if ((vbasedev->pre_copy_dirty_page_tracking == ON_OFF_AUTO_OFF)
> -                && (migration->device_state & VFIO_DEVICE_STATE_RUNNING)) {
> +                && (migration->device_state & VFIO_DEVICE_STATE_V1_RUNNING)) 
> {
>                  return false;
>              }
>          }
> @@ -381,8 +381,8 @@ static bool 
> vfio_devices_all_running_and_saving(VFIOContainer *container)
>                  return false;
>              }
>  
> -            if ((migration->device_state & VFIO_DEVICE_STATE_SAVING) &&
> -                (migration->device_state & VFIO_DEVICE_STATE_RUNNING)) {
> +            if ((migration->device_state & VFIO_DEVICE_STATE_V1_SAVING) &&
> +                (migration->device_state & VFIO_DEVICE_STATE_V1_RUNNING)) {
>                  continue;
>              } else {
>                  return false;
> diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
> index ff6b45de6b..835608cd23 100644
> --- a/hw/vfio/migration.c
> +++ b/hw/vfio/migration.c
> @@ -432,7 +432,7 @@ static int vfio_save_setup(QEMUFile *f, void *opaque)
>      }
>  
>      ret = vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_MASK,
> -                                   VFIO_DEVICE_STATE_SAVING);
> +                                   VFIO_DEVICE_STATE_V1_SAVING);
>      if (ret) {
>          error_report("%s: Failed to set state SAVING", vbasedev->name);
>          return ret;
> @@ -531,8 +531,8 @@ static int vfio_save_complete_precopy(QEMUFile *f, void 
> *opaque)
>      uint64_t data_size;
>      int ret;
>  
> -    ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_RUNNING,
> -                                   VFIO_DEVICE_STATE_SAVING);
> +    ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_RUNNING,
> +                                   VFIO_DEVICE_STATE_V1_SAVING);
>      if (ret) {
>          error_report("%s: Failed to set state STOP and SAVING",
>                       vbasedev->name);
> @@ -569,7 +569,7 @@ static int vfio_save_complete_precopy(QEMUFile *f, void 
> *opaque)
>          return ret;
>      }
>  
> -    ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_SAVING, 0);
> +    ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_SAVING, 
> 0);
>      if (ret) {
>          error_report("%s: Failed to set state STOPPED", vbasedev->name);
>          return ret;
> @@ -609,7 +609,7 @@ static int vfio_load_setup(QEMUFile *f, void *opaque)
>      }
>  
>      ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_MASK,
> -                                   VFIO_DEVICE_STATE_RESUMING);
> +                                   VFIO_DEVICE_STATE_V1_RESUMING);
>      if (ret) {
>          error_report("%s: Failed to set state RESUMING", vbasedev->name);
>          if (migration->region.mmaps) {
> @@ -717,20 +717,20 @@ static void vfio_vmstate_change(void *opaque, bool 
> running, RunState state)
>           * In both the above cases, set _RUNNING bit.
>           */
>          mask = ~VFIO_DEVICE_STATE_MASK;
> -        value = VFIO_DEVICE_STATE_RUNNING;
> +        value = VFIO_DEVICE_STATE_V1_RUNNING;
>      } else {
>          /*
>           * Here device state could be either _RUNNING or _SAVING|_RUNNING. 
> Reset
>           * _RUNNING bit
>           */
> -        mask = ~VFIO_DEVICE_STATE_RUNNING;
> +        mask = ~VFIO_DEVICE_STATE_V1_RUNNING;
>  
>          /*
>           * When VM state transition to stop for savevm command, device should
>           * start saving data.
>           */
>          if (state == RUN_STATE_SAVE_VM) {
> -            value = VFIO_DEVICE_STATE_SAVING;
> +            value = VFIO_DEVICE_STATE_V1_SAVING;
>          } else {
>              value = 0;
>          }
> @@ -767,9 +767,10 @@ static void vfio_migration_state_notifier(Notifier 
> *notifier, void *data)
>      case MIGRATION_STATUS_CANCELLED:
>      case MIGRATION_STATUS_FAILED:
>          bytes_transferred = 0;
> -        ret = vfio_migration_set_state(vbasedev,
> -                      ~(VFIO_DEVICE_STATE_SAVING | 
> VFIO_DEVICE_STATE_RESUMING),
> -                      VFIO_DEVICE_STATE_RUNNING);
> +        ret = vfio_migration_set_state(
> +            vbasedev,
> +            ~(VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING),
> +            VFIO_DEVICE_STATE_V1_RUNNING);

Yikes!  Please follow the line wrapping used elsewhere.  There's no need
to put the first arg on a new line and subsequent wrapped lines should
be indented to match the previous line, or at least to avoid wrapping
itself.  Here we can use something like:

        ret = vfio_migration_set_state(vbasedev,
                                       ~(VFIO_DEVICE_STATE_V1_SAVING |
                                         VFIO_DEVICE_STATE_V1_RESUMING),
                                       VFIO_DEVICE_STATE_V1_RUNNING);

Thanks,
Alex

>          if (ret) {
>              error_report("%s: Failed to set state RUNNING", vbasedev->name);
>          }
> @@ -864,8 +865,10 @@ int vfio_migration_probe(VFIODevice *vbasedev, Error 
> **errp)
>          goto add_blocker;
>      }
>  
> -    ret = vfio_get_dev_region_info(vbasedev, VFIO_REGION_TYPE_MIGRATION,
> -                                   VFIO_REGION_SUBTYPE_MIGRATION, &info);
> +    ret = vfio_get_dev_region_info(vbasedev,
> +                                   VFIO_REGION_TYPE_MIGRATION_DEPRECATED,
> +                                   VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATED,
> +                                   &info);
>      if (ret) {
>          goto add_blocker;
>      }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]