Vladimir Sementsov-Ogievskiy <[email protected]> writes:

> qemu_file_get_fd() may fail, and return -1 in this case.
> We don't support passing "invalid" file descriptors (like -1),
> so we should not interpret error here like invalid descriptor.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
> ---
>  migration/vmstate-types.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c
> index 4b01dc19c2..e34bf4486e 100644
> --- a/migration/vmstate-types.c
> +++ b/migration/vmstate-types.c
> @@ -321,12 +321,21 @@ const VMStateInfo vmstate_info_uint64 = {
>  static int get_fd(QEMUFile *f, void *pv, size_t size,
>                    const VMStateField *field)
>  {
> +    int fd;
>      int32_t *v = pv;
> +
>      if (migrate_mode() == MIG_MODE_CPR_EXEC) {
>          qemu_get_sbe32s(f, v);
>          return 0;
>      }
> -    *v = qemu_file_get_fd(f);
> +
> +    fd = qemu_file_get_fd(f);
> +    if (fd < 0) {
> +        return -1;
> +    }
> +
> +    *v = fd;
> +
>      return 0;
>  }

Reviewed-by: Fabiano Rosas <[email protected]>

Reply via email to