Re: [PATCH 1/6] qemu: fix domain start with corrupted save file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 22, 2020 at 05:04:54PM +0200, Peter Krempa wrote:
> Commit 21ad56e932 introduced a regression where a VM with a corrupted
> save image file would fail to start on the first attempt. This was
> caused by returning a wrong return code as  'fd' was abused to also hold
> the return code.
> 
> Since it's easy to miss this nuance introduce a 'ret' variable for the
> return code and return it's value in the error section.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1791522
> 
> Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>

Reviewed-by: Pavel Mores <pmores@xxxxxxxxxx>

> ---
>  src/qemu/qemu_driver.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index dfe0adaad8..9a9361949d 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -6691,6 +6691,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
>                          bool unlink_corrupt)
>  {
>      int fd = -1;
> +    int ret = -1;
>      virQEMUSaveDataPtr data = NULL;
>      virQEMUSaveHeaderPtr header;
>      virDomainDefPtr def = NULL;
> @@ -6726,7 +6727,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
>                                       _("cannot remove corrupt file: %s"),
>                                       path);
>              } else {
> -                fd = -3;
> +                ret = -3;
>              }
>          } else {
>              virReportError(VIR_ERR_OPERATION_FAILED,
> @@ -6747,7 +6748,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
>                                           _("cannot remove corrupt file: %s"),
>                                           path);
>                  } else {
> -                    fd = -3;
> +                    ret = -3;
>                  }
>                  goto error;
>              }
> @@ -6816,7 +6817,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
>      virDomainDefFree(def);
>      virQEMUSaveDataFree(data);
>      VIR_FORCE_CLOSE(fd);
> -    return -1;
> +    return ret;
>  }
> 
>  static int ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(6)
> -- 
> 2.26.0
> 





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux