mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 19:45:21 +00:00
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:
parent
5169e5ea38
commit
c3fd09f7b7
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user