mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
qemuMonitorOpen: Refactor cleanup
Use VIR_AUTOCLOSE to avoid a 'cleanup' label. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
parent
0e01846dbf
commit
775cd951e2
@ -725,7 +725,7 @@ qemuMonitorOpen(virDomainObj *vm,
|
||||
qemuMonitorCallbacks *cb,
|
||||
void *opaque)
|
||||
{
|
||||
int fd = -1;
|
||||
VIR_AUTOCLOSE fd = -1;
|
||||
qemuMonitor *ret = NULL;
|
||||
|
||||
timeout += QEMU_DEFAULT_MONITOR_WAIT;
|
||||
@ -734,7 +734,7 @@ qemuMonitorOpen(virDomainObj *vm,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unable to handle monitor type: %s"),
|
||||
virDomainChrTypeToString(config->type));
|
||||
goto cleanup;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virObjectUnlock(vm);
|
||||
@ -743,18 +743,16 @@ qemuMonitorOpen(virDomainObj *vm,
|
||||
virObjectLock(vm);
|
||||
|
||||
if (fd < 0)
|
||||
goto cleanup;
|
||||
return NULL;
|
||||
|
||||
if (!virDomainObjIsActive(vm)) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||
_("domain is not running"));
|
||||
goto cleanup;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = qemuMonitorOpenInternal(vm, fd, context, cb, opaque);
|
||||
cleanup:
|
||||
if (!ret)
|
||||
VIR_FORCE_CLOSE(fd);
|
||||
fd = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user