mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
libxl: Use automatic memory management
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
8278ca919e
commit
621fa350ab
@ -1815,12 +1815,8 @@ libxlDriverConfigInit(libxlDriverConfig *cfg)
|
|||||||
libxlDriverConfig *
|
libxlDriverConfig *
|
||||||
libxlDriverConfigGet(libxlDriverPrivate *driver)
|
libxlDriverConfigGet(libxlDriverPrivate *driver)
|
||||||
{
|
{
|
||||||
libxlDriverConfig *cfg;
|
VIR_LOCK_GUARD lock = virLockGuardLock(&driver->lock);
|
||||||
|
return virObjectRef(driver->config);
|
||||||
libxlDriverLock(driver);
|
|
||||||
cfg = virObjectRef(driver->config);
|
|
||||||
libxlDriverUnlock(driver);
|
|
||||||
return cfg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int libxlDriverConfigLoadFile(libxlDriverConfig *cfg,
|
int libxlDriverConfigLoadFile(libxlDriverConfig *cfg,
|
||||||
|
@ -219,15 +219,3 @@ libxlBuildDomainConfig(virPortAllocatorRange *graphicsports,
|
|||||||
virDomainDef *def,
|
virDomainDef *def,
|
||||||
libxlDriverConfig *cfg,
|
libxlDriverConfig *cfg,
|
||||||
libxl_domain_config *d_config);
|
libxl_domain_config *d_config);
|
||||||
|
|
||||||
static inline void
|
|
||||||
libxlDriverLock(libxlDriverPrivate *driver)
|
|
||||||
{
|
|
||||||
virMutexLock(&driver->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
libxlDriverUnlock(libxlDriverPrivate *driver)
|
|
||||||
{
|
|
||||||
virMutexUnlock(&driver->lock);
|
|
||||||
}
|
|
||||||
|
@ -79,16 +79,16 @@ libvirt_vmessage(xentoollog_logger *logger_in,
|
|||||||
/* Should we print to a domain-specific log file? */
|
/* Should we print to a domain-specific log file? */
|
||||||
if ((start = strstr(message, ": Domain ")) &&
|
if ((start = strstr(message, ": Domain ")) &&
|
||||||
(end = strstr(start + 9, ":"))) {
|
(end = strstr(start + 9, ":"))) {
|
||||||
FILE *domainLogFile;
|
FILE *domainLogFile = NULL;
|
||||||
|
|
||||||
VIR_DEBUG("Found domain log message");
|
VIR_DEBUG("Found domain log message");
|
||||||
|
|
||||||
start = start + 9;
|
start = start + 9;
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
|
|
||||||
virMutexLock(&lg->tableLock);
|
VIR_WITH_MUTEX_LOCK_GUARD(&lg->tableLock) {
|
||||||
domainLogFile = virHashLookup(lg->files, start);
|
domainLogFile = virHashLookup(lg->files, start);
|
||||||
virMutexUnlock(&lg->tableLock);
|
}
|
||||||
if (domainLogFile)
|
if (domainLogFile)
|
||||||
logFile = domainLogFile;
|
logFile = domainLogFile;
|
||||||
|
|
||||||
@ -197,9 +197,9 @@ libxlLoggerOpenFile(libxlLogger *logger,
|
|||||||
path, g_strerror(errno));
|
path, g_strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
virMutexLock(&logger->tableLock);
|
VIR_WITH_MUTEX_LOCK_GUARD(&logger->tableLock) {
|
||||||
ignore_value(virHashAddEntry(logger->files, domidstr, logFile));
|
ignore_value(virHashAddEntry(logger->files, domidstr, logFile));
|
||||||
virMutexUnlock(&logger->tableLock);
|
}
|
||||||
|
|
||||||
/* domain_config is non NULL only when starting a new domain */
|
/* domain_config is non NULL only when starting a new domain */
|
||||||
if (domain_config) {
|
if (domain_config) {
|
||||||
@ -211,10 +211,8 @@ libxlLoggerOpenFile(libxlLogger *logger,
|
|||||||
void
|
void
|
||||||
libxlLoggerCloseFile(libxlLogger *logger, int id)
|
libxlLoggerCloseFile(libxlLogger *logger, int id)
|
||||||
{
|
{
|
||||||
g_autofree char *domidstr = NULL;
|
g_autofree char *domidstr = g_strdup_printf("%d", id);
|
||||||
domidstr = g_strdup_printf("%d", id);
|
VIR_LOCK_GUARD lock = virLockGuardLock(&logger->tableLock);
|
||||||
|
|
||||||
virMutexLock(&logger->tableLock);
|
|
||||||
ignore_value(virHashRemoveEntry(logger->files, domidstr));
|
ignore_value(virHashRemoveEntry(logger->files, domidstr));
|
||||||
virMutexUnlock(&logger->tableLock);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user