Re: [PATCH] Allow to dynamically set the size of the debug buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 08, 2011 at 03:43:50PM +0000, Daniel P. Berrange wrote:
> On Tue, Mar 08, 2011 at 06:44:56PM +0800, Daniel Veillard wrote:
> > diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
> > index 452566c..d3631ec 100644
> > --- a/daemon/libvirtd.c
> > +++ b/daemon/libvirtd.c
> > @@ -2720,11 +2720,16 @@ qemudSetLogging(struct qemud_server *server, virConfPtr conf,
> >                  const char *filename)
> >  {
> >      int log_level = 0;
> > +    int log_buffer_size = -2;
> >      char *log_filters = NULL;
> >      char *log_outputs = NULL;
> >      char *log_file = NULL;
> >      int ret = -1;
> >  
> > +    GET_CONF_INT (conf, filename, log_buffer_size);
> > +    if (log_buffer_size != -2)
> > +        virLogSetBufferSize(log_buffer_size);
> 
> The possible values here seem a little odd.
> 
>   >   0  -> sets the log buffer size
>   ==  0  -> disables
>   == -2  -> leave at the default
>   <   0  -> disables

  -2 was just a trick to try to get from GET_CONF_INT whether
the configuration file had that setting set or not. I tried to
hint at the problem in the comment to my patch but this just led
to confusion apparently.
  I will just default log_buffer_size to 64 as indicated in
libvirtd.conf and fix the macro to actually get the information out.


> >  /**
> > + * virLogSetBufferSize:
> > + * @size: size of the buffer in kilobytes or 0 to deactivate
> > + *
> > + * Dynamically set the size or desactivate the logging buffer used to keep
> > + * a trace of all recent debug output. Note that the content of the buffer
> > + * is lost if it gets reallocated.
> > + *
> > + * Return -1 in case of failure or 0 in case of success
> > + */
> > +extern int
> > +virLogSetBufferSize(int size) {
> > +    int ret = 0;
> > +    int oldsize;
> > +    char *oldLogBuffer;
> > +
> > +    if (size < 0)
> > +        size = 0;
> 
> IMHO  size should just be 'size_t'. We don't need to have -ve
> values, since '0' already indicates disabled.

  I dislike using size_t for kilobytes as it tend to carry the meaning
that the value is a lenght in byte :

  "This type is used to represent the size of an object."

this is a very good way to get people confused, and we have had byte/kb
confusion in the past already.

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]