[PATCH] hw/vfio: cpr-iommufd: Fix wrong usage of migrate_add_blocker_modes

Jim Shu posted 1 patch 2 weeks, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260121063418.2001326-1-jim.shu@sifive.com
Maintainers: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Mark Kanda <mark.kanda@oracle.com>, Ben Chaney <bchaney@akamai.com>, Alex Williamson <alex@shazbot.org>, "Cédric Le Goater" <clg@redhat.com>
hw/vfio/cpr-iommufd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] hw/vfio: cpr-iommufd: Fix wrong usage of migrate_add_blocker_modes
Posted by Jim Shu 2 weeks, 4 days ago
The return value of API is 0 for success and negative error code for
failure. We'll check if the return value equals to 0.
Also, the MIG_MODE should be CPR_TRANSFER and CPR_EXEC instead
of 2 same bits.

The API usage is aligned with 'hw/vfio/cpr-legacy.c' after these 2
changes.

Fixes: 3ca0a0ab05c ("migration: Use bitset of MigMode instead of variable arguments")
Signed-off-by: Jim Shu <jim.shu@sifive.com>
---
 hw/vfio/cpr-iommufd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/vfio/cpr-iommufd.c b/hw/vfio/cpr-iommufd.c
index c244db88fbb..6758c73b6b9 100644
--- a/hw/vfio/cpr-iommufd.c
+++ b/hw/vfio/cpr-iommufd.c
@@ -159,8 +159,8 @@ bool vfio_iommufd_cpr_register_iommufd(IOMMUFDBackend *be, Error **errp)
 
     if (!vfio_cpr_supported(be, cpr_blocker)) {
         return migrate_add_blocker_modes(cpr_blocker,
-                    BIT(MIG_MODE_CPR_TRANSFER) | BIT(MIG_MODE_CPR_TRANSFER),
-                    errp);
+                    BIT(MIG_MODE_CPR_TRANSFER) | BIT(MIG_MODE_CPR_EXEC),
+                    errp) == 0;
     }
 
     vmstate_register(NULL, -1, &iommufd_cpr_vmstate, be);
-- 
2.43.0
Re: [PATCH] hw/vfio: cpr-iommufd: Fix wrong usage of migrate_add_blocker_modes
Posted by Cédric Le Goater 2 weeks, 4 days ago
On 1/21/26 07:34, Jim Shu wrote:
> The return value of API is 0 for success and negative error code for
> failure. We'll check if the return value equals to 0.
> Also, the MIG_MODE should be CPR_TRANSFER and CPR_EXEC instead
> of 2 same bits.
> 
> The API usage is aligned with 'hw/vfio/cpr-legacy.c' after these 2
> changes.
> 
> Fixes: 3ca0a0ab05c ("migration: Use bitset of MigMode instead of variable arguments")
> Signed-off-by: Jim Shu <jim.shu@sifive.com>
> ---
>   hw/vfio/cpr-iommufd.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/vfio/cpr-iommufd.c b/hw/vfio/cpr-iommufd.c
> index c244db88fbb..6758c73b6b9 100644
> --- a/hw/vfio/cpr-iommufd.c
> +++ b/hw/vfio/cpr-iommufd.c
> @@ -159,8 +159,8 @@ bool vfio_iommufd_cpr_register_iommufd(IOMMUFDBackend *be, Error **errp)
>   
>       if (!vfio_cpr_supported(be, cpr_blocker)) {
>           return migrate_add_blocker_modes(cpr_blocker,
> -                    BIT(MIG_MODE_CPR_TRANSFER) | BIT(MIG_MODE_CPR_TRANSFER),
> -                    errp);
> +                    BIT(MIG_MODE_CPR_TRANSFER) | BIT(MIG_MODE_CPR_EXEC),
> +                    errp) == 0;
>       }
>   
>       vmstate_register(NULL, -1, &iommufd_cpr_vmstate, be);

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


Thanks,

C.