The virtlogd daemon currently opens all files for append, but
in some cases the user may wish to discard existing data. Define
a new flag to indicate that logfiles should be truncated when
opening.
int rv = -1;
off_t offset;
ino_t inode;
+ bool trunc = args->flags & VIR_LOG_MANAGER_PROTOCOL_DOMAIN_OPEN_LOG_FILE_TRUNCATE;
if ((fd = virLogHandlerDomainOpenLogFile(virLogDaemonGetHandler(logDaemon),
args->driver,
(unsigned char *)args->dom.uuid,
args->dom.name,
args->path,
- args->flags,
+ trunc,
&inode, &offset)) < 0)
goto cleanup;
const unsigned char *domuuid,
const char *domname,
const char *path,
- unsigned int flags,
+ bool trunc,
ino_t *inode,
off_t *offset)
{
virLogHandlerLogFilePtr file = NULL;
int pipefd[2] = { -1, -1 };
- virCheckFlags(0, -1);
-
virObjectLock(handler);
handler->inhibitor(true, handler->opaque);
if ((file->file = virRotatingFileWriterNew(path,
DEFAULT_FILE_SIZE,
DEFAULT_MAX_BACKUP,
- false,
+ trunc,
DEFAULT_MODE)) == NULL)
goto error;
const unsigned char *domuuid,
const char *domname,
const char *path,
- unsigned int flags,
+ bool trunc,
ino_t *inode,
off_t *offset);
# include "internal.h"
+# include "logging/log_protocol.h"
+
typedef struct _virLogManager virLogManager;
typedef virLogManager *virLogManagerPtr;
};
typedef struct virLogManagerProtocolLogFilePosition virLogManagerProtocolLogFilePosition;
+enum virLogManagerProtocolDomainOpenLogFileFlags {
+ VIR_LOG_MANAGER_PROTOCOL_DOMAIN_OPEN_LOG_FILE_TRUNCATE = 1
+};
+
/* Obtain a file handle suitable for writing to a
* log file for a domain
*/