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

Ján Tomko jtomko at redhat.com
Wed Apr 22 16:41:51 UTC 2020

On a Wednesday in 2020, 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

double space

>the return code.
>Since it's easy to miss this nuance introduce a 'ret' variable for the

missing comma

>return code and return it's value in the error section.


>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> 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;

This does not restore the preservation of -errno from the following

     if ((fd = qemuOpenFile(driver, NULL, path, oflags, NULL)) < 0)
         goto error;

that existed before commit 21ad56e932 mentioned above. Thankfully.
Guess it's unlikely that this function would return -ESRCH and confuse
the caller.

Reviewed-by: Ján Tomko <jtomko at redhat.com>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20200422/4d54ab79/attachment-0001.sig>

More information about the libvir-list mailing list