[libvirt] [PATCH 7/8] admin: Introduce virAdmConnectSetLoggingFilters

John Ferlan jferlan at redhat.com
Tue Nov 22 19:29:39 UTC 2016



On 11/22/2016 11:29 AM, Erik Skultety wrote:
> On Wed, Nov 09, 2016 at 11:26:26AM -0500, John Ferlan wrote:
>>
>>
>> On 11/01/2016 06:27 AM, Erik Skultety wrote:
>>> Enable libvirt users to modify logging filters of a daemon from outside.
>>>
>>> Signed-off-by: Erik Skultety <eskultet at redhat.com>
>>> ---
>>>  daemon/admin.c                  | 10 ++++++++++
>>>  include/libvirt/libvirt-admin.h |  4 ++++
>>>  src/admin/admin_protocol.x      | 12 +++++++++++-
>>>  src/admin_protocol-structs      |  5 +++++
>>>  src/libvirt-admin.c             | 36 ++++++++++++++++++++++++++++++++++++
>>>  src/libvirt_admin_private.syms  |  1 +
>>>  src/libvirt_admin_public.syms   |  1 +
>>>  7 files changed, 68 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/daemon/admin.c b/daemon/admin.c
>>> index 79961b2..b66ccd8 100644
>>> --- a/daemon/admin.c
>>> +++ b/daemon/admin.c
>>> @@ -434,6 +434,16 @@ adminConnectSetLoggingOutputs(virNetDaemonPtr dmn ATTRIBUTE_UNUSED,
>>>  }
>>>  
>>>  static int
>>> +adminConnectSetLoggingFilters(virNetDaemonPtr dmn ATTRIBUTE_UNUSED,
>>> +                              const char *filters,
>>> +                              unsigned int flags)
>>> +{
>>> +    virCheckFlags(0, -1);
>>> +
>>> +    return virLogSetFilters(filters);
>>> +}
>>> +
>>> +static int
>>>  adminDispatchConnectGetLoggingOutputs(virNetServerPtr server ATTRIBUTE_UNUSED,
>>>                                        virNetServerClientPtr client ATTRIBUTE_UNUSED,
>>>                                        virNetMessagePtr msg ATTRIBUTE_UNUSED,
>>> diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admin.h
>>> index aa33fef..161727e 100644
>>> --- a/include/libvirt/libvirt-admin.h
>>> +++ b/include/libvirt/libvirt-admin.h
>>> @@ -416,6 +416,10 @@ int virAdmConnectSetLoggingOutputs(virAdmConnectPtr conn,
>>>                                     const char *outputs,
>>>                                     unsigned int flags);
>>>  
>>> +int virAdmConnectSetLoggingFilters(virAdmConnectPtr conn,
>>> +                                   const char *filters,
>>> +                                   unsigned int flags);
>>> +
>>>  # ifdef __cplusplus
>>>  }
>>>  # endif
>>> diff --git a/src/admin/admin_protocol.x b/src/admin/admin_protocol.x
>>> index 4a05928..4eef088 100644
>>> --- a/src/admin/admin_protocol.x
>>> +++ b/src/admin/admin_protocol.x
>>> @@ -206,6 +206,11 @@ struct admin_connect_set_logging_outputs_args {
>>>      unsigned int flags;
>>>  };
>>>  
>>> +struct admin_connect_set_logging_filters_args {
>>> +    admin_nonnull_string filters;
>>> +    unsigned int flags;
>>> +};
>>> +
>>>  /* Define the program number, protocol version and procedure numbers here. */
>>>  const ADMIN_PROGRAM = 0x06900690;
>>>  const ADMIN_PROTOCOL_VERSION = 1;
>>> @@ -306,5 +311,10 @@ enum admin_procedure {
>>>      /**
>>>       * @generate: both
>>>       */
>>> -    ADMIN_PROC_CONNECT_SET_LOGGING_OUTPUTS = 16
>>> +    ADMIN_PROC_CONNECT_SET_LOGGING_OUTPUTS = 16,
>>> +
>>> +    /**
>>> +     * @generate: both
>>> +     */
>>> +    ADMIN_PROC_CONNECT_SET_LOGGING_FILTERS = 17
>>>  };
>>> diff --git a/src/admin_protocol-structs b/src/admin_protocol-structs
>>> index cbc99e3..1974c07 100644
>>> --- a/src/admin_protocol-structs
>>> +++ b/src/admin_protocol-structs
>>> @@ -145,6 +145,10 @@ struct admin_connect_set_logging_outputs_args {
>>>          admin_nonnull_string       outputs;
>>>          u_int                      flags;
>>>  };
>>> +struct admin_connect_set_logging_filters_args {
>>> +        admin_nonnull_string       filters;
>>> +        u_int                      flags;
>>> +};
>>>  enum admin_procedure {
>>>          ADMIN_PROC_CONNECT_OPEN = 1,
>>>          ADMIN_PROC_CONNECT_CLOSE = 2,
>>> @@ -162,4 +166,5 @@ enum admin_procedure {
>>>          ADMIN_PROC_CONNECT_GET_LOGGING_OUTPUTS = 14,
>>>          ADMIN_PROC_CONNECT_GET_LOGGING_FILTERS = 15,
>>>          ADMIN_PROC_CONNECT_SET_LOGGING_OUTPUTS = 16,
>>> +        ADMIN_PROC_CONNECT_SET_LOGGING_FILTERS = 17,
>>>  };
>>> diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
>>> index 01ae26c..c74e6b9 100644
>>> --- a/src/libvirt-admin.c
>>> +++ b/src/libvirt-admin.c
>>> @@ -1221,3 +1221,39 @@ virAdmConnectSetLoggingOutputs(virAdmConnectPtr conn,
>>>      virDispatchError(NULL);
>>>      return -1;
>>>  }
>>> +
>>> +/**
>>> + * virAdmConnectSetLoggingFilters:
>>> + * @conn: pointer to an active admin connection
>>> + * @filters: pointer to a string containing a list of filters to be defined
>>> + * @flags: extra flags; not used yet, so callers should always pass 0
>>> + *
>>> + * Redefine the existing (set of) filter(s) with a new one specified in
>>> + * @filters. If multiple filters are specified, they need to be delimited by
>>> + * spaces. The format of each filter must conform to the format described in
>>> + * daemon's configuration file (e.g. libvirtd.conf).
>>> + *
>>
>> So you didn't want to write the code that would allow resetting filters
>> back to their defaults?  Or is that next?
>>
> 
> See my reply to 2/8, we should either fallback to some hard-coded value like
> with the outputs or not at all, since that would introduce certain level of
> confusion like what do we actually default to - a libvirt hard-coded value or
> the initial user-provided value.

So passing NULL could have a different result than passing ""?... Hmmm.

In any case, this is probably what prompted me to note something in
patch 2 about virLogDefaultFilter.

John
> 
> Erik
> 
>> IOW: I can see value for altering the filters in real time and then
>> wanting to reset them back to whatever was originally set at daemon startup.
>>
>>> + * Returns 0 if the new filter or the set of filters has been defined
>>> + * successfully, or -1 in case of an error.
>>> + */
>>> +int
>>> +virAdmConnectSetLoggingFilters(virAdmConnectPtr conn,
>>> +                               const char *filters,
>>> +                               unsigned int flags)
>>> +{
>>> +    int ret = -1;
>>> +
>>> +    VIR_DEBUG("conn=%p, flags=%x", conn, flags);
>>> +
>>> +    virResetLastError();
>>> +    virCheckAdmConnectReturn(conn, -1);
>>> +    virCheckNonNullArgGoto(filters, error);
>>> +
>>> +    if ((ret = remoteAdminConnectSetLoggingFilters(conn, filters, flags)) < 0)
>>> +        goto error;
>>> +
>>> +    return ret;
>>> + error:
>>> +    virDispatchError(NULL);
>>> +    return -1;
>>> +}
>>> diff --git a/src/libvirt_admin_private.syms b/src/libvirt_admin_private.syms
>>> index d1ca034..22b7167 100644
>>> --- a/src/libvirt_admin_private.syms
>>> +++ b/src/libvirt_admin_private.syms
>>> @@ -19,6 +19,7 @@ xdr_admin_connect_list_servers_ret;
>>>  xdr_admin_connect_lookup_server_args;
>>>  xdr_admin_connect_lookup_server_ret;
>>>  xdr_admin_connect_open_args;
>>> +xdr_admin_connect_set_logging_filters_args;
>>>  xdr_admin_connect_set_logging_outputs_args;
>>>  xdr_admin_server_get_client_limits_args;
>>>  xdr_admin_server_get_client_limits_ret;
>>> diff --git a/src/libvirt_admin_public.syms b/src/libvirt_admin_public.syms
>>> index d39de42..b4aee98 100644
>>> --- a/src/libvirt_admin_public.syms
>>> +++ b/src/libvirt_admin_public.syms
>>> @@ -40,5 +40,6 @@ LIBVIRT_ADMIN_2.0.0 {
>>>          virAdmServerSetClientLimits;
>>>          virAdmConnectGetLoggingFilters;
>>>          virAdmConnectGetLoggingOutputs;
>>> +        virAdmConnectSetLoggingFilters;
>>
>> Similar stanza comment from patch 6
>>
>>
>> John
>>>          virAdmConnectSetLoggingOutputs;
>>>  };
>>>
>>
>> --
>> libvir-list mailing list
>> libvir-list at redhat.com
>> https://www.redhat.com/mailman/listinfo/libvir-list




More information about the libvir-list mailing list