From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLqcA-0004PW-G4 for qemu-devel@nongnu.org; Tue, 17 Sep 2013 04:26:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VLqc2-0004yh-U1 for qemu-devel@nongnu.org; Tue, 17 Sep 2013 04:26:30 -0400 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:54807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLqc2-0004yY-CY for qemu-devel@nongnu.org; Tue, 17 Sep 2013 04:26:22 -0400 Received: from /spool/local by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Sep 2013 18:26:20 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 4A2E82CE8054 for ; Tue, 17 Sep 2013 18:26:15 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8H89jY266781390 for ; Tue, 17 Sep 2013 18:09:45 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r8H8QE6w028047 for ; Tue, 17 Sep 2013 18:26:14 +1000 Message-ID: <52381224.7000603@linux.vnet.ibm.com> Date: Tue, 17 Sep 2013 16:26:12 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1379314227-8855-1-git-send-email-famz@redhat.com> <1379314227-8855-6-git-send-email-famz@redhat.com> <20130916085902.GA6005@redhat.com> <5236D318.4080206@redhat.com> <20130916095121.GD22783@T430s.nay.redhat.com> <3AD10BC4-9EDC-4FDA-BC0D-D1380C5904C2@alex.org.uk> <5236DFBE.2000801@redhat.com> In-Reply-To: <5236DFBE.2000801@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v10 5/8] module: implement module loading List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: peter.maydell@linaro.org, famz@redhat.com, mjt@tls.msk.ru, qemu-devel@nongnu.org, Alex Bligh , vilanova@ac.upc.edu, rth@twiddle.net 于 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 >> 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 > 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. > > 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. > >