[libvirt] [PATCH 1/6] Introduce virTimeMs for getting current time in ms

Jiri Denemark jdenemar at redhat.com
Mon Jun 13 09:31:06 UTC 2011


On Thu, Jun 09, 2011 at 16:06:48 +0200, Michal Privoznik wrote:
> On 07.06.2011 15:01, Jiri Denemark wrote:
> > ---
> >  src/libvirt_private.syms |    1 +
> >  src/util/util.c          |   24 ++++++++++++++++++++++++
> >  src/util/util.h          |    2 ++
> >  3 files changed, 27 insertions(+), 0 deletions(-)
> > 
> > diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> > index e6ab870..2415a89 100644
> > --- a/src/libvirt_private.syms
> > +++ b/src/libvirt_private.syms
> > @@ -1027,6 +1027,7 @@ virStrToLong_ul;
> >  virStrToLong_ull;
> >  virStrcpy;
> >  virStrncpy;
> > +virTimeMs;
> >  virTimestamp;
> >  virVasprintf;
> >  
> > diff --git a/src/util/util.c b/src/util/util.c
> > index e221abe..d758cf9 100644
> > --- a/src/util/util.c
> > +++ b/src/util/util.c
> > @@ -3117,6 +3117,30 @@ virTimestamp(void)
> >      return timestamp;
> >  }
> >  
> > +#define timeval_to_ms(tv)   (((tv).tv_sec * 1000ull) + ((tv).tv_usec / 1000))
> What about making this in util.h so we can have only one definition and
> then cleanup src/qemu/qemu_domain.c:48, src/qemu/qemu_driver.c:116,
> src/qemu/qemu_migration.c:49?

Nope, one of the reasons for virTimeMs is to get rid of timeval_to_ms usage in
those files (which is done by patch 2/6).

> > --- a/src/util/util.h
> > +++ b/src/util/util.h
> > @@ -286,6 +286,8 @@ int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL;
> >  
> >  char *virTimestamp(void);
> >  
> > +int virTimeMs(unsigned long long *ms);
> I'd add ATTRIBUTE_NONNULL(1); here.

Added and pushed, thanks.

Jirka




More information about the libvir-list mailing list