qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading
Date: Mon, 16 Sep 2013 12:38:54 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8

Il 16/09/2013 12:24, Alex Bligh ha scritto:
> At risk of heresy, can I suggest a rather simpler scheme that requires
> a total of zero infrastructure changes?
> 
> Here's a patch against qemu 1.0 (sorry) Ubuntu dist (sorry) that
> uses weak binding to load and compile against any version of
> librbd:
>   
> https://github.com/flexiant/qemu/commit/6fa2e9c95bdaca7c814881e27f04424fb6cc2960
> 
> This requires librbd-dev headers of some sort in order to build. But
> librbd does not need to be there on a deployment, and indeed multiple
> versions work (and the patch does different things depending on
> librbd version).

No, librbd does need to be there for the other symbols that are not weak
(e.g. rbd_aio_read).  This approach cannot be "taken to the limit", i.e.
removing the librbd dependency altogether.  For example:

xx.c:
int f(void)
{
        return 42;
}

yy.c:
#pragma weak f
extern int f(void);
int main()
{
        printf("%p %d", f, f ? f(): 67);
}

$ gcc xx.c -shared -o xx.so
$ LD_RUN_PATH=$PWD gcc yy.c xx.so -o yy
$ ./yy
0x4005b0 42
$ rm xx.so
$ ./yy
./yy: error while loading shared libraries: xx.so: cannot open shared
object file: No such file or directory


Also, the code _is_ ugly.  Do it once and it's perhaps acceptable.  Do
it for libiscsi, librbd, libcurl, libssh2, SPICE, GTK+, SDL etc. and it
becomes unmaintainable.

Paolo

> This would seem to achieve the stated objective (qemu package can
> be installed without librbd dependencies) without any reliance
> on modules at all. So we could scrap the whole modules infrastructure
> and just tell people developing third party libraries to use weak
> binding. As you can see, for librbd anyway, the changes required
> to support weak binding are pretty minimal.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]