vfio/common: Change vfio_devices_all_running_and_saving() logic to equivalent one
commit8b942af393a2d9f822aea4e5e0d241e668146bf2
authorAvihai Horon <avihaih@nvidia.com>
Thu, 16 Feb 2023 14:36:23 +0000 (16 16:36 +0200)
committerAlex Williamson <alex.williamson@redhat.com>
Thu, 16 Feb 2023 19:13:46 +0000 (16 12:13 -0700)
treec0361033c16d18bf865f07fdc4eea57fa72e4d74
parentb051a3f640e2efc95e9e23c5cb1bb5a4c07731e2
vfio/common: Change vfio_devices_all_running_and_saving() logic to equivalent one

vfio_devices_all_running_and_saving() is used to check if migration is
in pre-copy phase. This is done by checking if migration is in setup or
active states and if all VFIO devices are in pre-copy state, i.e.
_SAVING | _RUNNING.

In VFIO migration protocol v2 pre-copy support is made optional. Hence,
a matching v2 protocol pre-copy state can't be used here.

As preparation for adding v2 protocol, change
vfio_devices_all_running_and_saving() logic such that it doesn't use the
VFIO pre-copy state.

The new equivalent logic checks if migration is in active state and if
all VFIO devices are in running state [1]. No functional changes
intended.

[1] Note that checking if migration is in setup or active states and if
all VFIO devices are in running state doesn't guarantee that we are in
pre-copy phase, thus we check if migration is only in active state.

Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Link: https://lore.kernel.org/r/20230216143630.25610-5-avihaih@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
hw/vfio/common.c