qemu
1/*
2* Copyright (c) 2021-2024 Oracle and/or its affiliates.
3*
4* This work is licensed under the terms of the GNU GPL, version 2 or later.
5* See the COPYING file in the top-level directory.
6*/
7
8#include "qemu/osdep.h"9#include "hw/vfio/vfio-common.h"10#include "migration/misc.h"11#include "qapi/error.h"12#include "sysemu/runstate.h"13
14static int vfio_cpr_reboot_notifier(NotifierWithReturn *notifier,15MigrationEvent *e, Error **errp)16{
17if (e->type == MIG_EVENT_PRECOPY_SETUP &&18!runstate_check(RUN_STATE_SUSPENDED) && !vm_get_suspended()) {19
20error_setg(errp,21"VFIO device only supports cpr-reboot for runstate suspended");22
23return -1;24}25return 0;26}
27
28bool vfio_cpr_register_container(VFIOContainerBase *bcontainer, Error **errp)29{
30migration_add_notifier_mode(&bcontainer->cpr_reboot_notifier,31vfio_cpr_reboot_notifier,32MIG_MODE_CPR_REBOOT);33return true;34}
35
36void vfio_cpr_unregister_container(VFIOContainerBase *bcontainer)37{
38migration_remove_notifier(&bcontainer->cpr_reboot_notifier);39}
40