2024-02-22 20:28:37 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021-2024 Oracle and/or its affiliates.
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "hw/vfio/vfio-common.h"
|
2024-02-22 20:28:38 +03:00
|
|
|
#include "migration/misc.h"
|
2024-02-22 20:28:37 +03:00
|
|
|
#include "qapi/error.h"
|
2024-02-22 20:28:38 +03:00
|
|
|
#include "sysemu/runstate.h"
|
|
|
|
|
|
|
|
static int vfio_cpr_reboot_notifier(NotifierWithReturn *notifier,
|
|
|
|
MigrationEvent *e, Error **errp)
|
|
|
|
{
|
|
|
|
if (e->type == MIG_EVENT_PRECOPY_SETUP &&
|
|
|
|
!runstate_check(RUN_STATE_SUSPENDED) && !vm_get_suspended()) {
|
|
|
|
|
|
|
|
error_setg(errp,
|
|
|
|
"VFIO device only supports cpr-reboot for runstate suspended");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2024-02-22 20:28:37 +03:00
|
|
|
|
2024-05-07 09:42:51 +03:00
|
|
|
bool vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **errp)
|
2024-02-22 20:28:37 +03:00
|
|
|
{
|
2024-02-22 20:28:38 +03:00
|
|
|
migration_add_notifier_mode(&bcontainer->cpr_reboot_notifier,
|
|
|
|
vfio_cpr_reboot_notifier,
|
|
|
|
MIG_MODE_CPR_REBOOT);
|
2024-05-07 09:42:51 +03:00
|
|
|
return true;
|
2024-02-22 20:28:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer)
|
|
|
|
{
|
2024-02-22 20:28:38 +03:00
|
|
|
migration_remove_notifier(&bcontainer->cpr_reboot_notifier);
|
2024-02-22 20:28:37 +03:00
|
|
|
}
|