Signed-off-by: Shi Lei <shi_lei@xxxxxxxxxxxxxx> --- src/util/viruuid.c | 31 +++++++++++++++++++++++++++++++ src/util/viruuid.h | 18 ++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/src/util/viruuid.c b/src/util/viruuid.c index 558fbb9c..c6e6272f 100644 --- a/src/util/viruuid.c +++ b/src/util/viruuid.c @@ -134,6 +134,18 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid) return 0; } + +int +virUUIDParseXML(const char *uuidstr, + virUUID *puuid, + const char *instname G_GNUC_UNUSED, + void *parent G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED) +{ + return virUUIDParse(uuidstr, *puuid); +} + + /** * virUUIDFormat: * @uuid: array of VIR_UUID_BUFLEN bytes to store the raw UUID @@ -159,6 +171,20 @@ virUUIDFormat(const unsigned char *uuid, char *uuidstr) } +int +virUUIDFormatBuf(virBuffer *buf, + const char *fmt, + const virUUID *puuid, + const void *parent G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED) +{ + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(*puuid, uuidstr); + virBufferAsprintf(buf, fmt, uuidstr); + + return 0; +} + /** * virUUIDIsValid @@ -263,3 +289,8 @@ int virGetHostUUID(unsigned char *uuid) return ret; } + +void virUUIDClear(virUUID *puuid G_GNUC_UNUSED) +{ + memset(*puuid, 0, VIR_UUID_BUFLEN); +} diff --git a/src/util/viruuid.h b/src/util/viruuid.h index b403b190..36766356 100644 --- a/src/util/viruuid.h +++ b/src/util/viruuid.h @@ -21,6 +21,7 @@ #pragma once #include "internal.h" +#include "virbuffer.h" /** @@ -39,6 +40,7 @@ } \ } while (0) +typedef unsigned char virUUID[VIR_UUID_BUFLEN]; int virSetHostUUIDStr(const char *host_uuid); int virGetHostUUID(unsigned char *host_uuid) ATTRIBUTE_NONNULL(1) G_GNUC_NO_INLINE; @@ -51,5 +53,21 @@ int virUUIDParse(const char *uuidstr, unsigned char *uuid) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; +int +virUUIDParseXML(const char *uuidstr, + virUUID *puuid, + const char *instname, + void *parent, + void *opaque); + const char *virUUIDFormat(const unsigned char *uuid, char *uuidstr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + +int +virUUIDFormatBuf(virBuffer *buf, + const char *fmt, + const virUUID *puuid, + const void *parent, + void *opaque); + +void virUUIDClear(virUUID *puuid); -- 2.25.1