mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35: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 *
|
||||
libxlDriverConfigGet(libxlDriverPrivate *driver)
|
||||
{
|
||||
libxlDriverConfig *cfg;
|
||||
|
||||
libxlDriverLock(driver);
|
||||
cfg = virObjectRef(driver->config);
|
||||
libxlDriverUnlock(driver);
|
||||
return cfg;
|
||||
VIR_LOCK_GUARD lock = virLockGuardLock(&driver->lock);
|
||||
return virObjectRef(driver->config);
|
||||
}
|
||||
|
||||
int libxlDriverConfigLoadFile(libxlDriverConfig *cfg,
|
||||
|
@ -219,15 +219,3 @@ libxlBuildDomainConfig(virPortAllocatorRange *graphicsports,
|
||||
virDomainDef *def,
|
||||
libxlDriverConfig *cfg,
|
||||
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? */
|
||||
if ((start = strstr(message, ": Domain ")) &&
|
||||
(end = strstr(start + 9, ":"))) {
|
||||
FILE *domainLogFile;
|
||||
FILE *domainLogFile = NULL;
|
||||
|
||||
VIR_DEBUG("Found domain log message");
|
||||
|
||||
start = start + 9;
|
||||
*end = '\0';
|
||||
|
||||
virMutexLock(&lg->tableLock);
|
||||
domainLogFile = virHashLookup(lg->files, start);
|
||||
virMutexUnlock(&lg->tableLock);
|
||||
VIR_WITH_MUTEX_LOCK_GUARD(&lg->tableLock) {
|
||||
domainLogFile = virHashLookup(lg->files, start);
|
||||
}
|
||||
if (domainLogFile)
|
||||
logFile = domainLogFile;
|
||||
|
||||
@ -197,9 +197,9 @@ libxlLoggerOpenFile(libxlLogger *logger,
|
||||
path, g_strerror(errno));
|
||||
return;
|
||||
}
|
||||
virMutexLock(&logger->tableLock);
|
||||
ignore_value(virHashAddEntry(logger->files, domidstr, logFile));
|
||||
virMutexUnlock(&logger->tableLock);
|
||||
VIR_WITH_MUTEX_LOCK_GUARD(&logger->tableLock) {
|
||||
ignore_value(virHashAddEntry(logger->files, domidstr, logFile));
|
||||
}
|
||||
|
||||
/* domain_config is non NULL only when starting a new domain */
|
||||
if (domain_config) {
|
||||
@ -211,10 +211,8 @@ libxlLoggerOpenFile(libxlLogger *logger,
|
||||
void
|
||||
libxlLoggerCloseFile(libxlLogger *logger, int id)
|
||||
{
|
||||
g_autofree char *domidstr = NULL;
|
||||
domidstr = g_strdup_printf("%d", id);
|
||||
g_autofree char *domidstr = g_strdup_printf("%d", id);
|
||||
VIR_LOCK_GUARD lock = virLockGuardLock(&logger->tableLock);
|
||||
|
||||
virMutexLock(&logger->tableLock);
|
||||
ignore_value(virHashRemoveEntry(logger->files, domidstr));
|
||||
virMutexUnlock(&logger->tableLock);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user