mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
system/runstate: add VM state change cb with return value
This patch adds the new VM state change cb type `VMChangeStateHandlerWithRet`, which has return value for `VMChangeStateEntry`. Thus, we can register a new VM state change cb with return value for device. Note that `VMChangeStateHandler` and `VMChangeStateHandlerWithRet` are mutually exclusive and cannot be provided at the same time. This patch is the pre patch for 'vhost-user: return failure if backend crashes when live migration', which makes the live migration aware of the loss of connection with the vhost-user backend and aborts the live migration. Virtio device will use VMChangeStateHandlerWithRet. Signed-off-by: Haoqian He <haoqian.he@smartx.com> Message-Id: <20250416024729.3289157-2-haoqian.he@smartx.com> Tested-by: Lei Yang <leiyang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
8717987fb5
commit
e0f300b36d
8 changed files with 62 additions and 20 deletions
|
@ -12,6 +12,7 @@ bool runstate_needs_reset(void);
|
|||
void runstate_replay_enable(void);
|
||||
|
||||
typedef void VMChangeStateHandler(void *opaque, bool running, RunState state);
|
||||
typedef int VMChangeStateHandlerWithRet(void *opaque, bool running, RunState state);
|
||||
|
||||
VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
|
||||
void *opaque);
|
||||
|
@ -20,21 +21,27 @@ VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
|
|||
VMChangeStateEntry *
|
||||
qemu_add_vm_change_state_handler_prio_full(VMChangeStateHandler *cb,
|
||||
VMChangeStateHandler *prepare_cb,
|
||||
VMChangeStateHandlerWithRet *cb_ret,
|
||||
void *opaque, int priority);
|
||||
VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev,
|
||||
VMChangeStateHandler *cb,
|
||||
VMChangeStateHandlerWithRet *cb_ret,
|
||||
void *opaque);
|
||||
VMChangeStateEntry *qdev_add_vm_change_state_handler_full(
|
||||
DeviceState *dev, VMChangeStateHandler *cb,
|
||||
VMChangeStateHandler *prepare_cb, void *opaque);
|
||||
DeviceState *dev, VMChangeStateHandler *cb, VMChangeStateHandler *prepare_cb,
|
||||
VMChangeStateHandlerWithRet *cb_ret, void *opaque);
|
||||
void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
|
||||
/**
|
||||
* vm_state_notify: Notify the state of the VM
|
||||
*
|
||||
* @running: whether the VM is running or not.
|
||||
* @state: the #RunState of the VM.
|
||||
*
|
||||
* Return the result of the callback which has return value.
|
||||
* If no callback has return value, still return 0 and the
|
||||
* upper layer should not do additional processing.
|
||||
*/
|
||||
void vm_state_notify(bool running, RunState state);
|
||||
int vm_state_notify(bool running, RunState state);
|
||||
|
||||
static inline bool shutdown_caused_by_guest(ShutdownCause cause)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue