qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, qemu-block@nongnu.org,
	sw@weilnetz.de, mdroth@linux.vnet.ibm.com, armbru@redhat.com,
	pbonzini@redhat.com, mreitz@redhat.com, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v8 04/12] vdi: Use QEMU UUID API
Date: Sun, 18 Sep 2016 23:33:33 -0400	[thread overview]
Message-ID: <20160919033333.GD32304@localhost.localdomain> (raw)
In-Reply-To: <1474172732-31994-5-git-send-email-famz@redhat.com>

On Sun, Sep 18, 2016 at 12:25:24PM +0800, Fam Zheng wrote:
> The UUID operations we need from libuuid are fully supported by QEMU UUID
> implementation. Use it, and remove the unused code.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  block/vdi.c | 73 ++++++++++++++-----------------------------------------------
>  1 file changed, 17 insertions(+), 56 deletions(-)
> 
> diff --git a/block/vdi.c b/block/vdi.c
> index 8a1cf97..96b78d5 100644
> --- a/block/vdi.c
> +++ b/block/vdi.c
> @@ -58,14 +58,7 @@
>  #include "migration/migration.h"
>  #include "qemu/coroutine.h"
>  #include "qemu/cutils.h"
> -
> -#if defined(CONFIG_UUID)
> -#include <uuid/uuid.h>
> -#else
> -/* TODO: move uuid emulation to some central place in QEMU. */
> -#include "sysemu/sysemu.h"     /* UUID_FMT */
> -typedef unsigned char uuid_t[16];
> -#endif
> +#include "qemu/uuid.h"
>  
>  /* Code configuration options. */
>  
> @@ -140,28 +133,6 @@ typedef unsigned char uuid_t[16];
>  #define VDI_DISK_SIZE_MAX        ((uint64_t)VDI_BLOCKS_IN_IMAGE_MAX * \
>                                    (uint64_t)DEFAULT_CLUSTER_SIZE)
>  
> -#if !defined(CONFIG_UUID)
> -static inline void uuid_generate(uuid_t out)
> -{
> -    memset(out, 0, sizeof(uuid_t));
> -}
> -
> -static inline int uuid_is_null(const uuid_t uu)
> -{
> -    uuid_t null_uuid = { 0 };
> -    return memcmp(uu, null_uuid, sizeof(uuid_t)) == 0;
> -}
> -
> -# if defined(CONFIG_VDI_DEBUG)
> -static inline void uuid_unparse(const uuid_t uu, char *out)
> -{
> -    snprintf(out, 37, UUID_FMT,
> -            uu[0], uu[1], uu[2], uu[3], uu[4], uu[5], uu[6], uu[7],
> -            uu[8], uu[9], uu[10], uu[11], uu[12], uu[13], uu[14], uu[15]);
> -}
> -# endif
> -#endif
> -
>  typedef struct {
>      char text[0x40];
>      uint32_t signature;
> @@ -182,10 +153,10 @@ typedef struct {
>      uint32_t block_extra;       /* unused here */
>      uint32_t blocks_in_image;
>      uint32_t blocks_allocated;
> -    uuid_t uuid_image;
> -    uuid_t uuid_last_snap;
> -    uuid_t uuid_link;
> -    uuid_t uuid_parent;
> +    QemuUUID uuid_image;
> +    QemuUUID uuid_last_snap;
> +    QemuUUID uuid_link;
> +    QemuUUID uuid_parent;
>      uint64_t unused2[7];
>  } QEMU_PACKED VdiHeader;
>  
> @@ -206,16 +177,6 @@ typedef struct {
>      Error *migration_blocker;
>  } BDRVVdiState;
>  
> -/* Change UUID from little endian (IPRT = VirtualBox format) to big endian
> - * format (network byte order, standard, see RFC 4122) and vice versa.
> - */
> -static void uuid_convert(uuid_t uuid)
> -{
> -    bswap32s((uint32_t *)&uuid[0]);
> -    bswap16s((uint16_t *)&uuid[4]);
> -    bswap16s((uint16_t *)&uuid[6]);
> -}
> -
>  static void vdi_header_to_cpu(VdiHeader *header)
>  {
>      le32_to_cpus(&header->signature);
> @@ -234,10 +195,10 @@ static void vdi_header_to_cpu(VdiHeader *header)
>      le32_to_cpus(&header->block_extra);
>      le32_to_cpus(&header->blocks_in_image);
>      le32_to_cpus(&header->blocks_allocated);
> -    uuid_convert(header->uuid_image);
> -    uuid_convert(header->uuid_last_snap);
> -    uuid_convert(header->uuid_link);
> -    uuid_convert(header->uuid_parent);
> +    qemu_uuid_bswap(&header->uuid_image);
> +    qemu_uuid_bswap(&header->uuid_last_snap);
> +    qemu_uuid_bswap(&header->uuid_link);
> +    qemu_uuid_bswap(&header->uuid_parent);
>  }
>  
>  static void vdi_header_to_le(VdiHeader *header)
> @@ -258,10 +219,10 @@ static void vdi_header_to_le(VdiHeader *header)
>      cpu_to_le32s(&header->block_extra);
>      cpu_to_le32s(&header->blocks_in_image);
>      cpu_to_le32s(&header->blocks_allocated);
> -    uuid_convert(header->uuid_image);
> -    uuid_convert(header->uuid_last_snap);
> -    uuid_convert(header->uuid_link);
> -    uuid_convert(header->uuid_parent);
> +    qemu_uuid_bswap(&header->uuid_image);
> +    qemu_uuid_bswap(&header->uuid_last_snap);
> +    qemu_uuid_bswap(&header->uuid_link);
> +    qemu_uuid_bswap(&header->uuid_parent);
>  }
>  
>  #if defined(CONFIG_VDI_DEBUG)
> @@ -469,11 +430,11 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
>                     (uint64_t)header.blocks_in_image * header.block_size);
>          ret = -ENOTSUP;
>          goto fail;
> -    } else if (!uuid_is_null(header.uuid_link)) {
> +    } else if (!qemu_uuid_is_null(&header.uuid_link)) {
>          error_setg(errp, "unsupported VDI image (non-NULL link UUID)");
>          ret = -ENOTSUP;
>          goto fail;
> -    } else if (!uuid_is_null(header.uuid_parent)) {
> +    } else if (!qemu_uuid_is_null(&header.uuid_parent)) {
>          error_setg(errp, "unsupported VDI image (non-NULL parent UUID)");
>          ret = -ENOTSUP;
>          goto fail;
> @@ -821,8 +782,8 @@ static int vdi_create(const char *filename, QemuOpts *opts, Error **errp)
>      if (image_type == VDI_TYPE_STATIC) {
>          header.blocks_allocated = blocks;
>      }
> -    uuid_generate(header.uuid_image);
> -    uuid_generate(header.uuid_last_snap);
> +    qemu_uuid_generate(&header.uuid_image);
> +    qemu_uuid_generate(&header.uuid_last_snap);
>      /* There is no need to set header.uuid_link or header.uuid_parent here. */
>  #if defined(CONFIG_VDI_DEBUG)
>      vdi_header_print(&header);
> -- 
> 2.7.4
> 
> 
Reviewed-by: Jeff Cody <jcody@redhat.com>

  reply	other threads:[~2016-09-19  3:33 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-18  4:25 [Qemu-devel] [PATCH v8 00/12] UUID clean ups for 2.8 Fam Zheng
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 01/12] util: Add UUID API Fam Zheng
2016-09-19  3:30   ` Jeff Cody
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 02/12] uuid: Make null_uuid static Fam Zheng
2016-09-19  3:31   ` Jeff Cody
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 03/12] vhdx: Use QEMU UUID API Fam Zheng
2016-09-19  3:33   ` Jeff Cody
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 04/12] vdi: " Fam Zheng
2016-09-19  3:33   ` Jeff Cody [this message]
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 05/12] vpc: " Fam Zheng
2016-09-19  3:33   ` Jeff Cody
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 06/12] crypto: Switch to " Fam Zheng
2016-09-19  3:34   ` Jeff Cody
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 07/12] tests: No longer dependent on CONFIG_UUID Fam Zheng
2016-09-19  3:34   ` Jeff Cody
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 08/12] configure: Remove detection code for UUID Fam Zheng
2016-09-19  3:34   ` Jeff Cody
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 09/12] vl: Switch qemu_uuid to QemuUUID Fam Zheng
2016-09-19  3:34   ` Jeff Cody
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 10/12] uuid: Tighten uuid parse Fam Zheng
2016-09-19  3:44   ` Jeff Cody
2016-09-19 20:30   ` Eric Blake
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 11/12] tests: Add uuid tests Fam Zheng
2016-09-19  3:44   ` Jeff Cody
2016-09-20 15:37   ` Eric Blake
2016-09-21  3:32     ` Fam Zheng
2016-09-18  4:25 ` [Qemu-devel] [PATCH v8 12/12] Add UUID files to MAINTAINERS Fam Zheng
2016-09-19  3:44   ` Jeff Cody

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=20160919033333.GD32304@localhost.localdomain \
    --to=jcody@redhat.com \
    --cc=armbru@redhat.com \
    --cc=famz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).