Ian Campbell
2011-Mar-15 16:16 UTC
[Xen-devel] [PATCH 0 of 4] tools: build system fix indirect library usage and --as-needed
This series arranges for all libraries and binaries to only link against those shared libraries which they use directly, relying on the dynamic linker to do the right thing for indirect dependencies. In order to do this I''ve pushed the tools/blktap2 UUID abstraction down into libvhd and out of line to encapsulate all knowledge regarding this abstraction into libvhd rather than expecting the users of the library to do the right thing. Having done this supporting --as-needed becomes a pretty trivial case of ensuring links lines have the libraries in the correct order. Tested by: * running xl, start/stop a guest * running xend, start/stop a guest * manually importing each python extension and calling whatever initialisation function I could find. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Mar-15 16:16 UTC
[Xen-devel] [PATCH 1 of 4] tools/blktap2: push uuid wrapper functions down into libvhd
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1300201970 0 # Node ID 83a1d6598fa3617085baecec1cda1e4caa518c92 # Parent 452c744798f4bb73d9a2286ac03971a48ab275a1 tools/blktap2: push uuid wrapper functions down into libvhd. Nothing else uses them. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 452c744798f4 -r 83a1d6598fa3 tools/blktap2/drivers/block-vhd.c --- a/tools/blktap2/drivers/block-vhd.c Tue Mar 15 14:42:17 2011 +0000 +++ b/tools/blktap2/drivers/block-vhd.c Tue Mar 15 15:12:50 2011 +0000 @@ -807,7 +807,7 @@ vhd_validate_parent(td_driver_t *child_d } */ - 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 -r 452c744798f4 -r 83a1d6598fa3 tools/blktap2/include/blk_uuid.h --- a/tools/blktap2/include/blk_uuid.h Tue Mar 15 14:42:17 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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__ */ diff -r 452c744798f4 -r 83a1d6598fa3 tools/blktap2/include/libvhd-journal.h --- a/tools/blktap2/include/libvhd-journal.h Tue Mar 15 14:42:17 2011 +0000 +++ b/tools/blktap2/include/libvhd-journal.h Tue Mar 15 15:12:50 2011 +0000 @@ -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; diff -r 452c744798f4 -r 83a1d6598fa3 tools/blktap2/include/libvhd.h --- a/tools/blktap2/include/libvhd.h Tue Mar 15 14:42:17 2011 +0000 +++ b/tools/blktap2/include/libvhd.h Tue Mar 15 15:12:50 2011 +0000 @@ -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 @@ static inline int 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 -r 452c744798f4 -r 83a1d6598fa3 tools/blktap2/include/vhd-uuid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/blktap2/include/vhd-uuid.h Tue Mar 15 15:12:50 2011 +0000 @@ -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__ */ diff -r 452c744798f4 -r 83a1d6598fa3 tools/blktap2/include/vhd.h --- a/tools/blktap2/include/vhd.h Tue Mar 15 14:42:17 2011 +0000 +++ b/tools/blktap2/include/vhd.h Tue Mar 15 15:12:50 2011 +0000 @@ -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. */ diff -r 452c744798f4 -r 83a1d6598fa3 tools/blktap2/vhd/lib/libvhd-journal.c --- a/tools/blktap2/vhd/lib/libvhd-journal.c Tue Mar 15 14:42:17 2011 +0000 +++ b/tools/blktap2/vhd/lib/libvhd-journal.c Tue Mar 15 15:12:50 2011 +0000 @@ -237,7 +237,7 @@ vhd_journal_add_journal_header(vhd_journ 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); diff -r 452c744798f4 -r 83a1d6598fa3 tools/blktap2/vhd/lib/libvhd.c --- a/tools/blktap2/vhd/lib/libvhd.c Tue Mar 15 14:42:17 2011 +0000 +++ b/tools/blktap2/vhd/lib/libvhd.c Tue Mar 15 15:12:50 2011 +0000 @@ -2454,7 +2454,7 @@ vhd_initialize_footer(vhd_context_t *ctx 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 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, } 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, 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); } diff -r 452c744798f4 -r 83a1d6598fa3 tools/blktap2/vhd/lib/vhd-util-check.c --- a/tools/blktap2/vhd/lib/vhd-util-check.c Tue Mar 15 14:42:17 2011 +0000 +++ b/tools/blktap2/vhd/lib/vhd-util-check.c Tue Mar 15 15:12:50 2011 +0000 @@ -218,7 +218,7 @@ vhd_util_check_validate_differencing_hea 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_conte 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; } diff -r 452c744798f4 -r 83a1d6598fa3 tools/blktap2/vhd/lib/vhd-util-read.c --- a/tools/blktap2/vhd/lib/vhd-util-read.c Tue Mar 15 14:42:17 2011 +0000 +++ b/tools/blktap2/vhd/lib/vhd-util-read.c Tue Mar 15 15:12:50 2011 +0000 @@ -78,7 +78,7 @@ vhd_print_header(vhd_context_t *vhd, vhd (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 he 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"); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Mar-15 16:16 UTC
[Xen-devel] [PATCH 2 of 4] tools/blktap2/libvhd: move uuid wrapper functions out of line
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1300202108 0 # Node ID 75db4a775805fbdcb5013427661d94db1b7b17fc # Parent 83a1d6598fa3617085baecec1cda1e4caa518c92 tools/blktap2/libvhd: move uuid wrapper functions out of line. This isolates users of libvhd from the need to know about the different OS schemes for UUIDs. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 83a1d6598fa3 -r 75db4a775805 tools/blktap2/include/vhd-uuid.h --- a/tools/blktap2/include/vhd-uuid.h Tue Mar 15 15:12:50 2011 +0000 +++ b/tools/blktap2/include/vhd-uuid.h Tue Mar 15 15:15:08 2011 +0000 @@ -25,101 +25,20 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __BLKTAP2_VHD_UUID_H__ -#define __BLKTAP2_VHDUUID_H__ +#define __BLKTAP2_VHD_UUID_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 @@ -127,4 +46,18 @@ static inline int vhd_uuid_compare(vhd_u #endif +int vhd_uuid_is_nil(vhd_uuid_t *uuid); + +void vhd_uuid_generate(vhd_uuid_t *uuid); + +void vhd_uuid_to_string(vhd_uuid_t *uuid, char *out, size_t size); + +void vhd_uuid_from_string(vhd_uuid_t *uuid, const char *in); + +void vhd_uuid_copy(vhd_uuid_t *dst, vhd_uuid_t *src); + +void vhd_uuid_clear(vhd_uuid_t *uuid); + +int vhd_uuid_compare(vhd_uuid_t *uuid1, vhd_uuid_t *uuid2); + #endif /* __BLKTAP2_VHD_UUID_H__ */ diff -r 83a1d6598fa3 -r 75db4a775805 tools/blktap2/vhd/lib/Makefile --- a/tools/blktap2/vhd/lib/Makefile Tue Mar 15 15:12:50 2011 +0000 +++ b/tools/blktap2/vhd/lib/Makefile Tue Mar 15 15:15:08 2011 +0000 @@ -42,6 +42,7 @@ LIB-SRCS += vhd-util-snapshot.c LIB-SRCS += vhd-util-snapshot.c LIB-SRCS += vhd-util-scan.c LIB-SRCS += vhd-util-check.c +LIB-SRCS += vhd-util-uuid.c LIB-SRCS += relative-path.c LIB-SRCS += atomicio.c diff -r 83a1d6598fa3 -r 75db4a775805 tools/blktap2/vhd/lib/vhd-util-uuid.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/blktap2/vhd/lib/vhd-util-uuid.c Tue Mar 15 15:15:08 2011 +0000 @@ -0,0 +1,128 @@ + /* Copyright (c) 2008, XenSource Inc. + * Copyright (c) 2011, Citrix + * + * 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. + */ + +#if defined(__linux__) + +#include <uuid/uuid.h> + +typedef struct { + uuid_t uuid; +} vhd_uuid_t; + +int vhd_uuid_is_nil(vhd_uuid_t *uuid) +{ + return uuid_is_null(uuid->uuid); +} + +void vhd_uuid_generate(vhd_uuid_t *uuid) +{ + uuid_generate(uuid->uuid); +} + +void vhd_uuid_to_string(vhd_uuid_t *uuid, char *out, size_t size) +{ + uuid_unparse(uuid->uuid, out); +} + +void vhd_uuid_from_string(vhd_uuid_t *uuid, const char *in) +{ + uuid_parse(in, uuid->uuid); +} + +void vhd_uuid_copy(vhd_uuid_t *dst, vhd_uuid_t *src) +{ + uuid_copy(dst->uuid, src->uuid); +} + +void vhd_uuid_clear(vhd_uuid_t *uuid) +{ + uuid_clear(uuid->uuid); +} + +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; + +int vhd_uuid_is_nil(vhd_uuid_t *uuid) +{ + uint32_t status; + return uuid_is_nil((uuid_t *)uuid, &status); +} + +void vhd_uuid_generate(vhd_uuid_t *uuid) +{ + uint32_t status; + uuid_create((uuid_t *)uuid, &status); +} + +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); +} + +void vhd_uuid_from_string(vhd_uuid_t *uuid, const char *in) +{ + uint32_t status; + uuid_from_string(in, (uuid_t *)uuid, &status); +} + +void vhd_uuid_copy(vhd_uuid_t *dst, vhd_uuid_t *src) +{ + memcpy((uuid_t *)dst, (uuid_t *)src, sizeof(uuid_t)); +} + +void vhd_uuid_clear(vhd_uuid_t *uuid) +{ + memset((uuid_t *)uuid, 0, sizeof(uuid_t)); +} + +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-util-uuid.c for your OS" + +#endif _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Mar-15 16:16 UTC
[Xen-devel] [PATCH 3 of 4] tools: link each shared library or binary only against the libraries it uses
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1300205433 0 # Node ID 4446ee65519b4fcd894b08cf091c5aed935d0e74 # Parent 75db4a775805fbdcb5013427661d94db1b7b17fc tools: link each shared library or binary only against the libraries it uses In particular if binary A uses libB and libB uses libC entirely internally then A does not need to link against libC only libB. However when linking binary A the linker does need to have visibility of the libraries which libB links against (libC in this example). For out of tree uses this is achieved without fuss due because the libraries are installed in a standard path. However in the case of in-tree users the linker needs a hint in the form of the -rpath-link option. Therefore a new class of build variable, $(SHLIB_FOO), is introduced which includes the linker options needed to link against a library which uses libFOO. The intention is that $(LDLIBS_bar) will include the $(SHLIB_foo)s which it uses where necessary rather requiring that users are aware of this. For the python extensions this change appears particularly large since previously each of python bindings were linked against the union of all possible libraries used by all bindings instead of just what they individually needed. This change removes a dependency on libdl.so from nearly everything in the system, only libxenctrl actually uses it. In the context of xl/libxl the intention of libxl is to remove any need for a user of libxl to know about libxenstore or libxenctrl, however in the current build it is xl which links against those libraries rather than libxl (which only links against libc). After this change libxl correctly depends on the libraries it uses and xl does not depend on libraries which it is not support to be required to know about. Note that xl does depend on libxenctrl.so since it uses xtl_* directly. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 75db4a775805 -r 4446ee65519b tools/Rules.mk --- a/tools/Rules.mk Tue Mar 15 15:15:08 2011 +0000 +++ b/tools/Rules.mk Tue Mar 15 16:10:33 2011 +0000 @@ -11,6 +11,7 @@ XEN_INCLUDE = $(XEN_ROOT)/tools/i XEN_INCLUDE = $(XEN_ROOT)/tools/include XEN_XC = $(XEN_ROOT)/tools/python/xen/lowlevel/xc XEN_LIBXC = $(XEN_ROOT)/tools/libxc +XEN_XENLIGHT = $(XEN_ROOT)/tools/libxl XEN_XENSTORE = $(XEN_ROOT)/tools/xenstore XEN_LIBXENSTAT = $(XEN_ROOT)/tools/xenstat/libxenstat/src XEN_BLKTAP2 = $(XEN_ROOT)/tools/blktap2 @@ -18,13 +19,16 @@ CFLAGS_include = -I$(XEN_INCLUDE) CFLAGS_include = -I$(XEN_INCLUDE) CFLAGS_libxenctrl = -I$(XEN_LIBXC) $(CFLAGS_include) -LDLIBS_libxenctrl = -L$(XEN_LIBXC) -lxenctrl $(DLOPEN_LIBS) +LDLIBS_libxenctrl = -L$(XEN_LIBXC) -lxenctrl +SHLIB_libxenctrl = -Wl,-rpath-link=$(XEN_LIBXC) CFLAGS_libxenguest = -I$(XEN_LIBXC) $(CFLAGS_include) LDLIBS_libxenguest = -L$(XEN_LIBXC) -lxenguest +SHLIB_libxenguest = -Wl,-rpath-link=L$(XEN_LIBXC) CFLAGS_libxenstore = -I$(XEN_XENSTORE) $(CFLAGS_include) LDLIBS_libxenstore = -L$(XEN_XENSTORE) -lxenstore +SHLIB_libxenstore = -Wl,-rpath-link=$(XEN_XENSTORE) ifeq ($(CONFIG_Linux),y) LIBXL_BLKTAP = y @@ -35,10 +39,16 @@ ifeq ($(LIBXL_BLKTAP),y) ifeq ($(LIBXL_BLKTAP),y) CFLAGS_libblktapctl = -I$(XEN_BLKTAP2)/control -I$(XEN_BLKTAP2)/include $(CFLAGS_include) LDLIBS_libblktapctl = -L$(XEN_BLKTAP2)/control -lblktapctl +SHLIB_libblktapctl = -Wl,-rpath-link=$(XEN_BLKTAP2)/control else CFLAGS_libblktapctl LDLIBS_libblktapctl +SHLIB_libblktapctl endif + +CFLAGS_libxenlight = -I$(XEN_XENLIGHT) $(CFLAGS_include) +LDLIBS_libxenlight = -L$(XEN_XENLIGHT) $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libblktapctl) -lxenlight +SHLIB_libxenlight = -Wl,-rpath-link=$(XEN_XENLIGHT) X11_LDPATH = -L/usr/X11R6/$(LIBLEAFDIR) diff -r 75db4a775805 -r 4446ee65519b tools/blktap2/drivers/Makefile --- a/tools/blktap2/drivers/Makefile Tue Mar 15 15:15:08 2011 +0000 +++ b/tools/blktap2/drivers/Makefile Tue Mar 15 16:10:33 2011 +0000 @@ -28,10 +28,6 @@ LBLIBS_img := $(LDLIBS_libxenctrl) $(CRY LBLIBS_img := $(LDLIBS_libxenctrl) $(CRYPT_LIB) -lpthread -lz -lm LIBS += -L$(LIBVHDDIR) -lvhd - -ifeq ($(CONFIG_Linux),y) -LIBS += -luuid -endif REMUS-OBJS := block-remus.o REMUS-OBJS += hashtable.o diff -r 75db4a775805 -r 4446ee65519b tools/blktap2/vhd/Makefile --- a/tools/blktap2/vhd/Makefile Tue Mar 15 15:15:08 2011 +0000 +++ b/tools/blktap2/vhd/Makefile Tue Mar 15 16:10:33 2011 +0000 @@ -22,9 +22,6 @@ endif endif LIBS := -Llib -lvhd -ifeq ($(CONFIG_Linux),y) -LIBS += -luuid -endif # Get gcc to generate the dependencies for us. CFLAGS += -Wp,-MD,.$(@F).d diff -r 75db4a775805 -r 4446ee65519b tools/libxl/Makefile --- a/tools/libxl/Makefile Tue Mar 15 15:15:08 2011 +0000 +++ b/tools/libxl/Makefile Tue Mar 15 16:10:33 2011 +0000 @@ -15,10 +15,16 @@ CFLAGS += -I. -fPIC CFLAGS += -I. -fPIC CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl) -LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(UTIL_LIBS) ifeq ($(CONFIG_Linux),y) -LIBS += -luuid +LIBUUID_LIBS += -luuid endif + +LIBXL_LIBS +LIBXL_LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(UTIL_LIBS) $(LIBUUID_LIBS) + +LIBXLU_LIBS + +CLIENT_LIBS = $(LDLIBS_libxenlight) LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o flexarray.o ifeq ($(LIBXL_BLKTAP),y) @@ -81,7 +87,7 @@ libxenlight.so.$(MAJOR): libxenlight.so. ln -sf $< $@ libxenlight.so.$(MAJOR).$(MINOR): $(LIBXL_OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ + $(CC) $(CFLAGS) -Wl,-rpath-link -Wl,$(XEN_ROOT)/tools/libxc $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LIBXL_LIBS) libxenlight.a: $(LIBXL_OBJS) $(AR) rcs libxenlight.a $^ @@ -93,13 +99,13 @@ libxlutil.so.$(XLUMAJOR): libxlutil.so.$ ln -sf $< $@ libxlutil.so.$(XLUMAJOR).$(XLUMINOR): $(LIBXLU_OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxlutil.so.$(XLUMAJOR) $(SHLIB_LDFLAGS) -o $@ $^ + $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxlutil.so.$(XLUMAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LIBXLU_LIBS) libxlutil.a: $(LIBXLU_OBJS) $(AR) rcs libxlutil.a $^ $(CLIENTS): $(XL_OBJS) libxlutil.so libxenlight.so - $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) + $(CC) $(LDFLAGS) -o $@ $(XL_OBJS) libxlutil.so libxenlight.so $(CLIENT_LIBS) .PHONY: install install: all diff -r 75db4a775805 -r 4446ee65519b tools/python/setup.py --- a/tools/python/setup.py Tue Mar 15 15:15:08 2011 +0000 +++ b/tools/python/setup.py Tue Mar 15 16:10:33 2011 +0000 @@ -6,119 +6,98 @@ XEN_ROOT = "../.." extra_compile_args = [ "-fno-strict-aliasing", "-Werror" ] -include_dirs = [ XEN_ROOT + "/tools/libxc", - XEN_ROOT + "/tools/xenstore", - XEN_ROOT + "/tools/include", - XEN_ROOT + "/tools/libxl", - ] - -library_dirs = [ XEN_ROOT + "/tools/libxc", - XEN_ROOT + "/tools/xenstore", - XEN_ROOT + "/tools/libxl" - ] - -libraries = [ "xenctrl", "xenguest", "xenstore" ] - -depends = [ XEN_ROOT + "/tools/libxc/libxenctrl.so", - XEN_ROOT + "/tools/libxc/libxenguest.so", - XEN_ROOT + "/tools/xenstore/libxenstore.so" - ] - -plat = os.uname()[0] -if plat == ''Linux'': - uuid_libs = ["uuid"] - blktap_ctl_libs = ["blktapctl"] - library_dirs.append(XEN_ROOT + "/tools/blktap2/control") - blktab_ctl_depends = [ XEN_ROOT + "/tools/blktap2/control/libblktapctl.so" ] -else: - uuid_libs = [] - blktap_ctl_libs = [] - blktab_ctl_depends = [] +PATH_XEN = XEN_ROOT + "/tools/include" +PATH_LIBXC = XEN_ROOT + "/tools/libxc" +PATH_LIBXL = XEN_ROOT + "/tools/libxl" +PATH_XENSTORE = XEN_ROOT + "/tools/xenstore" xc = Extension("xc", extra_compile_args = extra_compile_args, - include_dirs = include_dirs + [ "xen/lowlevel/xc" ], - library_dirs = library_dirs, - libraries = libraries, - depends = depends, + include_dirs = [ PATH_XEN, PATH_LIBXC, "xen/lowlevel/xc" ], + library_dirs = [ PATH_LIBXC ], + libraries = [ "xenctrl", "xenguest" ], + depends = [ PATH_LIBXC + "/libxenctrl.so", PATH_LIBXC + "/libxenguest.so" ], sources = [ "xen/lowlevel/xc/xc.c" ]) xs = Extension("xs", extra_compile_args = extra_compile_args, - include_dirs = include_dirs + [ "xen/lowlevel/xs" ], - library_dirs = library_dirs, - libraries = libraries, - depends = depends, + include_dirs = [ PATH_XEN, PATH_XENSTORE, "xen/lowlevel/xs" ], + library_dirs = [ PATH_XENSTORE ], + libraries = [ "xenstore" ], + depends = [ PATH_XENSTORE + "/libxenstore.so" ], sources = [ "xen/lowlevel/xs/xs.c" ]) scf = Extension("scf", extra_compile_args = extra_compile_args, - include_dirs = include_dirs + [ "xen/lowlevel/scf" ], - library_dirs = library_dirs, - libraries = libraries, - depends = depends, + include_dirs = [ "xen/lowlevel/scf" ], + library_dirs = [ ], + libraries = [ ], + depends = [ ], sources = [ "xen/lowlevel/scf/scf.c" ]) - + process = Extension("process", extra_compile_args = extra_compile_args, - include_dirs = include_dirs + [ "xen/lowlevel/process" ], - library_dirs = library_dirs, - libraries = libraries + [ "contract" ], - depends = depends, + include_dirs = [ "xen/lowlevel/process" ], + library_dirs = [ ], + libraries = [ "contract" ], + depends = [ ], sources = [ "xen/lowlevel/process/process.c" ]) acm = Extension("acm", extra_compile_args = extra_compile_args, - include_dirs = include_dirs + [ "xen/lowlevel/acm" ], - library_dirs = library_dirs, - libraries = libraries, - depends = depends, + include_dirs = [ PATH_XEN, PATH_LIBXC, "xen/lowlevel/acm" ], + library_dirs = [ PATH_LIBXC ], + libraries = [ "xenctrl" ], + depends = [ PATH_LIBXC + "/libxenctrl.so" ], sources = [ "xen/lowlevel/acm/acm.c" ]) flask = Extension("flask", extra_compile_args = extra_compile_args, - include_dirs = include_dirs + [ "xen/lowlevel/flask" ] + - [ "../flask/libflask/include" ], - library_dirs = library_dirs + [ "../flask/libflask" ], - libraries = libraries + [ "flask" ], - depends = depends + [ XEN_ROOT + "/tools/flask/libflask/libflask.so" ], + include_dirs = [ PATH_XEN, PATH_LIBXC, "xen/lowlevel/flask", + "../flask/libflask/include" ], + library_dirs = [ PATH_LIBXC, "../flask/libflask" ], + libraries = [ "xenctrl", "flask" ], + depends = [ PATH_LIBXC + "/libxenctrl.so", + XEN_ROOT + "/tools/flask/libflask/libflask.so" ], sources = [ "xen/lowlevel/flask/flask.c" ]) ptsname = Extension("ptsname", extra_compile_args = extra_compile_args, - include_dirs = include_dirs + [ "ptsname" ], - library_dirs = library_dirs, - libraries = libraries, - depends = depends, + include_dirs = [ "ptsname" ], + library_dirs = [ ], + libraries = [ ], + depends = [ ], sources = [ "ptsname/ptsname.c" ]) checkpoint = Extension("checkpoint", - extra_compile_args = extra_compile_args, - include_dirs = include_dirs, - library_dirs = library_dirs, - libraries = libraries + [ "rt" ], - depends = depends, - sources = [ "xen/lowlevel/checkpoint/checkpoint.c", - "xen/lowlevel/checkpoint/libcheckpoint.c"]) + extra_compile_args = extra_compile_args, + include_dirs = [ PATH_XEN, PATH_LIBXC, PATH_XENSTORE ], + library_dirs = [ PATH_LIBXC, PATH_XENSTORE ], + libraries = [ "xenctrl", "xenguest", "xenstore", "rt" ], + depends = [ PATH_LIBXC + "/libxenctrl.so", + PATH_LIBXC + "/libxenguest.so", + PATH_XENSTORE + "/libxenstore.so" ], + sources = [ "xen/lowlevel/checkpoint/checkpoint.c", + "xen/lowlevel/checkpoint/libcheckpoint.c"]) netlink = Extension("netlink", - extra_compile_args = extra_compile_args, - include_dirs = include_dirs, - library_dirs = library_dirs, - libraries = libraries, - depends = depends, - sources = [ "xen/lowlevel/netlink/netlink.c", - "xen/lowlevel/netlink/libnetlink.c"]) + extra_compile_args = extra_compile_args, + include_dirs = [ ], + library_dirs = [ ], + libraries = [ ], + depends = [ ], + sources = [ "xen/lowlevel/netlink/netlink.c", + "xen/lowlevel/netlink/libnetlink.c"]) xl = Extension("xl", extra_compile_args = extra_compile_args, - include_dirs = include_dirs + [ "xen/lowlevel/xl" ], - library_dirs = library_dirs, - libraries = libraries + ["xenlight" ] + blktap_ctl_libs + uuid_libs, - depends = depends + blktab_ctl_depends + - [ XEN_ROOT + "/tools/libxl/libxenlight.so" ], + include_dirs = [ PATH_XEN, PATH_LIBXL, PATH_LIBXC, PATH_XENSTORE, "xen/lowlevel/xl" ], + library_dirs = [ PATH_LIBXL ], + libraries = [ "xenlight" ], + depends = [ PATH_LIBXL + "/libxenlight.so" ], sources = [ "xen/lowlevel/xl/xl.c", "xen/lowlevel/xl/_pyxl_types.c" ]) +plat = os.uname()[0] modules = [ xc, xs, ptsname, acm, flask, xl ] if plat == ''SunOS'': modules.extend([ scf, process ]) @@ -143,7 +122,6 @@ setup(name = ''xen'', ''xen.sv'', ''xen.xsview'', ''xen.remus'', - ''xen.xend.tests'', ''xen.xend.server.tests'', ''xen.xend.xenstore.tests'', diff -r 75db4a775805 -r 4446ee65519b tools/python/xen/lowlevel/xl/xl.c --- a/tools/python/xen/lowlevel/xl/xl.c Tue Mar 15 15:15:08 2011 +0000 +++ b/tools/python/xen/lowlevel/xl/xl.c Tue Mar 15 16:10:33 2011 +0000 @@ -35,7 +35,6 @@ #include <sys/socket.h> #include <sys/select.h> #include <arpa/inet.h> -#include <xenctrl.h> #include <ctype.h> #include <inttypes.h> diff -r 75db4a775805 -r 4446ee65519b tools/python/xen/lowlevel/xs/xs.c --- a/tools/python/xen/lowlevel/xs/xs.c Tue Mar 15 15:15:08 2011 +0000 +++ b/tools/python/xen/lowlevel/xs/xs.c Tue Mar 15 16:10:33 2011 +0000 @@ -30,7 +30,6 @@ #include <fcntl.h> #include <errno.h> -#include <xenctrl.h> #include "xs.h" /** @file _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Mar-15 16:16 UTC
[Xen-devel] [PATCH 4 of 4] tools: support building with --as-needed
# HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1300205703 0 # Node ID ec906d89bd42120407bb53d28d31079162b37286 # Parent 4446ee65519b4fcd894b08cf091c5aed935d0e74 tools: support building with --as-needed Tested by forcing --as-needed via tools/Rules.mk but this is included since the intention is simply to support diustros which default to --as-needed, not to enable it everywhere. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 4446ee65519b -r ec906d89bd42 tools/Rules.mk --- a/tools/Rules.mk Tue Mar 15 16:10:33 2011 +0000 +++ b/tools/Rules.mk Tue Mar 15 16:15:03 2011 +0000 @@ -65,9 +65,6 @@ LDFLAGS += $(shell getconf LFS_LDFLAGS) LDFLAGS += $(shell getconf LFS_LDFLAGS) endif -# Xen tools build is currently incompatible with ld --as-needed -LDFLAGS += -Wl,--no-as-needed - # 32-bit x86 does not perform well with -ve segment accesses on Xen. CFLAGS-$(CONFIG_X86_32) += $(call cc-option,$(CC),-mno-tls-direct-seg-refs) CFLAGS += $(CFLAGS-y) diff -r 4446ee65519b -r ec906d89bd42 tools/blktap2/vhd/lib/Makefile --- a/tools/blktap2/vhd/lib/Makefile Tue Mar 15 16:10:33 2011 +0000 +++ b/tools/blktap2/vhd/lib/Makefile Tue Mar 15 16:15:03 2011 +0000 @@ -57,7 +57,7 @@ build: $(LIBVHD-BUILD) libvhd.a: $(LIB-OBJS) $(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG),$(LIBVHD-SONAME) $(SHLIB_LDFLAGS) \ - $(LDFLAGS) -o libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $(LIBS) $^ + $(LDFLAGS) -o libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $^ $(LIBS) ln -sf libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) libvhd.so.$(LIBVHD-MAJOR) ln -sf libvhd.so.$(LIBVHD-MAJOR) libvhd.so $(AR) rc $@ $^ diff -r 4446ee65519b -r ec906d89bd42 tools/libxc/Makefile --- a/tools/libxc/Makefile Tue Mar 15 16:10:33 2011 +0000 +++ b/tools/libxc/Makefile Tue Mar 15 16:15:03 2011 +0000 @@ -159,7 +159,7 @@ libxenctrl.so.$(MAJOR): libxenctrl.so.$( ln -sf $< $@ libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(DLOPEN_LIBS) $(SHLIB_LDFLAGS) -o $@ $^ $(PTHREAD_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(DLOPEN_LIBS) $(PTHREAD_LIBS) # libxenguest _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Mar-15 16:18 UTC
[Xen-devel] Re: [PATCH 0 of 4] tools: build system fix indirect library usage and --as-needed
On Tue, 2011-03-15 at 16:16 +0000, Ian Campbell wrote:> This series arranges for all libraries and binaries to only link > against those shared libraries which they use directly, relying on the > dynamic linker to do the right thing for indirect dependencies. > > In order to do this I''ve pushed the tools/blktap2 UUID abstraction > down into libvhd and out of line to encapsulate all knowledge > regarding this abstraction into libvhd rather than expecting the users > of the library to do the right thing. > > Having done this supporting --as-needed becomes a pretty trivial case > of ensuring links lines have the libraries in the correct order. > > Tested by: > * running xl, start/stop a guest > * running xend, start/stop a guest > * manually importing each python extension and calling > whatever initialisation function I could find.Also, the output of: find tools/ -perm +111 -type f | while read i ; do file $i | grep -q ELF || continue echo $i objdump -p $i | grep NEEDED echo done before and after is attached. The diff is below. Ian. --- BEFORE +++ AFTER @@ -35,7 +35,6 @@ tools/console/xenconsole NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenstore.so.3.0 NEEDED libutil.so.1 NEEDED librt.so.1 @@ -43,7 +42,6 @@ tools/console/xenconsoled NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenstore.so.3.0 NEEDED libutil.so.1 NEEDED librt.so.1 @@ -51,12 +49,10 @@ tools/xenmon/xentrace_setmask NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libc.so.6 tools/xenmon/xenbaked NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libc.so.6 tools/remus/imqebt/imqebt @@ -107,7 +103,6 @@ tools/xenstore/xenstored NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libc.so.6 tools/xenstore/xenstore-control @@ -115,12 +110,7 @@ NEEDED libc.so.6 tools/python/build/lib.linux-i686-2.5/xen/lowlevel/xl.so - NEEDED libxenctrl.so.4.0 - NEEDED libxenguest.so.4.0 - NEEDED libxenstore.so.3.0 NEEDED libxenlight.so.1.0 - NEEDED libblktapctl.so.1.0 - NEEDED libuuid.so.1 NEEDED libpthread.so.0 NEEDED libc.so.6 @@ -133,8 +123,6 @@ NEEDED libc.so.6 tools/python/build/lib.linux-i686-2.5/xen/lowlevel/xs.so - NEEDED libxenctrl.so.4.0 - NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libpthread.so.0 NEEDED libc.so.6 @@ -142,36 +130,25 @@ tools/python/build/lib.linux-i686-2.5/xen/lowlevel/xc.so NEEDED libxenctrl.so.4.0 NEEDED libxenguest.so.4.0 - NEEDED libxenstore.so.3.0 NEEDED libpthread.so.0 NEEDED libc.so.6 tools/python/build/lib.linux-i686-2.5/xen/lowlevel/acm.so NEEDED libxenctrl.so.4.0 - NEEDED libxenguest.so.4.0 - NEEDED libxenstore.so.3.0 NEEDED libpthread.so.0 NEEDED libc.so.6 tools/python/build/lib.linux-i686-2.5/xen/lowlevel/flask.so NEEDED libxenctrl.so.4.0 - NEEDED libxenguest.so.4.0 - NEEDED libxenstore.so.3.0 NEEDED libflask.so.1.0 NEEDED libpthread.so.0 NEEDED libc.so.6 tools/python/build/lib.linux-i686-2.5/xen/lowlevel/netlink.so - NEEDED libxenctrl.so.4.0 - NEEDED libxenguest.so.4.0 - NEEDED libxenstore.so.3.0 NEEDED libpthread.so.0 NEEDED libc.so.6 tools/python/build/lib.linux-i686-2.5/xen/lowlevel/ptsname.so - NEEDED libxenctrl.so.4.0 - NEEDED libxenguest.so.4.0 - NEEDED libxenstore.so.3.0 NEEDED libpthread.so.0 NEEDED libc.so.6 @@ -179,35 +156,29 @@ tools/xentrace/xenctx NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libc.so.6 tools/xentrace/xentrace NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libc.so.6 tools/xentrace/xentrace_setsize NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libc.so.6 tools/flask/utils/flask-setenforce NEEDED libflask.so.1.0 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libc.so.6 tools/flask/utils/flask-loadpolicy NEEDED libflask.so.1.0 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libc.so.6 tools/flask/utils/flask-getenforce NEEDED libflask.so.1.0 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libc.so.6 tools/flask/libflask/libflask.so.1.0.0 @@ -261,28 +232,24 @@ tools/xcutils/lsevtchn NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 tools/xcutils/xc_save NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 tools/xcutils/readnotes NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 tools/xcutils/xc_restore NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 @@ -290,8 +257,12 @@ tools/libxl/xl NEEDED libxlutil.so.1.0 NEEDED libxenlight.so.1.0 + NEEDED libc.so.6 + NEEDED libxenctrl.so.4.0 + NEEDED libuuid.so.1 + +tools/libxl/libxenlight.so.1.0.0 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libblktapctl.so.1.0 @@ -299,20 +270,15 @@ NEEDED libuuid.so.1 NEEDED libc.so.6 -tools/libxl/libxenlight.so.1.0.0 - NEEDED libc.so.6 - tools/libxl/libxlutil.so.1.0.0 NEEDED libc.so.6 tools/blktap2/vhd/vhd-update NEEDED libvhd.so.1.0 - NEEDED libuuid.so.1 NEEDED libc.so.6 tools/blktap2/vhd/vhd-util NEEDED libvhd.so.1.0 - NEEDED libuuid.so.1 NEEDED libc.so.6 tools/blktap2/vhd/lib/libvhd.so.1.0.0 @@ -330,9 +296,7 @@ NEEDED librt.so.1 NEEDED libz.so.1 NEEDED libvhd.so.1.0 - NEEDED libuuid.so.1 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libpthread.so.0 NEEDED libm.so.6 NEEDED libc.so.6 @@ -341,9 +305,7 @@ NEEDED librt.so.1 NEEDED libz.so.1 NEEDED libvhd.so.1.0 - NEEDED libuuid.so.1 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libpthread.so.0 NEEDED libm.so.6 NEEDED libc.so.6 @@ -352,16 +314,13 @@ NEEDED librt.so.1 NEEDED libz.so.1 NEEDED libvhd.so.1.0 - NEEDED libuuid.so.1 NEEDED libc.so.6 tools/blktap2/drivers/qcow2raw NEEDED librt.so.1 NEEDED libz.so.1 NEEDED libvhd.so.1.0 - NEEDED libuuid.so.1 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libpthread.so.0 NEEDED libm.so.6 NEEDED libc.so.6 @@ -370,9 +329,7 @@ NEEDED librt.so.1 NEEDED libz.so.1 NEEDED libvhd.so.1.0 - NEEDED libuuid.so.1 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libpthread.so.0 NEEDED libm.so.6 NEEDED libc.so.6 @@ -381,9 +338,7 @@ NEEDED librt.so.1 NEEDED libz.so.1 NEEDED libvhd.so.1.0 - NEEDED libuuid.so.1 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libpthread.so.0 NEEDED libm.so.6 NEEDED libc.so.6 @@ -392,9 +347,7 @@ NEEDED librt.so.1 NEEDED libz.so.1 NEEDED libvhd.so.1.0 - NEEDED libuuid.so.1 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libpthread.so.0 NEEDED libm.so.6 NEEDED libc.so.6 @@ -403,9 +356,7 @@ NEEDED librt.so.1 NEEDED libz.so.1 NEEDED libvhd.so.1.0 - NEEDED libuuid.so.1 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libpthread.so.0 NEEDED libm.so.6 NEEDED libc.so.6 @@ -414,9 +365,7 @@ NEEDED librt.so.1 NEEDED libz.so.1 NEEDED libvhd.so.1.0 - NEEDED libuuid.so.1 NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libpthread.so.0 NEEDED libm.so.6 NEEDED libc.so.6 @@ -450,13 +399,6 @@ tools/ocaml/libs/log/dllsyslog_stubs.so NEEDED libc.so.6 -tools/ocaml/xenstored/oxenstored - NEEDED libxenctrl.so.4.0 - NEEDED libxenguest.so.4.0 - NEEDED libm.so.6 - NEEDED libdl.so.2 - NEEDED libc.so.6 - tools/xenstat/xentop/xentop NEEDED libxenstore.so.3.0 NEEDED libxenctrl.so.4.0 @@ -483,7 +425,6 @@ tools/misc/xenlockprof NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 @@ -493,28 +434,24 @@ tools/misc/xenpm NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 tools/misc/gtracestat NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 tools/misc/xenwatchdogd NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 tools/misc/xen-hvmcrash NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 @@ -524,21 +461,18 @@ tools/misc/xen-hvmctx NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 tools/misc/xenperf NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 tools/misc/xen-hptool NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenguest.so.4.0 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 @@ -549,7 +483,6 @@ tools/xenpaging/xenpaging NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenstore.so.3.0 NEEDED libc.so.6 @@ -558,7 +491,6 @@ tools/debugger/kdd/kdd NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libc.so.6 tools/debugger/gdbsx/gdbsx @@ -578,7 +510,6 @@ tools/blktap/drivers/blktapctrl NEEDED libxenctrl.so.4.0 - NEEDED libdl.so.2 NEEDED libxenstore.so.3.0 NEEDED libblktap.so.3.0 NEEDED librt.so.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Daniel Stodden
2011-Mar-15 16:42 UTC
Re: [Xen-devel] [PATCH 2 of 4] tools/blktap2/libvhd: move uuid wrapper functions out of line
On Tue, 2011-03-15 at 12:16 -0400, Ian Campbell wrote:> # HG changeset patch > # User Ian Campbell <ian.campbell@citrix.com> > # Date 1300202108 0 > # Node ID 75db4a775805fbdcb5013427661d94db1b7b17fc > # Parent 83a1d6598fa3617085baecec1cda1e4caa518c92 > tools/blktap2/libvhd: move uuid wrapper functions out of line. > > This isolates users of libvhd from the need to know about the > different OS schemes for UUIDs. > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>Ack. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2011-Mar-17 19:17 UTC
[Xen-devel] Re: [PATCH 0 of 4] tools: build system fix indirect library usage and --as-needed
Ian Campbell writes ("[Xen-devel] Re: [PATCH 0 of 4] tools: build system fix indirect library usage and --as-needed"):> On Tue, 2011-03-15 at 16:16 +0000, Ian Campbell wrote: > > This series arranges for all libraries and binaries to only link > > against those shared libraries which they use directly, relying on the > > dynamic linker to do the right thing for indirect dependencies.Thanks. That looked plausible and it built for me so I have applied all four. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel