qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 3/6] vfio/migration: Add vfio_migratable_devices_num()


From: Cédric Le Goater
Subject: Re: [PATCH 3/6] vfio/migration: Add vfio_migratable_devices_num()
Date: Tue, 29 Aug 2023 15:24:08 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 8/28/23 17:18, Avihai Horon wrote:
Add vfio_migratable_devices_num() function, which returns the number of
VFIO devices that are using VFIO migration, and use it in
vfio_multiple_devices_migration_is_supported().

This is done in preparation for next patches which will block VFIO
migration with postcopy migration or background snapshot, as they are
not compatible together.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>


Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.


---
  hw/vfio/common.c | 22 ++++++++++++++++++----
  1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 237101d038..57a76feab1 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -363,6 +363,23 @@ bool vfio_mig_active(void)
static Error *multiple_devices_migration_blocker; +static unsigned int vfio_migratable_devices_num(void)
+{
+    VFIOGroup *group;
+    VFIODevice *vbasedev;
+    unsigned int device_num = 0;
+
+    QLIST_FOREACH(group, &vfio_group_list, next) {
+        QLIST_FOREACH(vbasedev, &group->device_list, next) {
+            if (vbasedev->migration) {
+                device_num++;
+            }
+        }
+    }
+
+    return device_num;
+}
+
  /*
   * Multiple devices migration is allowed only if all devices support P2P
   * migration. Single device migration is allowed regardless of P2P migration
@@ -372,14 +389,11 @@ static bool 
vfio_multiple_devices_migration_is_supported(void)
  {
      VFIOGroup *group;
      VFIODevice *vbasedev;
-    unsigned int device_num = 0;
      bool all_support_p2p = true;
QLIST_FOREACH(group, &vfio_group_list, next) {
          QLIST_FOREACH(vbasedev, &group->device_list, next) {
              if (vbasedev->migration) {
-                device_num++;
-
                  if (!(vbasedev->migration->mig_flags & VFIO_MIGRATION_P2P)) {
                      all_support_p2p = false;
                  }
@@ -387,7 +401,7 @@ static bool 
vfio_multiple_devices_migration_is_supported(void)
          }
      }
- return all_support_p2p || device_num <= 1;
+    return all_support_p2p || vfio_migratable_devices_num() <= 1;
  }
int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Error **errp)




reply via email to

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