diff mbox series

[for-8.2,v2,3/6] qdev: Add qdev_add_vm_change_state_handler_full()

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

Commit Message

Avihai Horon July 31, 2023, 10:25 a.m. UTC
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>
---
 include/sysemu/runstate.h         |  3 +++
 hw/core/vm-change-state-handler.c | 14 +++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

Comments

Cédric Le Goater Aug. 1, 2023, 12:04 p.m. UTC | #1
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 mbox series

Patch

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);
 }