tools/blktap2: push uuid wrapper functions down into libvhd.
authorIan Campbell <ian.campbell@citrix.com>
Thu, 17 Mar 2011 19:13:53 +0000 (19:13 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 17 Mar 2011 19:13:53 +0000 (19:13 +0000)
Nothing else uses them.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/blktap2/drivers/block-vhd.c
tools/blktap2/include/blk_uuid.h [deleted file]
tools/blktap2/include/libvhd-journal.h
tools/blktap2/include/libvhd.h
tools/blktap2/include/vhd-uuid.h [new file with mode: 0644]
tools/blktap2/include/vhd.h
tools/blktap2/vhd/lib/libvhd-journal.c
tools/blktap2/vhd/lib/libvhd.c
tools/blktap2/vhd/lib/vhd-util-check.c
tools/blktap2/vhd/lib/vhd-util-read.c

index 649664a8a51cf3ccbd4f382cb857c36f76c826c8..76ea5bd4f16187e7b40b3931453fdbcc6c160b09 100644 (file)
@@ -807,7 +807,7 @@ vhd_validate_parent(td_driver_t *child_driver,
        }
        */
 
-       if (blk_uuid_compare(&child->vhd.header.prt_uuid, &parent->vhd.footer.uuid)) {
+       if (vhd_uuid_compare(&child->vhd.header.prt_uuid, &parent->vhd.footer.uuid)) {
                DPRINTF("ERROR: %s: %s, %s: parent uuid has changed since "
                        "snapshot.  Child image no longer valid.\n",
                        __func__, child->vhd.file, parent->vhd.file);
diff --git a/tools/blktap2/include/blk_uuid.h b/tools/blktap2/include/blk_uuid.h
deleted file mode 100644 (file)
index 9d554a9..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/* Copyright (c) 2008, XenSource Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in the
- *       documentation and/or other materials provided with the distribution.
- *     * Neither the name of XenSource Inc. nor the names of its contributors
- *       may be used to endorse or promote products derived from this software
- *       without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-#ifndef __BLKTAP2_UUID_H__
-#define __BLKTAP2_UUID_H__
-
-#if defined(__linux__)
-
-#include <uuid/uuid.h>
-
-typedef struct {
-    uuid_t uuid;
-} blk_uuid_t;
-
-static inline int blk_uuid_is_nil(blk_uuid_t *uuid)
-{
-       return uuid_is_null(uuid->uuid);
-}
-
-static inline void blk_uuid_generate(blk_uuid_t *uuid)
-{
-       uuid_generate(uuid->uuid);
-}
-
-static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out, size_t size)
-{
-       uuid_unparse(uuid->uuid, out);
-}
-
-static inline void blk_uuid_from_string(blk_uuid_t *uuid, const char *in)
-{
-       uuid_parse(in, uuid->uuid);
-}
-
-static inline void blk_uuid_copy(blk_uuid_t *dst, blk_uuid_t *src)
-{
-       uuid_copy(dst->uuid, src->uuid);
-}
-
-static inline void blk_uuid_clear(blk_uuid_t *uuid)
-{
-       uuid_clear(uuid->uuid);
-}
-
-static inline int blk_uuid_compare(blk_uuid_t *uuid1, blk_uuid_t *uuid2)
-{
-       return uuid_compare(uuid1->uuid, uuid2->uuid);
-}
-
-#elif defined(__NetBSD__)
-
-#include <uuid.h>
-#include <string.h>
-#include <stdlib.h>
-
-typedef uuid_t blk_uuid_t;
-
-static inline int blk_uuid_is_nil(blk_uuid_t *uuid)
-{
-       uint32_t status;
-       return uuid_is_nil((uuid_t *)uuid, &status);
-}
-
-static inline void blk_uuid_generate(blk_uuid_t *uuid)
-{
-       uint32_t status;
-       uuid_create((uuid_t *)uuid, &status);
-}
-
-static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out, size_t size)
-{
-       uint32_t status;
-       char *_out = NULL;
-       uuid_to_string((uuid_t *)uuid, &_out, &status);
-       strlcpy(out, _out, size);
-       free(_out);
-}
-
-static inline void blk_uuid_from_string(blk_uuid_t *uuid, const char *in)
-{
-       uint32_t status;
-       uuid_from_string(in, (uuid_t *)uuid, &status);
-}
-
-static inline void blk_uuid_copy(blk_uuid_t *dst, blk_uuid_t *src)
-{
-       memcpy((uuid_t *)dst, (uuid_t *)src, sizeof(uuid_t));
-}
-
-static inline void blk_uuid_clear(blk_uuid_t *uuid)
-{
-       memset((uuid_t *)uuid, 0, sizeof(uuid_t));
-}
-
-static inline int blk_uuid_compare(blk_uuid_t *uuid1, blk_uuid_t *uuid2)
-{
-       uint32_t status;
-       return uuid_compare((uuid_t *)uuid1, (uuid_t *)uuid2, &status);
-}
-
-#else
-
-#error "Please update blk_uuid.h for your OS"
-
-#endif
-
-#endif /* __BLKTAP2_UUID_H__ */
index 75852523c9f0469694a8c54106836b0c78cb4b85..78e45a2c240cc3cadc6e426fe4bd081cc6bbe62c 100644 (file)
@@ -39,7 +39,7 @@
 
 typedef struct vhd_journal_header {
        char                       cookie[8];
-       blk_uuid_t                 uuid;
+       vhd_uuid_t                 uuid;
        uint64_t                   vhd_footer_offset;
        uint32_t                   journal_data_entries;
        uint32_t                   journal_metadata_entries;
index ac6908415eea41e9eb7f6ef17addb7cebc5d5495..8e854e413f7aa8b867b28c35500ec33ac2eedb9c 100644 (file)
@@ -36,7 +36,7 @@
 #include <sys/bswap.h>
 #endif
 
-#include "blk_uuid.h"
+#include "vhd-uuid.h"
 #include "vhd.h"
 
 #ifndef O_LARGEFILE
@@ -216,7 +216,7 @@ vhd_parent_locator_size(vhd_parent_locator_t *loc)
 static inline int
 vhd_parent_raw(vhd_context_t *ctx)
 {
-       return blk_uuid_is_nil(&ctx->header.prt_uuid);
+       return vhd_uuid_is_nil(&ctx->header.prt_uuid);
 }
 
 void libvhd_set_log_level(int);
diff --git a/tools/blktap2/include/vhd-uuid.h b/tools/blktap2/include/vhd-uuid.h
new file mode 100644 (file)
index 0000000..655ea8f
--- /dev/null
@@ -0,0 +1,130 @@
+/* Copyright (c) 2008, XenSource Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of XenSource Inc. nor the names of its contributors
+ *       may be used to endorse or promote products derived from this software
+ *       without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#ifndef __BLKTAP2_VHD_UUID_H__
+#define __BLKTAP2_VHDUUID_H__
+
+#if defined(__linux__)
+
+#include <uuid/uuid.h>
+
+typedef struct {
+    uuid_t uuid;
+} vhd_uuid_t;
+
+static inline int vhd_uuid_is_nil(vhd_uuid_t *uuid)
+{
+       return uuid_is_null(uuid->uuid);
+}
+
+static inline void vhd_uuid_generate(vhd_uuid_t *uuid)
+{
+       uuid_generate(uuid->uuid);
+}
+
+static inline void vhd_uuid_to_string(vhd_uuid_t *uuid, char *out, size_t size)
+{
+       uuid_unparse(uuid->uuid, out);
+}
+
+static inline void vhd_uuid_from_string(vhd_uuid_t *uuid, const char *in)
+{
+       uuid_parse(in, uuid->uuid);
+}
+
+static inline void vhd_uuid_copy(vhd_uuid_t *dst, vhd_uuid_t *src)
+{
+       uuid_copy(dst->uuid, src->uuid);
+}
+
+static inline void vhd_uuid_clear(vhd_uuid_t *uuid)
+{
+       uuid_clear(uuid->uuid);
+}
+
+static inline int vhd_uuid_compare(vhd_uuid_t *uuid1, vhd_uuid_t *uuid2)
+{
+       return uuid_compare(uuid1->uuid, uuid2->uuid);
+}
+
+#elif defined(__NetBSD__)
+
+#include <uuid.h>
+#include <string.h>
+#include <stdlib.h>
+
+typedef uuid_t vhd_uuid_t;
+
+static inline int vhd_uuid_is_nil(vhd_uuid_t *uuid)
+{
+       uint32_t status;
+       return uuid_is_nil((uuid_t *)uuid, &status);
+}
+
+static inline void vhd_uuid_generate(vhd_uuid_t *uuid)
+{
+       uint32_t status;
+       uuid_create((uuid_t *)uuid, &status);
+}
+
+static inline void vhd_uuid_to_string(vhd_uuid_t *uuid, char *out, size_t size)
+{
+       uint32_t status;
+       char *_out = NULL;
+       uuid_to_string((uuid_t *)uuid, &_out, &status);
+       strlcpy(out, _out, size);
+       free(_out);
+}
+
+static inline void vhd_uuid_from_string(vhd_uuid_t *uuid, const char *in)
+{
+       uint32_t status;
+       uuid_from_string(in, (uuid_t *)uuid, &status);
+}
+
+static inline void vhd_uuid_copy(vhd_uuid_t *dst, vhd_uuid_t *src)
+{
+       memcpy((uuid_t *)dst, (uuid_t *)src, sizeof(uuid_t));
+}
+
+static inline void vhd_uuid_clear(vhd_uuid_t *uuid)
+{
+       memset((uuid_t *)uuid, 0, sizeof(uuid_t));
+}
+
+static inline int vhd_uuid_compare(vhd_uuid_t *uuid1, vhd_uuid_t *uuid2)
+{
+       uint32_t status;
+       return uuid_compare((uuid_t *)uuid1, (uuid_t *)uuid2, &status);
+}
+
+#else
+
+#error "Please update vhd-uuid.h for your OS"
+
+#endif
+
+#endif /* __BLKTAP2_VHD_UUID_H__ */
index a31aadf491e79ff457d0123916c283c4ca145eb7..c06442545bc03f3758315f932483fac17ab7aa7b 100644 (file)
@@ -59,7 +59,7 @@ struct hd_ftr {
   u32    geometry;        /* Disk geometry                                */
   u32    type;            /* Disk type                                    */
   u32    checksum;        /* 1's comp sum of this struct.                 */
-  blk_uuid_t uuid;        /* Unique disk ID, used for naming parents      */
+  vhd_uuid_t uuid;        /* Unique disk ID, used for naming parents      */
   char   saved;           /* one-bit -- is this disk/VM in a saved state? */
   char   hidden;          /* tapdisk-specific field: is this vdi hidden?  */
   char   reserved[426];   /* padding                                      */
@@ -147,7 +147,7 @@ struct dd_hdr {
   u32    max_bat_size;    /* Maximum number of entries in the BAT         */
   u32    block_size;      /* Block size in bytes. Must be power of 2.     */
   u32    checksum;        /* Header checksum.  1's comp of all fields.    */
-  blk_uuid_t prt_uuid;    /* ID of the parent disk.                       */
+  vhd_uuid_t prt_uuid;    /* ID of the parent disk.                       */
   u32    prt_ts;          /* Modification time of the parent disk         */
   u32    res1;            /* Reserved.                                    */
   char   prt_name[512];   /* Parent unicode name.                         */
index 24383ff62b299cbca0fb3016e73f37bf82b02f72..7edd182dc36811728df1cbd90c88b253623992a5 100644 (file)
@@ -237,7 +237,7 @@ vhd_journal_add_journal_header(vhd_journal_t *j)
        if (err)
                return err;
 
-       blk_uuid_copy(&j->header.uuid, &vhd->footer.uuid);
+       vhd_uuid_copy(&j->header.uuid, &vhd->footer.uuid);
        memcpy(j->header.cookie,
               VHD_JOURNAL_HEADER_COOKIE, sizeof(j->header.cookie));
        j->header.vhd_footer_offset = off - sizeof(vhd_footer_t);
index bc9649a639653988307a12fed8c64d1fbdf0046f..3511cb4f80274f788f10bac16604a7fc04edc8b2 100644 (file)
@@ -2454,7 +2454,7 @@ vhd_initialize_footer(vhd_context_t *ctx, int type, uint64_t size)
        ctx->footer.saved        = 0;
        ctx->footer.data_offset  = 0xFFFFFFFFFFFFFFFF;
        strcpy(ctx->footer.crtr_app, "tap");
-       blk_uuid_generate(&ctx->footer.uuid);
+       vhd_uuid_generate(&ctx->footer.uuid);
 }
 
 static int
@@ -2569,7 +2569,7 @@ vhd_initialize_header(vhd_context_t *ctx, const char *parent_path,
                        return err;
 
                ctx->header.prt_ts = vhd_time(stats.st_mtime);
-               blk_uuid_copy(&ctx->header.prt_uuid, &parent.footer.uuid);
+               vhd_uuid_copy(&ctx->header.prt_uuid, &parent.footer.uuid);
                if (!size)
                        size = parent.footer.curr_size;
                vhd_close(&parent);
@@ -2651,7 +2651,7 @@ vhd_change_parent(vhd_context_t *child, char *parent_path, int raw)
        }
 
        if (raw) {
-               blk_uuid_clear(&child->header.prt_uuid);
+               vhd_uuid_clear(&child->header.prt_uuid);
        } else {
                err = vhd_open(&parent, ppath, VHD_OPEN_RDONLY);
                if (err) {
@@ -2659,7 +2659,7 @@ vhd_change_parent(vhd_context_t *child, char *parent_path, int raw)
                               ppath, child->file, err);
                        goto out;
                }
-               blk_uuid_copy(&child->header.prt_uuid, &parent.footer.uuid);
+               vhd_uuid_copy(&child->header.prt_uuid, &parent.footer.uuid);
                vhd_close(&parent);
        }
 
index 59a1a4732930deb954679911c3f4cba36cc5af67..af07426d5b637d63345a9c1e1ed2a86172b78e5c 100644 (file)
@@ -218,7 +218,7 @@ vhd_util_check_validate_differencing_header(vhd_context_t *vhd)
                if (vhd_util_check_zeros(header->loc, sizeof(header->loc)))
                        return "invalid non-null parent locators";
 
-               if (!blk_uuid_is_nil(&header->prt_uuid))
+               if (!vhd_uuid_is_nil(&header->prt_uuid))
                        return "invalid non-null parent uuid";
 
                if (header->prt_ts)
@@ -320,7 +320,7 @@ vhd_util_check_validate_parent(vhd_context_t *vhd, const char *ppath)
                                VHD_OPEN_RDONLY | VHD_OPEN_IGNORE_DISABLED))
                return "error opening parent";
 
-       if (blk_uuid_compare(&vhd->header.prt_uuid, &parent.footer.uuid)) {
+       if (vhd_uuid_compare(&vhd->header.prt_uuid, &parent.footer.uuid)) {
                msg = "invalid parent uuid";
                goto out;
        }
index 2e8dc8b786f9aca5f0acb7932375b7ccd502934e..ac4d833cbc819f700b9c421ca557e15bcdb4f98c 100644 (file)
@@ -78,7 +78,7 @@ vhd_print_header(vhd_context_t *vhd, vhd_header_t *h, int hex)
               (err ? "failed to read name" : name));
        free(name);
 
-       blk_uuid_to_string(&h->prt_uuid, uuid, sizeof(uuid));
+       vhd_uuid_to_string(&h->prt_uuid, uuid, sizeof(uuid));
        printf("Parent UUID         : %s\n", uuid);
     
        vhd_time_to_string(h->prt_ts, time_str);
@@ -153,7 +153,7 @@ vhd_print_footer(vhd_footer_t *f, int hex)
        printf("Checksum            : 0x%x|0x%x (%s)\n", f->checksum, cksm,
                f->checksum == cksm ? "Good!" : "Bad!");
 
-       blk_uuid_to_string(&f->uuid, uuid, sizeof(uuid));
+       vhd_uuid_to_string(&f->uuid, uuid, sizeof(uuid));
        printf("UUID                : %s\n", uuid);
 
        printf("Saved state         : %s\n", f->saved == 0 ? "No" : "Yes");