qemu: Don't overwrite errors by closefd in error paths

When qemuMonitorCloseFileHandle is called in error path, we need to
preserve the original error since a possible further error when running
closefd monitor command is not very useful to users.
This commit is contained in:
Jiri Denemark 2011-07-13 11:16:20 +02:00
parent 5169e5ea38
commit c3fd09f7b7
2 changed files with 15 additions and 2 deletions

View File

@ -1964,20 +1964,30 @@ int qemuMonitorSendFileHandle(qemuMonitorPtr mon,
int qemuMonitorCloseFileHandle(qemuMonitorPtr mon,
const char *fdname)
{
int ret;
int ret = -1;
virErrorPtr error;
VIR_DEBUG("mon=%p fdname=%s",
mon, fdname);
error = virSaveLastError();
if (!mon) {
qemuReportError(VIR_ERR_INVALID_ARG, "%s",
_("monitor must not be NULL"));
return -1;
goto cleanup;
}
if (mon->json)
ret = qemuMonitorJSONCloseFileHandle(mon, fdname);
else
ret = qemuMonitorTextCloseFileHandle(mon, fdname);
cleanup:
if (error) {
virSetError(error);
virFreeError(error);
}
return ret;
}

View File

@ -362,6 +362,9 @@ int qemuMonitorSendFileHandle(qemuMonitorPtr mon,
const char *fdname,
int fd);
/* The function preserves previous error and only sets it's own error if no
* error was set before.
*/
int qemuMonitorCloseFileHandle(qemuMonitorPtr mon,
const char *fdname);