summaryrefslogtreecommitdiff
path: root/util/uuid.c
AgeCommit message (Collapse)AuthorFilesLines
2017-12-20util: add is_equal to UUID APIRoman Kagan1-1/+6
It's going to be useful, in particular, in VMBus code massively using uuids aka GUIDs. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> Message-Id: <20171127124355.26015-1-rkagan@virtuozzo.com> Signed-off-by: Fam Zheng <famz@redhat.com>
2016-09-23uuid: Tighten uuid parseFam Zheng1-1/+23
sscanf is relatively loose (tolerate) on some invalid formats that we should fail instead of generating a wrong uuid structure, like with whitespaces and short strings. Add and use a helper function to first check the format. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Message-Id: <1474432046-325-11-git-send-email-famz@redhat.com>
2016-09-23vl: Switch qemu_uuid to QemuUUIDFam Zheng1-5/+6
Update all qemu_uuid users as well, especially get rid of the duplicated low level g_strdup_printf, sscanf and snprintf calls with QEMU UUID API. Since qemu_uuid_parse is quite tangled with qemu_uuid, its switching to QemuUUID is done here too to keep everything in sync and avoid code churn. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Message-Id: <1474432046-325-10-git-send-email-famz@redhat.com>
2016-09-23uuid: Make null_uuid staticFam Zheng1-1/+1
So that it doesn't have to be zeroed at each call. Suggested-by: Eric Blake <eblake@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Message-Id: <1474432046-325-3-git-send-email-famz@redhat.com>
2016-09-23util: Add UUID APIFam Zheng1-0/+91
A number of different places across the code base use CONFIG_UUID. Some of them are soft dependency, some are not built if libuuid is not available, some come with dummy fallback, some throws runtime error. It is hard to maintain, and hard to reason for users. Since UUID is a simple standard with only a small number of operations, it is cleaner to have a central support in libqemuutil. This patch adds qemu_uuid_* functions that all uuid users in the code base can rely on. Except for qemu_uuid_generate which is new code, all other functions are just copy from existing fallbacks from other files. Note that qemu_uuid_parse is moved without updating the function signature to use QemuUUID, to keep this patch simple. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Message-Id: <1474432046-325-2-git-send-email-famz@redhat.com>