Message ID | 20230828151842.11303-4-avihaih@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | vfio/migration: Block VFIO migration with postcopy and background snapshot | expand |
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)
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)
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> --- hw/vfio/common.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)