Message ID | 20230731102521.15335-4-avihaih@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | vfio/migration: Add P2P support for VFIO migration | expand |
On 7/31/23 12:25, Avihai Horon wrote: > Add qdev_add_vm_change_state_handler_full() variant that allows setting > a prepare callback in addition to the main callback. > > This will facilitate adding P2P support for VFIO migration in the > following patches. > > Signed-off-by: Avihai Horon <avihaih@nvidia.com> > Signed-off-by: Joao Martins <joao.m.martins@oracle.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Thanks, C. > --- > include/sysemu/runstate.h | 3 +++ > hw/core/vm-change-state-handler.c | 14 +++++++++++++- > 2 files changed, 16 insertions(+), 1 deletion(-) > > diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h > index 764a0fc6a4..08afb97695 100644 > --- a/include/sysemu/runstate.h > +++ b/include/sysemu/runstate.h > @@ -23,6 +23,9 @@ qemu_add_vm_change_state_handler_prio_full(VMChangeStateHandler *cb, > VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev, > VMChangeStateHandler *cb, > void *opaque); > +VMChangeStateEntry *qdev_add_vm_change_state_handler_full( > + DeviceState *dev, VMChangeStateHandler *cb, > + VMChangeStateHandler *prepare_cb, void *opaque); > void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); > /** > * vm_state_notify: Notify the state of the VM > diff --git a/hw/core/vm-change-state-handler.c b/hw/core/vm-change-state-handler.c > index 1f3630986d..8e2639224e 100644 > --- a/hw/core/vm-change-state-handler.c > +++ b/hw/core/vm-change-state-handler.c > @@ -55,8 +55,20 @@ static int qdev_get_dev_tree_depth(DeviceState *dev) > VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev, > VMChangeStateHandler *cb, > void *opaque) > +{ > + return qdev_add_vm_change_state_handler_full(dev, cb, NULL, opaque); > +} > + > +/* > + * Exactly like qdev_add_vm_change_state_handler() but passes a prepare_cb > + * argument too. > + */ > +VMChangeStateEntry *qdev_add_vm_change_state_handler_full( > + DeviceState *dev, VMChangeStateHandler *cb, > + VMChangeStateHandler *prepare_cb, void *opaque) > { > int depth = qdev_get_dev_tree_depth(dev); > > - return qemu_add_vm_change_state_handler_prio(cb, opaque, depth); > + return qemu_add_vm_change_state_handler_prio_full(cb, prepare_cb, opaque, > + depth); > }
diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 764a0fc6a4..08afb97695 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -23,6 +23,9 @@ qemu_add_vm_change_state_handler_prio_full(VMChangeStateHandler *cb, VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev, VMChangeStateHandler *cb, void *opaque); +VMChangeStateEntry *qdev_add_vm_change_state_handler_full( + DeviceState *dev, VMChangeStateHandler *cb, + VMChangeStateHandler *prepare_cb, void *opaque); void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); /** * vm_state_notify: Notify the state of the VM diff --git a/hw/core/vm-change-state-handler.c b/hw/core/vm-change-state-handler.c index 1f3630986d..8e2639224e 100644 --- a/hw/core/vm-change-state-handler.c +++ b/hw/core/vm-change-state-handler.c @@ -55,8 +55,20 @@ static int qdev_get_dev_tree_depth(DeviceState *dev) VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev, VMChangeStateHandler *cb, void *opaque) +{ + return qdev_add_vm_change_state_handler_full(dev, cb, NULL, opaque); +} + +/* + * Exactly like qdev_add_vm_change_state_handler() but passes a prepare_cb + * argument too. + */ +VMChangeStateEntry *qdev_add_vm_change_state_handler_full( + DeviceState *dev, VMChangeStateHandler *cb, + VMChangeStateHandler *prepare_cb, void *opaque) { int depth = qdev_get_dev_tree_depth(dev); - return qemu_add_vm_change_state_handler_prio(cb, opaque, depth); + return qemu_add_vm_change_state_handler_prio_full(cb, prepare_cb, opaque, + depth); }