提交 f76a5718 编写于 作者: P Peter Krempa

qemu: fix domain start with corrupted save file

Commit 21ad56e9 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' value in the error section.

https://bugzilla.redhat.com/show_bug.cgi?id=1791522Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NPavel Mores <pmores@redhat.com>
上级 d016a64d
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册