From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK2xv-0005jo-AN for qemu-devel@nongnu.org; Thu, 12 Sep 2013 05:13:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VK2xq-00038r-Jv for qemu-devel@nongnu.org; Thu, 12 Sep 2013 05:13:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK2xq-00038f-BG for qemu-devel@nongnu.org; Thu, 12 Sep 2013 05:13:26 -0400 Date: Thu, 12 Sep 2013 10:13:17 +0100 From: "Daniel P. Berrange" Message-ID: <20130912091317.GB18793@redhat.com> References: <1378906448-15834-1-git-send-email-famz@redhat.com> <1378906448-15834-5-git-send-email-famz@redhat.com> <20130911154841.GD2293@redhat.com> <5230BA69.1000202@twiddle.net> <20130912030232.GK9134@T430s.nay.redhat.com> <523152EB.5010505@msgid.tls.msk.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <523152EB.5010505@msgid.tls.msk.ru> Subject: Re: [Qemu-devel] [PATCH v6 4/8] module: implement module loading function Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev Cc: peter.maydell@linaro.org, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com, vilanova@ac.upc.edu, Richard Henderson On Thu, Sep 12, 2013 at 09:36:43AM +0400, Michael Tokarev wrote: > 12.09.2013 07:02, Fam Zheng wrote. > >On Wed, 09/11 11:46, Richard Henderson wrote: > >>On 09/11/2013 08:48 AM, Daniel P. Berrange wrote: > >>>We know the precise list of valid modules when building QEMU, > >>>so IMHO, this should just explicitly load each known module > >>>name, and *not* readdir. Also it should do something along the > >>>lines suggested their of poisoning exported symbols with a > >>>build hash to guarantee the modules loaded match the original > >>>binary and that the symbols change on every rebuild. > >> > >>We need not mangle the symbols, which could be complicated to > >>actually implement, and irritating to work around within gdb. > >> > >Agree with this, some id or hash check should be enough. > > A solution which I proposed at the very beginning -- to export > a "hashed" init function from modules, and call it from the > main executable. Like, instead of, say, qemu_module_init(), > call qemu_module_init_0xdeadbeaf(), where 0xdeadbeaf is a > hash of some build-dependent value. This should be enough > to keep it going. > > Ofcourse, if a module lacks this function, it should not be > loaded. Yep, that would be a reasonable way todo this. THe current patches use attribute(constructor) so QEMU doesn't actually call any explicit init function after dlopen()ing. That could easily be changed though. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|