* [Qemu-devel] [PATCH] vdi: don't override libuuid symbols
@ 2012-11-20 15:34 Stefan Hajnoczi
2012-11-20 15:46 ` Kevin Wolf
2012-11-20 16:15 ` Stefan Hajnoczi
0 siblings, 2 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-11-20 15:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Stefan Weil, Stefan Hajnoczi, vbellur
It's poor symbol hygiene to provide a global symbols that collide with a
common library like libuuid. If QEMU links against a shared library
that depends on uuid_generate() it can end up calling our stub version
of the function.
This exact scenario happened with GlusterFS libgfapi.so, which depends
on libglusterfs.so's uuid_generate().
Scope the uuid stubs for vdi.c only and avoid affecting other shared
objects.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/vdi.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/block/vdi.c b/block/vdi.c
index f35b12e..c8330b7 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -60,9 +60,6 @@
/* TODO: move uuid emulation to some central place in QEMU. */
#include "sysemu.h" /* UUID_FMT */
typedef unsigned char uuid_t[16];
-void uuid_generate(uuid_t out);
-int uuid_is_null(const uuid_t uu);
-void uuid_unparse(const uuid_t uu, char *out);
#endif
/* Code configuration options. */
@@ -124,18 +121,18 @@ void uuid_unparse(const uuid_t uu, char *out);
#define VDI_IS_ALLOCATED(X) ((X) < VDI_DISCARDED)
#if !defined(CONFIG_UUID)
-void uuid_generate(uuid_t out)
+static inline void uuid_generate(uuid_t out)
{
memset(out, 0, sizeof(uuid_t));
}
-int uuid_is_null(const uuid_t uu)
+static inline int uuid_is_null(const uuid_t uu)
{
uuid_t null_uuid = { 0 };
return memcmp(uu, null_uuid, sizeof(uuid_t)) == 0;
}
-void uuid_unparse(const uuid_t uu, char *out)
+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],
--
1.8.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vdi: don't override libuuid symbols
2012-11-20 15:34 [Qemu-devel] [PATCH] vdi: don't override libuuid symbols Stefan Hajnoczi
@ 2012-11-20 15:46 ` Kevin Wolf
2012-11-20 16:15 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2012-11-20 15:46 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Stefan Weil, qemu-devel, vbellur
Am 20.11.2012 16:34, schrieb Stefan Hajnoczi:
> It's poor symbol hygiene to provide a global symbols that collide with a
> common library like libuuid. If QEMU links against a shared library
> that depends on uuid_generate() it can end up calling our stub version
> of the function.
>
> This exact scenario happened with GlusterFS libgfapi.so, which depends
> on libglusterfs.so's uuid_generate().
>
> Scope the uuid stubs for vdi.c only and avoid affecting other shared
> objects.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vdi: don't override libuuid symbols
2012-11-20 15:34 [Qemu-devel] [PATCH] vdi: don't override libuuid symbols Stefan Hajnoczi
2012-11-20 15:46 ` Kevin Wolf
@ 2012-11-20 16:15 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2012-11-20 16:15 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Kevin Wolf, Stefan Weil, qemu-devel, vbellur
On Tue, Nov 20, 2012 at 04:34:17PM +0100, Stefan Hajnoczi wrote:
> It's poor symbol hygiene to provide a global symbols that collide with a
> common library like libuuid. If QEMU links against a shared library
> that depends on uuid_generate() it can end up calling our stub version
> of the function.
>
> This exact scenario happened with GlusterFS libgfapi.so, which depends
> on libglusterfs.so's uuid_generate().
>
> Scope the uuid stubs for vdi.c only and avoid affecting other shared
> objects.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> block/vdi.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
Thanks, applied to the block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-20 16:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-20 15:34 [Qemu-devel] [PATCH] vdi: don't override libuuid symbols Stefan Hajnoczi
2012-11-20 15:46 ` Kevin Wolf
2012-11-20 16:15 ` Stefan Hajnoczi
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).