From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLWCu-0004Za-Q0 for qemu-devel@nongnu.org; Mon, 16 Sep 2013 06:39:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VLWCq-0003ao-1S for qemu-devel@nongnu.org; Mon, 16 Sep 2013 06:39:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLWCp-0003ag-OR for qemu-devel@nongnu.org; Mon, 16 Sep 2013 06:38:59 -0400 Message-ID: <5236DFBE.2000801@redhat.com> Date: Mon, 16 Sep 2013 12:38:54 +0200 From: Paolo Bonzini 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> In-Reply-To: <3AD10BC4-9EDC-4FDA-BC0D-D1380C5904C2@alex.org.uk> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: Alex Bligh Cc: peter.maydell@linaro.org, famz@redhat.com, mjt@tls.msk.ru, qemu-devel@nongnu.org, vilanova@ac.upc.edu, rth@twiddle.net 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.