All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] migration/ram: add additional check
@ 2024-03-04 14:42 Maksim Davydov
  2024-03-05  2:27 ` Peter Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Maksim Davydov @ 2024-03-04 14:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: farosas, peterx

If a migration stream is broken, the address and flag reading can return
zero. Thus, an irrelevant flag error will be returned instead of EIO.
It can be fixed by additional check after the reading.

Signed-off-by: Maksim Davydov <davydov-max@yandex-team.ru>
---
 migration/ram.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/migration/ram.c b/migration/ram.c
index 45a00b45ed..95d8b19c3b 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -3902,6 +3902,12 @@ static int ram_load_precopy(QEMUFile *f)
         i++;
 
         addr = qemu_get_be64(f);
+        ret = qemu_file_get_error(f);
+        if (ret) {
+            error_report("Getting RAM address failed");
+            break;
+        }
+
         flags = addr & ~TARGET_PAGE_MASK;
         addr &= TARGET_PAGE_MASK;
 
-- 
2.34.1



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

* Re: [PATCH] migration/ram: add additional check
  2024-03-04 14:42 [PATCH] migration/ram: add additional check Maksim Davydov
@ 2024-03-05  2:27 ` Peter Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Xu @ 2024-03-05  2:27 UTC (permalink / raw)
  To: Maksim Davydov; +Cc: qemu-devel, farosas

On Mon, Mar 04, 2024 at 05:42:03PM +0300, Maksim Davydov wrote:
> If a migration stream is broken, the address and flag reading can return
> zero. Thus, an irrelevant flag error will be returned instead of EIO.
> It can be fixed by additional check after the reading.
> 
> Signed-off-by: Maksim Davydov <davydov-max@yandex-team.ru>
> ---
>  migration/ram.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index 45a00b45ed..95d8b19c3b 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -3902,6 +3902,12 @@ static int ram_load_precopy(QEMUFile *f)
>          i++;
>  
>          addr = qemu_get_be64(f);
> +        ret = qemu_file_get_error(f);
> +        if (ret) {
> +            error_report("Getting RAM address failed");
> +            break;
> +        }
> +
>          flags = addr & ~TARGET_PAGE_MASK;
>          addr &= TARGET_PAGE_MASK;
>  
> -- 
> 2.34.1
> 
> 

Queued, thanks.

-- 
Peter Xu



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

end of thread, other threads:[~2024-03-05  2:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-04 14:42 [PATCH] migration/ram: add additional check Maksim Davydov
2024-03-05  2:27 ` Peter Xu

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.