mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
lxc: virLXCProcessReadLogOutput: Automatically close FD
Switch to 'VIR_AUTOCLOSE' to simplify cleanup. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
b0c680853a
commit
68d5617c3c
@ -1076,8 +1076,7 @@ virLXCProcessReadLogOutput(virDomainObj *vm,
|
|||||||
char *buf,
|
char *buf,
|
||||||
size_t buflen)
|
size_t buflen)
|
||||||
{
|
{
|
||||||
int fd = -1;
|
VIR_AUTOCLOSE fd = -1;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if ((fd = open(logfile, O_RDONLY)) < 0) {
|
if ((fd = open(logfile, O_RDONLY)) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
@ -1090,17 +1089,10 @@ virLXCProcessReadLogOutput(virDomainObj *vm,
|
|||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Unable to seek log file %s to %llu"),
|
_("Unable to seek log file %s to %llu"),
|
||||||
logfile, (unsigned long long)pos);
|
logfile, (unsigned long long)pos);
|
||||||
VIR_FORCE_CLOSE(fd);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virLXCProcessReadLogOutputData(vm,
|
return virLXCProcessReadLogOutputData(vm, fd, buf, buflen);
|
||||||
fd,
|
|
||||||
buf,
|
|
||||||
buflen);
|
|
||||||
|
|
||||||
VIR_FORCE_CLOSE(fd);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user