mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-11 16:00:50 -07:00
vfio/iommufd: device name blocker
If an invariant device name cannot be created, block CPR. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Link: https://lore.kernel.org/qemu-devel/1751493538-202042-12-git-send-email-steven.sistare@oracle.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
184053f04f
commit
a434fd8f64
2 changed files with 12 additions and 0 deletions
|
|
@ -28,6 +28,8 @@
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qemu/units.h"
|
#include "qemu/units.h"
|
||||||
|
#include "migration/cpr.h"
|
||||||
|
#include "migration/blocker.h"
|
||||||
#include "monitor/monitor.h"
|
#include "monitor/monitor.h"
|
||||||
#include "vfio-helpers.h"
|
#include "vfio-helpers.h"
|
||||||
|
|
||||||
|
|
@ -324,8 +326,16 @@ bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp)
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Assign a name so any function printing it will not break.
|
* Assign a name so any function printing it will not break.
|
||||||
|
* The fd number changes across processes, so this cannot be
|
||||||
|
* used as an invariant name for CPR.
|
||||||
*/
|
*/
|
||||||
vbasedev->name = g_strdup_printf("VFIO_FD%d", vbasedev->fd);
|
vbasedev->name = g_strdup_printf("VFIO_FD%d", vbasedev->fd);
|
||||||
|
error_setg(&vbasedev->cpr.id_blocker,
|
||||||
|
"vfio device with fd=%d needs an id property",
|
||||||
|
vbasedev->fd);
|
||||||
|
return migrate_add_blocker_modes(&vbasedev->cpr.id_blocker,
|
||||||
|
errp, MIG_MODE_CPR_TRANSFER,
|
||||||
|
-1) == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -336,6 +346,7 @@ bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp)
|
||||||
void vfio_device_free_name(VFIODevice *vbasedev)
|
void vfio_device_free_name(VFIODevice *vbasedev)
|
||||||
{
|
{
|
||||||
g_clear_pointer(&vbasedev->name, g_free);
|
g_clear_pointer(&vbasedev->name, g_free);
|
||||||
|
migrate_del_blocker(&vbasedev->cpr.id_blocker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **errp)
|
void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error **errp)
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ typedef struct VFIOContainerCPR {
|
||||||
|
|
||||||
typedef struct VFIODeviceCPR {
|
typedef struct VFIODeviceCPR {
|
||||||
Error *mdev_blocker;
|
Error *mdev_blocker;
|
||||||
|
Error *id_blocker;
|
||||||
} VFIODeviceCPR;
|
} VFIODeviceCPR;
|
||||||
|
|
||||||
bool vfio_legacy_cpr_register_container(struct VFIOContainer *container,
|
bool vfio_legacy_cpr_register_container(struct VFIOContainer *container,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue