libxl: fix leaking logfile fds

Per-domain log files were introduced in commit a30b08b717. The FILE
objects associated with these log files are stored in a hash table
using domid as a key. When a domain is shutdown, destroyed, or
otherwise powered-off, the FILE object is removed from the hash table,
where the free function will close the FILE.

Unfortunately the call to remove the FILE from the hash table occurs
after setting domid=-1 in the libxlDomainCleanup() function. The
object is never removed from the hash table, the free function is
never called, and the underlying fd is leaked. Fix by removing the
FILE object from the hash table before setting domid=-1.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Jim Fehlig 2018-05-31 15:41:37 -06:00
parent a1b43af0ba
commit 67c56f6e65
1 changed files with 1 additions and 2 deletions

View File

@ -769,6 +769,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
VIR_WARN("Unable to release lease on %s", vm->def->name);
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
libxlLoggerCloseFile(cfg->logger, vm->def->id);
vm->def->id = -1;
if (priv->deathW) {
@ -822,8 +823,6 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
VIR_FREE(xml);
}
libxlLoggerCloseFile(cfg->logger, vm->def->id);
virDomainObjRemoveTransientDef(vm);
virObjectUnref(cfg);
}