[Top][All Lists]

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

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

From: Wenchao Xia
Subject: Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading
Date: Tue, 17 Sep 2013 16:26:12 +0800
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv: Gecko/20110303 Thunderbird/3.1.9

于 2013/9/16 18:38, Paolo Bonzini 写道:
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

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:

int f(void)
        return 42;

#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

Is there a way to tell the program loader: don't resolve the dynamic symbol, f, then code can run into main(), and we add code do dlopen("/another_dir/xx.so")? (Assume xx.so
exist in /another_dir/?

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.


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]