Received: from eggs.gnu.org ([2001:4830:134:3::10]:48468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJmH9-0005yz-8q for qemu-devel@nongnu.org; Wed, 11 Sep 2013 11:24:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJmH3-00040o-Hu for qemu-devel@nongnu.org; Wed, 11 Sep 2013 11:24:15 -0400 Received: from mail.avalus.com ([2001:41c8:10:1dd::10]:46421) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJmH3-0003zj-Bg for qemu-devel@nongnu.org; Wed, 11 Sep 2013 11:24:09 -0400 Date: Wed, 11 Sep 2013 16:23:53 +0100 From: Alex Bligh Message-ID: <66D9B8AB43C372ACE8E41913@Ximines.local> In-Reply-To: <523086EC.1020103@twiddle.net> References: <1378877909-28518-1-git-send-email-famz@redhat.com> <1378877909-28518-5-git-send-email-famz@redhat.com> <523086EC.1020103@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Re: [Qemu-devel] [RFC PATCH v5 4/6] module: implement module loading function Reply-To: Alex Bligh List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: peter.maydell@linaro.org, Fam Zheng , Alex Bligh , mjt@tls.msk.ru, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com, vilanova@ac.upc.edu --On 11 September 2013 08:06:20 -0700 Richard Henderson wrote: > If we want dependencies between modules, we may well need to get the > dynamic linker involved with the search directory. This would rule > out any command-line, or monitor-line altering of the path. > > But it does suggest the default being DT_RUNPATH, overridable "near" > the command-line via LD_RUN_PATH. Not quite sure what you are suggesting here. DT_RUNPATH is an elf tag IIRC. Not sure what LD_RUN_PATH does. LD_LIBRARY_PATH affects more than just this. If we are using the dynamic linker and DT_RUNPATH (which I believe is in the executable) or the normal paths we WILL NEED proper API versioning etc.; in this case (in the distro example I pulled out), an upgrade to qemu making an API change will have different API versioned libs and these can happily coexist, so no need for directories. But are we really sufficiently stable for that? Any internal change in API (as modules communicate using an internal API, not something wrapped with opaque struct *) is going to result in a library major version number change as far as I can see. That's going to play merry hell with distributions. Assuming we restrict this to load dependencies (as opposed to version dependencies), I would have thought the way to go is a) ensure that each build of qemu has ALL the modules available. b) qemu and all its modules always look in the same place c) that place can be changed at load time (as well as at compile time) to permit different versions of qemu to be around. I think this can be done with dlopen() as follows: If filename contains a slash ("/"), then it is interpreted as a (relative or absolute) pathname. This means no searching is done with DT_RPATH, DT_RUNPATH etc. It later says: If the library has dependencies on other shared libraries, then these are also automatically loaded by the dynamic linker using the same rules. (This process may occur recursively, if those libraries in turn have dependencies, and so on.) My dlopen() foo is insufficiently strong to know what happens if you have dependencies AND specify an absolute or relative path (as opposed to just a module name). In an ideal world it would just look in the same directory and not elsewhere, in which case we can use the scheme I suggested AND use dlopen() AND not worry about API versioning (yet). > I also wonder about the utility of the subdirectories above, as > opposed to filename prefixes. +1 -- Alex Bligh