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' value in the error section.
https://bugzilla.redhat.com/show_bug.cgi?id=
1791522
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
bool unlink_corrupt)
{
int fd = -1;
+ int ret = -1;
virQEMUSaveDataPtr data = NULL;
virQEMUSaveHeaderPtr header;
virDomainDefPtr def = NULL;
_("cannot remove corrupt file: %s"),
path);
} else {
- fd = -3;
+ ret = -3;
}
} else {
virReportError(VIR_ERR_OPERATION_FAILED,
_("cannot remove corrupt file: %s"),
path);
} else {
- fd = -3;
+ ret = -3;
}
goto error;
}
virDomainDefFree(def);
virQEMUSaveDataFree(data);
VIR_FORCE_CLOSE(fd);
- return -1;
+ return ret;
}
static int ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(6)