Skip to contentSkip to conversation

vfio: Open code vfio_migration_set_error()

PATCH In review Cédric Le Goater 2 participants 4 messages Mar 24, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio: Open code vfio_migration_set_error()

VFIO uses migration_file_set_error() in a couple of places where an 'Error **' parameter is not provided. In MemoryListener handlers :

vfio_listener_region_add
vfio_listener_log_global_stop
vfio_listener_log_sync

and in callback routines for IOMMU notifiers :

vfio_iommu_map_notify
vfio_iommu_map_dirty_notify

Hopefully, one day, we will be able to extend these callbacks with an 'Error **' parameter and avoid setting the global migration error. Until then, it seems sensible to clearly identify the use cases, which are limited, and open code vfio_migration_set_error(). One other benefit is an improved error reporting when migration is running.

While at it, slightly modify error reporting to only report errors when migration is not active and not always as is currently done.

---
 hw/vfio/common.c | 60 +++++++++++++++++++++++++++++-------------------
 1 file changed, 36 insertions(+), 24 deletions(-)
hw/vfio/common.c +36 -24
index 1a0d9290f88c9774a98f65087a36b86922b21a73..a591ce5b97ff41cdc8249e9eeafc8dc347d45fac 100644
@@ -149,13 +149,6 @@ bool vfio_viommu_preset(VFIODevice *vbasedev)
     return vbasedev->bcontainer->space->as != &address_space_memory;
 }
 
-static void vfio_set_migration_error(int ret)
-{
-    if (migration_is_running()) {
-        migration_file_set_error(ret, NULL);
-    }
-}
-
 bool vfio_device_state_is_running(VFIODevice *vbasedev)
 {
     VFIOMigration *migration = vbasedev->migration;
@@ -291,9 +284,14 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
                                 iova, iova + iotlb->addr_mask);
 
     if (iotlb->target_as != &address_space_memory) {
-        error_report("Wrong target AS \"%s\", only system memory is allowed",
-                     iotlb->target_as->name ? iotlb->target_as->name : "none");
-        vfio_set_migration_error(-EINVAL);
+        error_setg(&local_err,
+                   "Wrong target AS \"%s\", only system memory is allowed",
+                   iotlb->target_as->name ? iotlb->target_as->name : "none");
+        if (migration_is_running()) {
+            migration_file_set_error(-EINVAL, local_err);
+        } else {
+            error_report_err(local_err);
+        }
         return;
     }
 
@@ -326,11 +324,16 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
         ret = vfio_container_dma_unmap(bcontainer, iova,
                                        iotlb->addr_mask + 1, iotlb);
         if (ret) {
-            error_report("vfio_container_dma_unmap(%p, 0x%"HWADDR_PRIx", "
-                         "0x%"HWADDR_PRIx") = %d (%s)",
-                         bcontainer, iova,
-                         iotlb->addr_mask + 1, ret, strerror(-ret));
-            vfio_set_migration_error(ret);
+            error_setg(&local_err,
+                       "vfio_container_dma_unmap(%p, 0x%"HWADDR_PRIx", "
+                       "0x%"HWADDR_PRIx") = %d (%s)",
+                       bcontainer, iova,
+                       iotlb->addr_mask + 1, ret, strerror(-ret));
+            if (migration_is_running()) {
+                migration_file_set_error(ret, local_err);
+            } else {
+                error_report_err(local_err);
+            }
         }
     }
 out:
@@ -1112,8 +1115,11 @@ static void vfio_listener_log_global_stop(MemoryListener *listener)
     if (ret) {
         error_prepend(&local_err,
                       "vfio: Could not stop dirty page tracking - ");
-        error_report_err(local_err);
-        vfio_set_migration_error(ret);
+        if (migration_is_running()) {
+            migration_file_set_error(ret, local_err);
+        } else {
+            error_report_err(local_err);
+        }
     }
 }
 
@@ -1229,14 +1235,14 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
     trace_vfio_iommu_map_dirty_notify(iova, iova + iotlb->addr_mask);
 
     if (iotlb->target_as != &address_space_memory) {
-        error_report("Wrong target AS \"%s\", only system memory is allowed",
-                     iotlb->target_as->name ? iotlb->target_as->name : "none");
+        error_setg(&local_err,
+                   "Wrong target AS \"%s\", only system memory is allowed",
+                   iotlb->target_as->name ? iotlb->target_as->name : "none");
         goto out;
     }
 
     rcu_read_lock();
     if (!vfio_get_xlat_addr(iotlb, NULL, &translated_addr, NULL, &local_err)) {
-        error_report_err(local_err);
         goto out_unlock;
     }
 
@@ -1247,7 +1253,6 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
                       "vfio_iommu_map_dirty_notify(%p, 0x%"HWADDR_PRIx", "
                       "0x%"HWADDR_PRIx") failed - ", bcontainer, iova,
                       iotlb->addr_mask + 1);
-        error_report_err(local_err);
     }
 
 out_unlock:
@@ -1255,7 +1260,11 @@ out_unlock:
 
 out:
     if (ret) {
-        vfio_set_migration_error(ret);
+        if (migration_is_running()) {
+            migration_file_set_error(ret, local_err);
+        } else {
+            error_report_err(local_err);
+        }
     }
 }
 
@@ -1388,8 +1397,11 @@ static void vfio_listener_log_sync(MemoryListener *listener,
     if (vfio_log_sync_needed(bcontainer)) {
         ret = vfio_sync_dirty_bitmap(bcontainer, section, &local_err);
         if (ret) {
-            error_report_err(local_err);
-            vfio_set_migration_error(ret);
+            if (migration_is_running()) {
+                migration_file_set_error(ret, local_err);
+            } else {
+                error_report_err(local_err);
+            }
         }
     }
 }
Signature · 1 line
2.49.0
#1 lore raw
Quoted 35 lines · Cédric Le Goater

External email: Use caution opening links or attachments

VFIO uses migration_file_set_error() in a couple of places where an 'Error **' parameter is not provided. In MemoryListener handlers :

vfio_listener_region_add
vfio_listener_log_global_stop
vfio_listener_log_sync

and in callback routines for IOMMU notifiers :

vfio_iommu_map_notify
vfio_iommu_map_dirty_notify

Hopefully, one day, we will be able to extend these callbacks with an 'Error **' parameter and avoid setting the global migration error. Until then, it seems sensible to clearly identify the use cases, which are limited, and open code vfio_migration_set_error(). One other benefit is an improved error reporting when migration is running.

While at it, slightly modify error reporting to only report errors when migration is not active and not always as is currently done.

---
  hw/vfio/common.c | 60 +++++++++++++++++++++++++++++-------------------
  1 file changed, 36 insertions(+), 24 deletions(-)
hw/vfio/common.c +0 -0
index 1a0d9290f88c9774a98f65087a36b86922b21a73..a591ce5b97ff41cdc8249e9eeafc8dc347d45fac 100644

hw/vfio/common.c bool vfio_viommu_preset(VFIODevice *vbasedev) · line 157

Quoted 9 lines
hw/vfio/common.c +0 -6
@@ -149,13 +149,6 @@ bool vfio_viommu_preset(VFIODevice *vbasedev)
      return vbasedev->bcontainer->space->as != &address_space_memory;
  }
 
-static void vfio_set_migration_error(int ret)
-{
-    if (migration_is_running()) {
-        migration_file_set_error(ret, NULL);
-    }
-}

Wouldn't it be better to extend vfio_set_migration_error() to take also Error* instead of duplicating code? We can rename it to vfio_set_error() if it's not solely related to vfio migration anymore.

Thanks.

Quoted 115 lines
hw/vfio/common.c +36 -19
-
  bool vfio_device_state_is_running(VFIODevice *vbasedev)
  {
      VFIOMigration *migration = vbasedev->migration;
@@ -291,9 +284,14 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
                                  iova, iova + iotlb->addr_mask);
 
      if (iotlb->target_as != &address_space_memory) {
-        error_report("Wrong target AS \"%s\", only system memory is allowed",
-                     iotlb->target_as->name ? iotlb->target_as->name : "none");
-        vfio_set_migration_error(-EINVAL);
+        error_setg(&local_err,
+                   "Wrong target AS \"%s\", only system memory is allowed",
+                   iotlb->target_as->name ? iotlb->target_as->name : "none");
+        if (migration_is_running()) {
+            migration_file_set_error(-EINVAL, local_err);
+        } else {
+            error_report_err(local_err);
+        }
          return;
      }
 
@@ -326,11 +324,16 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
          ret = vfio_container_dma_unmap(bcontainer, iova,
                                         iotlb->addr_mask + 1, iotlb);
          if (ret) {
-            error_report("vfio_container_dma_unmap(%p, 0x%"HWADDR_PRIx", "
-                         "0x%"HWADDR_PRIx") = %d (%s)",
-                         bcontainer, iova,
-                         iotlb->addr_mask + 1, ret, strerror(-ret));
-            vfio_set_migration_error(ret);
+            error_setg(&local_err,
+                       "vfio_container_dma_unmap(%p, 0x%"HWADDR_PRIx", "
+                       "0x%"HWADDR_PRIx") = %d (%s)",
+                       bcontainer, iova,
+                       iotlb->addr_mask + 1, ret, strerror(-ret));
+            if (migration_is_running()) {
+                migration_file_set_error(ret, local_err);
+            } else {
+                error_report_err(local_err);
+            }
          }
      }
  out:
@@ -1112,8 +1115,11 @@ static void vfio_listener_log_global_stop(MemoryListener *listener)
      if (ret) {
          error_prepend(&local_err,
                        "vfio: Could not stop dirty page tracking - ");
-        error_report_err(local_err);
-        vfio_set_migration_error(ret);
+        if (migration_is_running()) {
+            migration_file_set_error(ret, local_err);
+        } else {
+            error_report_err(local_err);
+        }
      }
  }
 
@@ -1229,14 +1235,14 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
      trace_vfio_iommu_map_dirty_notify(iova, iova + iotlb->addr_mask);
 
      if (iotlb->target_as != &address_space_memory) {
-        error_report("Wrong target AS \"%s\", only system memory is allowed",
-                     iotlb->target_as->name ? iotlb->target_as->name : "none");
+        error_setg(&local_err,
+                   "Wrong target AS \"%s\", only system memory is allowed",
+                   iotlb->target_as->name ? iotlb->target_as->name : "none");
          goto out;
      }
 
      rcu_read_lock();
      if (!vfio_get_xlat_addr(iotlb, NULL, &translated_addr, NULL, &local_err)) {
-        error_report_err(local_err);
          goto out_unlock;
      }
 
@@ -1247,7 +1253,6 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
                        "vfio_iommu_map_dirty_notify(%p, 0x%"HWADDR_PRIx", "
                        "0x%"HWADDR_PRIx") failed - ", bcontainer, iova,
                        iotlb->addr_mask + 1);
-        error_report_err(local_err);
      }
 
  out_unlock:
@@ -1255,7 +1260,11 @@ out_unlock:
 
  out:
      if (ret) {
-        vfio_set_migration_error(ret);
+        if (migration_is_running()) {
+            migration_file_set_error(ret, local_err);
+        } else {
+            error_report_err(local_err);
+        }
      }
  }
 
@@ -1388,8 +1397,11 @@ static void vfio_listener_log_sync(MemoryListener *listener,
      if (vfio_log_sync_needed(bcontainer)) {
          ret = vfio_sync_dirty_bitmap(bcontainer, section, &local_err);
          if (ret) {
-            error_report_err(local_err);
-            vfio_set_migration_error(ret);
+            if (migration_is_running()) {
+                migration_file_set_error(ret, local_err);
+            } else {
+                error_report_err(local_err);
+            }
          }
      }
  }
--

2.49.0

#2 lore raw
Quoted 40 lines · Avihai Horon
Quoted 38 lines · Cédric Le Goater

External email: Use caution opening links or attachments

VFIO uses migration_file_set_error() in a couple of places where an 'Error **' parameter is not provided. In MemoryListener handlers :

   vfio_listener_region_add
   vfio_listener_log_global_stop
   vfio_listener_log_sync

and in callback routines for IOMMU notifiers :

   vfio_iommu_map_notify
   vfio_iommu_map_dirty_notify

Hopefully, one day, we will be able to extend these callbacks with an 'Error **' parameter and avoid setting the global migration error. Until then, it seems sensible to clearly identify the use cases, which are limited, and open code vfio_migration_set_error(). One other benefit is an improved error reporting when migration is running.

While at it, slightly modify error reporting to only report errors when migration is not active and not always as is currently done.

---
  hw/vfio/common.c | 60 +++++++++++++++++++++++++++++-------------------

  1 file changed, 36 insertions(+), 24 deletions(-)
hw/vfio/common.c +0 -0
index 1a0d9290f88c9774a98f65087a36b86922b21a73..a591ce5b97ff41cdc8249e9eeafc8dc347d45fac 100644
@@ -149,13 +149,6 @@ bool vfio_viommu_preset(VFIODevice *vbasedev)
       return vbasedev->bcontainer->space->as != &address_space_memory;
   }
 
Quoted 9 lines

hw/vfio/common.c bool vfio_viommu_preset(VFIODevice *vbasedev) · line 157

Quoted 6 lines
hw/vfio/common.c +0 -6
-static void vfio_set_migration_error(int ret)
-{
-    if (migration_is_running()) {
-        migration_file_set_error(ret, NULL);
-    }
-}

Wouldn't it be better to extend vfio_set_migration_error() to take also Error* instead of duplicating code? We can rename it to vfio_set_error() if it's not solely related to vfio migration anymore.

IMO, the vfio_set_migration_error() wrapper shadows the use of the migration routines and their context. I prefer to be explicit about it, open the code and work on removal. It is possible to add an 'Error **' parameter to log_global_stop handlers and to the IOMMU notifiers. It just takes time.

Thanks,

C.

Quoted 119 lines

Thanks.

Quoted 115 lines
hw/vfio/common.c +18 -9
-
   bool vfio_device_state_is_running(VFIODevice *vbasedev)
   {
       VFIOMigration *migration = vbasedev->migration;
@@ -291,9 +284,14 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
                                   iova, iova + iotlb->addr_mask);
 
       if (iotlb->target_as != &address_space_memory) {
-        error_report("Wrong target AS \"%s\", only system memory is allowed",
-                     iotlb->target_as->name ? iotlb->target_as->name : "none");
-        vfio_set_migration_error(-EINVAL);
+        error_setg(&local_err,
+                   "Wrong target AS \"%s\", only system memory is allowed",
+                   iotlb->target_as->name ? iotlb->target_as->name : "none");
+        if (migration_is_running()) {
+            migration_file_set_error(-EINVAL, local_err);
+        } else {
+            error_report_err(local_err);
+        }
           return;
       }
 
@@ -326,11 +324,16 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
           ret = vfio_container_dma_unmap(bcontainer, iova,
                                          iotlb->addr_mask + 1, iotlb);
           if (ret) {
-            error_report("vfio_container_dma_unmap(%p, 0x%"HWADDR_PRIx", "
-                         "0x%"HWADDR_PRIx") = %d (%s)",
-                         bcontainer, iova,
-                         iotlb->addr_mask + 1, ret, strerror(-ret));
-            vfio_set_migration_error(ret);
+            error_setg(&local_err,
+                       "vfio_container_dma_unmap(%p, 0x%"HWADDR_PRIx", "
+                       "0x%"HWADDR_PRIx") = %d (%s)",
+                       bcontainer, iova,
+                       iotlb->addr_mask + 1, ret, strerror(-ret));
+            if (migration_is_running()) {
+                migration_file_set_error(ret, local_err);
+            } else {
+                error_report_err(local_err);
+            }
           }
       }

  out:

hw/vfio/common.c +8 -5
@@ -1112,8 +1115,11 @@ static void vfio_listener_log_global_stop(MemoryListener *listener)
       if (ret) {
           error_prepend(&local_err,
                         "vfio: Could not stop dirty page tracking - ");
-        error_report_err(local_err);
-        vfio_set_migration_error(ret);
+        if (migration_is_running()) {
+            migration_file_set_error(ret, local_err);
+        } else {
+            error_report_err(local_err);
+        }
       }
   }
 
@@ -1229,14 +1235,14 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
       trace_vfio_iommu_map_dirty_notify(iova, iova + iotlb->addr_mask);
 
       if (iotlb->target_as != &address_space_memory) {
-        error_report("Wrong target AS \"%s\", only system memory is allowed",
-                     iotlb->target_as->name ? iotlb->target_as->name : "none");
+        error_setg(&local_err,
+                   "Wrong target AS \"%s\", only system memory is allowed",
+                   iotlb->target_as->name ? iotlb->target_as->name : "none");
           goto out;
       }
 
       rcu_read_lock();
       if (!vfio_get_xlat_addr(iotlb, NULL, &translated_addr, NULL, &local_err)) {
-        error_report_err(local_err);
           goto out_unlock;
       }
 
@@ -1247,7 +1253,6 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)

                        "vfio_iommu_map_dirty_notify(%p, 0x%"HWADDR_PRIx", " "0x%"HWADDR_PRIx") failed - ", bcontainer, iova, iotlb->addr_mask + 1);
-        error_report_err(local_err);
      }

  out_unlock:

hw/vfio/common.c +0 -0
@@ -1255,7 +1260,11 @@ out_unlock:
 

  out:
      if (ret) {
-        vfio_set_migration_error(ret);
+        if (migration_is_running()) {
+            migration_file_set_error(ret, local_err); +        } else {
+            error_report_err(local_err);
+        }
      }
  }

hw/vfio/common.c +5 -2
@@ -1388,8 +1397,11 @@ static void vfio_listener_log_sync(MemoryListener *listener,
       if (vfio_log_sync_needed(bcontainer)) {
           ret = vfio_sync_dirty_bitmap(bcontainer, section, &local_err);
           if (ret) {
-            error_report_err(local_err);
-            vfio_set_migration_error(ret);
+            if (migration_is_running()) {
+                migration_file_set_error(ret, local_err);
+            } else {
+                error_report_err(local_err);
+            }
           }
       }
   }
Signature · 1 line
2.49.0
Reviewed-by
#3 lore raw
Quoted 13 lines · Cédric Le Goater

External email: Use caution opening links or attachments

Quoted 9 lines · Avihai Horon
Quoted 7 lines · Cédric Le Goater

External email: Use caution opening links or attachments

VFIO uses migration_file_set_error() in a couple of places where an 'Error **' parameter is not provided. In MemoryListener handlers :

   vfio_listener_region_add

Nit: migration_file_set_error() is not used in vfio_listener_region_add.

Quoted 42 lines
Quoted 32 lines
Quoted 32 lines

   vfio_listener_log_global_stop
   vfio_listener_log_sync

and in callback routines for IOMMU notifiers :

   vfio_iommu_map_notify
   vfio_iommu_map_dirty_notify

Hopefully, one day, we will be able to extend these callbacks with an 'Error **' parameter and avoid setting the global migration error. Until then, it seems sensible to clearly identify the use cases, which are limited, and open code vfio_migration_set_error(). One other benefit is an improved error reporting when migration is running.

While at it, slightly modify error reporting to only report errors when migration is not active and not always as is currently done.

---
  hw/vfio/common.c | 60
+++++++++++++++++++++++++++++-------------------

  1 file changed, 36 insertions(+), 24 deletions(-)
hw/vfio/common.c +0 -0
index 1a0d9290f88c9774a98f65087a36b86922b21a73..a591ce5b97ff41cdc8249e9eeafc8dc347d45fac 100644
@@ -149,13 +149,6 @@ bool vfio_viommu_preset(VFIODevice *vbasedev)
       return vbasedev->bcontainer->space->as != &address_space_memory;
   }
 
Quoted 9 lines

hw/vfio/common.c bool vfio_viommu_preset(VFIODevice *vbasedev) · line 157

Quoted 6 lines
hw/vfio/common.c +0 -6
-static void vfio_set_migration_error(int ret)
-{
-    if (migration_is_running()) {
-        migration_file_set_error(ret, NULL);
-    }
-}

Wouldn't it be better to extend vfio_set_migration_error() to take also Error* instead of duplicating code? We can rename it to vfio_set_error() if it's not solely related to vfio migration anymore.

Quoted 5 lines

IMO, the vfio_set_migration_error() wrapper shadows the use of the migration routines and their context. I prefer to be explicit about it, open the code and work on removal. It is possible to add an 'Error **' parameter to log_global_stop handlers and to the IOMMU notifiers. It just takes time.

I see, fair enough.

Quoted 141 lines

Thanks,

C.

Quoted 135 lines

Thanks.

Quoted 131 lines
hw/vfio/common.c +2 -4
-
   bool vfio_device_state_is_running(VFIODevice *vbasedev)
   {
       VFIOMigration *migration = vbasedev->migration;
@@ -291,9 +284,14 @@ static void vfio_iommu_map_notify(IOMMUNotifier 
 *n, IOMMUTLBEntry *iotlb)
                                   iova, iova + iotlb->addr_mask);
 
       if (iotlb->target_as != &address_space_memory) {
-        error_report("Wrong target AS \"%s\", only system memory is 
 allowed",
-                     iotlb->target_as->name ? 
 iotlb->target_as->name : "none");
-        vfio_set_migration_error(-EINVAL);
+        error_setg(&local_err,
+                   "Wrong target AS \"%s\", only system memory is 

allowed",
+                   iotlb->target_as->name ? iotlb->target_as->name : "none");
+        if (migration_is_running()) {
+            migration_file_set_error(-EINVAL, local_err); +        } else {
+            error_report_err(local_err);
+        }
          return;
      }

hw/vfio/common.c +0 -1
@@ -326,11 +324,16 @@ static void 
 vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
           ret = vfio_container_dma_unmap(bcontainer, iova,
                                          iotlb->addr_mask + 1, iotlb);
           if (ret) {
-            error_report("vfio_container_dma_unmap(%p, 

0x%"HWADDR_PRIx", "
-                         "0x%"HWADDR_PRIx") = %d (%s)",
-                         bcontainer, iova,
-                         iotlb->addr_mask + 1, ret, strerror(-ret)); -            vfio_set_migration_error(ret);
+            error_setg(&local_err,
+                       "vfio_container_dma_unmap(%p, 0x%"HWADDR_PRIx", "
+                       "0x%"HWADDR_PRIx") = %d (%s)",
+                       bcontainer, iova,
+                       iotlb->addr_mask + 1, ret, strerror(-ret)); +            if (migration_is_running()) {
+                migration_file_set_error(ret, local_err); +            } else {
+                error_report_err(local_err);
+            }
          }
      }
  out:

hw/vfio/common.c +8 -4
@@ -1112,8 +1115,11 @@ static void 
 vfio_listener_log_global_stop(MemoryListener *listener)
       if (ret) {
           error_prepend(&local_err,
                         "vfio: Could not stop dirty page tracking - ");
-        error_report_err(local_err);
-        vfio_set_migration_error(ret);
+        if (migration_is_running()) {
+            migration_file_set_error(ret, local_err);
+        } else {
+            error_report_err(local_err);
+        }
       }
   }
@@ -1229,14 +1235,14 @@ static void 
 vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
       trace_vfio_iommu_map_dirty_notify(iova, iova + iotlb->addr_mask);
 
       if (iotlb->target_as != &address_space_memory) {
-        error_report("Wrong target AS \"%s\", only system memory is 
 allowed",
-                     iotlb->target_as->name ? 
 iotlb->target_as->name : "none");
+        error_setg(&local_err,
+                   "Wrong target AS \"%s\", only system memory is 
 allowed",
+                   iotlb->target_as->name ? iotlb->target_as->name 
 : "none");
           goto out;
       }
 

      rcu_read_lock();
      if (!vfio_get_xlat_addr(iotlb, NULL, &translated_addr, NULL, &local_err)) { -        error_report_err(local_err);
          goto out_unlock;
      }

hw/vfio/common.c +0 -0
@@ -1247,7 +1253,6 @@ static void 
 vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)

                        "vfio_iommu_map_dirty_notify(%p, 0x%"HWADDR_PRIx", " "0x%"HWADDR_PRIx") failed - ", bcontainer, iova, iotlb->addr_mask + 1);
-        error_report_err(local_err);
      }

  out_unlock:

hw/vfio/common.c +0 -0
@@ -1255,7 +1260,11 @@ out_unlock:
 

  out:
      if (ret) {
-        vfio_set_migration_error(ret);
+        if (migration_is_running()) {
+            migration_file_set_error(ret, local_err); +        } else {
+            error_report_err(local_err);
+        }
      }
  }

hw/vfio/common.c +5 -2
@@ -1388,8 +1397,11 @@ static void 
 vfio_listener_log_sync(MemoryListener *listener,
       if (vfio_log_sync_needed(bcontainer)) {
           ret = vfio_sync_dirty_bitmap(bcontainer, section, &local_err);
           if (ret) {
-            error_report_err(local_err);
-            vfio_set_migration_error(ret);
+            if (migration_is_running()) {
+                migration_file_set_error(ret, local_err);
+            } else {
+                error_report_err(local_err);
+            }
           }
       }

  }

Signature · 1 line
2.49.0