From: Fam Zheng <famz@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, qemu-block@nongnu.org,
sw@weilnetz.de, jcody@redhat.com, mdroth@linux.vnet.ibm.com,
armbru@redhat.com, pbonzini@redhat.com, mreitz@redhat.com,
rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v6 1/9] util: Add UUID API
Date: Sun, 18 Sep 2016 09:46:27 +0800 [thread overview]
Message-ID: <20160918014627.GA23821@lemon> (raw)
In-Reply-To: <9958a7dc-29b6-1fd6-f740-8ab5177403f7@redhat.com>
On Sat, 09/17 16:29, Eric Blake wrote:
> On 08/17/2016 02:28 AM, Fam Zheng wrote:
> > 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_* the functions so that all uuid users in the code base can
>
> s/the functions so/functions/
>
> > 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>
> > ---
>
> > +++ b/include/qemu/uuid.h
> > @@ -0,0 +1,59 @@
> > +/*
> > + * QEMU UUID functions
> > + *
> > + * Copyright 2016 Red Hat, Inc.,
>
> Why the trailing comma?
Simply a typo. Will fix.
>
> > +++ b/util/uuid.c
> > @@ -0,0 +1,92 @@
> > +/*
> > + * QEMU UUID functions
> > + *
> > + * Copyright 2016 Red Hat, Inc.,
>
> copy-and-paste? :)
>
>
> > +
> > +#include "qemu/osdep.h"
> > +#include "qemu-common.h"
> > +#include "qemu/uuid.h"
> > +#include "qemu/bswap.h"
> > +#include <glib.h>
>
> Do you still need the <glib.h> header here? And if so, shouldn't it be
> right after osdep.h?
Yes, it will be removed.
>
> > +
> > +void qemu_uuid_generate(QemuUUID *uuid)
> > +{
> > + int i;
> > + uint32_t tmp[4];
> > +
> > + QEMU_BUILD_BUG_ON(sizeof(QemuUUID) != 16);
> > +
> > + for (i = 0; i < 4; ++i) {
> > + tmp[i] = g_random_int();
> > + }
> > + memcpy(uuid, tmp, sizeof(tmp));
> > + /* Set the two most significant bits (bits 6 and 7) of the
> > + clock_seq_hi_and_reserved to zero and one, respectively. */
> > + uuid->data[8] = (uuid->data[8] & 0x3f) | 0x80;
> > + /* Set the four most significant bits (bits 12 through 15) of the
> > + time_hi_and_version field to the 4-bit version number.
> > + */
> > + uuid->data[6] = (uuid->data[6] & 0xf) | 0x40;
> > +}
>
> Looks okay.
>
> > +
> > +int qemu_uuid_is_null(const QemuUUID *uu)
> > +{
> > + QemuUUID null_uuid = { 0 };
>
> Could make this static, so that it doesn't have to be zeroed on every
> entry to this function (but in a separate patch, since this one just
> moved it, right?)
Sure, will do.
>
> > + return memcmp(uu, &null_uuid, sizeof(QemuUUID)) == 0;
> > +}
> > +
>
> Once the nits are cleaned up, you can add:
> Reviewed-by: Eric Blake <eblake@redhat.com>
Thanks!
Fam
next prev parent reply other threads:[~2016-09-18 1:46 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-17 7:28 [Qemu-devel] [PATCH v6 0/9] UUID clean ups for 2.8 Fam Zheng
2016-08-17 7:28 ` [Qemu-devel] [PATCH v6 1/9] util: Add UUID API Fam Zheng
2016-09-17 21:29 ` Eric Blake
2016-09-18 1:46 ` Fam Zheng [this message]
2016-08-17 7:28 ` [Qemu-devel] [PATCH v6 2/9] vhdx: Use QEMU " Fam Zheng
2016-09-17 21:31 ` Eric Blake
2016-08-17 7:28 ` [Qemu-devel] [PATCH v6 3/9] vdi: " Fam Zheng
2016-09-17 21:32 ` Eric Blake
2016-09-18 5:48 ` Stefan Weil
2016-08-17 7:28 ` [Qemu-devel] [PATCH v6 4/9] vpc: " Fam Zheng
2016-09-17 21:33 ` Eric Blake
2016-08-17 7:28 ` [Qemu-devel] [PATCH v6 5/9] crypto: Switch to " Fam Zheng
2016-09-17 21:34 ` Eric Blake
2016-08-17 7:28 ` [Qemu-devel] [PATCH v6 6/9] tests: No longer dependent on CONFIG_UUID Fam Zheng
2016-09-17 21:34 ` Eric Blake
2016-08-17 7:28 ` [Qemu-devel] [PATCH v6 7/9] configure: Remove detection code for UUID Fam Zheng
2016-09-17 21:35 ` Eric Blake
2016-08-17 7:28 ` [Qemu-devel] [PATCH v6 8/9] vl: Switch qemu_uuid to QemuUUID Fam Zheng
2016-09-17 21:38 ` Eric Blake
2016-09-17 21:50 ` Eric Blake
2016-08-17 7:28 ` [Qemu-devel] [PATCH v6 9/9] tests: Add uuid tests Fam Zheng
2016-09-17 22:02 ` Eric Blake
2016-09-03 5:07 ` [Qemu-devel] [PATCH v6 0/9] UUID clean ups for 2.8 Fam Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160918014627.GA23821@lemon \
--to=famz@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.