[libvirt] [PATCH v2 6/8] logging: support truncation of logfiles when opening

John Ferlan jferlan at redhat.com
Fri Mar 4 14:33:42 UTC 2016



On 02/29/2016 08:33 AM, Daniel P. Berrange wrote:
> 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.
> ---
>  src/logging/log_daemon_dispatch.c | 3 ++-
>  src/logging/log_handler.c         | 6 ++----
>  src/logging/log_handler.h         | 2 +-
>  src/logging/log_manager.h         | 2 ++
>  src/logging/log_protocol.x        | 4 ++++
>  5 files changed, 11 insertions(+), 6 deletions(-)
> 

[...]

> diff --git a/src/logging/log_protocol.x b/src/logging/log_protocol.x
> index b0ac31b..0363c75 100644
> --- a/src/logging/log_protocol.x
> +++ b/src/logging/log_protocol.x
> @@ -30,6 +30,10 @@ struct virLogManagerProtocolLogFilePosition {
>  };
>  typedef struct virLogManagerProtocolLogFilePosition virLogManagerProtocolLogFilePosition;
>  
> +enum virLogManagerProtocolDomainOpenLogFileFlags {
> +    VIR_LOG_MANAGER_PROTOCOL_DOMAIN_OPEN_LOG_FILE_TRUNCATE = 1
> +};
> +

Use "= (1 << 0)" (just to be painfully obvious for the next adjustment)

Since the trunc setting is "flags & VIR_LOG_*_TRUNCATE"

On an unrelated note (while looking at other possible uses of similar
constructs - virLockSpaceProtocolAcquireResourceFlags so far is OK, but
if the "next" value isn't 4....




More information about the libvir-list mailing list