All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] vfio/migration: Correct device state from vmstate change for savevm case.
@ 2021-06-08 18:37 Kirti Wankhede
  2021-06-18 10:44 ` Kirti Wankhede
  0 siblings, 1 reply; 2+ messages in thread
From: Kirti Wankhede @ 2021-06-08 18:37 UTC (permalink / raw)
  To: alex.williamson, dgilbert
  Cc: cjia, cohuck, qemu-devel, Kirti Wankhede, dnigam, targupta

Set _SAVING flag for device state from vmstate change handler when it gets
called from savevm.

Currently State transition savevm/suspend is seen as:
    _RUNNING -> _STOP -> Stop-and-copy -> _STOP

State transition savevm/suspend should be:
    _RUNNING -> Stop-and-copy -> _STOP

State transition from _RUNNING to _STOP occurs from vfio_vmstate_change()
where when vmstate changes from running to !running, _RUNNING flag is reset
but at the same time when vfio_vmstate_change() is called for
RUN_STATE_SAVE_VM, _SAVING bit should be set.

Reported by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com>
---
 hw/vfio/migration.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 384576cfc051..33242b2313b9 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -725,7 +725,16 @@ static void vfio_vmstate_change(void *opaque, bool running, RunState state)
          * _RUNNING bit
          */
         mask = ~VFIO_DEVICE_STATE_RUNNING;
-        value = 0;
+
+        /*
+         * When VM state transition to stop for savevm command, device should
+         * start saving data.
+         */
+        if (state == RUN_STATE_SAVE_VM) {
+            value = VFIO_DEVICE_STATE_SAVING;
+        } else {
+            value = 0;
+        }
     }
 
     ret = vfio_migration_set_state(vbasedev, mask, value);
-- 
2.7.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1 1/1] vfio/migration: Correct device state from vmstate change for savevm case.
  2021-06-08 18:37 [PATCH v1 1/1] vfio/migration: Correct device state from vmstate change for savevm case Kirti Wankhede
@ 2021-06-18 10:44 ` Kirti Wankhede
  0 siblings, 0 replies; 2+ messages in thread
From: Kirti Wankhede @ 2021-06-18 10:44 UTC (permalink / raw)
  To: alex.williamson, dgilbert
  Cc: mgurtovoy, yishaih, cjia, cohuck, qemu-devel, dnigam,
	Jason Gunthorpe, targupta

CCing more Nvidia folks who are testing this patch.

Gentle Ping for review.

Thanks,
Kirti


On 6/9/2021 12:07 AM, Kirti Wankhede wrote:
> Set _SAVING flag for device state from vmstate change handler when it gets
> called from savevm.
> 
> Currently State transition savevm/suspend is seen as:
>      _RUNNING -> _STOP -> Stop-and-copy -> _STOP
> 
> State transition savevm/suspend should be:
>      _RUNNING -> Stop-and-copy -> _STOP
> 
> State transition from _RUNNING to _STOP occurs from vfio_vmstate_change()
> where when vmstate changes from running to !running, _RUNNING flag is reset
> but at the same time when vfio_vmstate_change() is called for
> RUN_STATE_SAVE_VM, _SAVING bit should be set.
> 
> Reported by: Yishai Hadas <yishaih@nvidia.com>
> Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com>
> ---
>   hw/vfio/migration.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
> index 384576cfc051..33242b2313b9 100644
> --- a/hw/vfio/migration.c
> +++ b/hw/vfio/migration.c
> @@ -725,7 +725,16 @@ static void vfio_vmstate_change(void *opaque, bool running, RunState state)
>            * _RUNNING bit
>            */
>           mask = ~VFIO_DEVICE_STATE_RUNNING;
> -        value = 0;
> +
> +        /*
> +         * When VM state transition to stop for savevm command, device should
> +         * start saving data.
> +         */
> +        if (state == RUN_STATE_SAVE_VM) {
> +            value = VFIO_DEVICE_STATE_SAVING;
> +        } else {
> +            value = 0;
> +        }
>       }
>   
>       ret = vfio_migration_set_state(vbasedev, mask, value);
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-18 11:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 18:37 [PATCH v1 1/1] vfio/migration: Correct device state from vmstate change for savevm case Kirti Wankhede
2021-06-18 10:44 ` Kirti Wankhede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.