On Tue, Jan 23, 2007 at 12:59:49PM +0000, Daniel P. Berrange wrote:
On Tue, Jan 23, 2007 at 12:37:50PM +0000, Mark McLoughlin wrote:
> On Tue, 2007-01-23 at 11:20 +0100, Karel Zak wrote:
>
> > + char uuid[37];
> >
> > Magic number? :-)
> >
> > #define UUID_STRLEN 36
> >
> > char uuid[UUID_STRLEN+1];
>
> Good point. Here's a proposed API addition to put the buffer lengths as
> macros in libvirt.h.
>
> Anyone got objections to that?
No objections, but I think if we're going to do this, we should take it
one step further and provide APIs for converting between RAW & Printable
versions of UUID in both directions. Currently we're just duping this
conversion code all over the place - with inconsistent use of '-' in
the printable versions.
/*
* uuidstr: the printable UUID string
* uuid: pre-allocated buffer of length VIR_UUID_BUFLEN
*/
int virUUIDParseString(const char *uuidstr, unsigned char *uuid)
/*
* uuid: the raw UUID valu exactly VIR_UUID_BUFLEN bytes long
* uuidstr: pre-allocated buffer of length VIR_UUID_STRING_BUFLEN
* to be filled in printable UUID
*/
int virUUIDFormatString(const unsigned char *uuid, char *uuidstr)
Oh and a thing to generate a random UUID too is needed by both the xm_internal
and qemu & test backends
int virUUIDGenerate(unsigned char *uuid);
Probably we only need any of this stuff in the internal headers though, rather
than public facing
Mark's patch extend the public API, that's fine, but I think the conversion
internally should be private. IMHO that's part of the many think we identified
to go in /lib/ shared code.
Daniel
--
Red Hat Virtualization group
http://redhat.com/virtualization/
Daniel Veillard | virtualization library
http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit
http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/