From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHSt3-0008AN-6F for qemu-devel@nongnu.org; Mon, 27 Jun 2016 05:31:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHSt2-0002VR-4U for qemu-devel@nongnu.org; Mon, 27 Jun 2016 05:31:25 -0400 Date: Mon, 27 Jun 2016 17:31:09 +0800 From: Fam Zheng Message-ID: <20160627093109.GA4461@ad.usersys.redhat.com> References: <1466631354-17309-1-git-send-email-clord@redhat.com> <1466631354-17309-4-git-send-email-clord@redhat.com> <20160624100443.GF9558@stefanha-x1.localdomain> <20160624103755.GN25240@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160624103755.GN25240@redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 3/3] blockdev: Add dynamic module loading for block drivers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , clord@redhat.com Cc: Stefan Hajnoczi , kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, Marc Mari On Fri, 06/24 11:37, Daniel P. Berrange wrote: > On Fri, Jun 24, 2016 at 11:04:43AM +0100, Stefan Hajnoczi wrote: > > On Wed, Jun 22, 2016 at 05:35:54PM -0400, Colin Lord wrote: > > > > > > > > @@ -447,8 +466,15 @@ int get_tmp_filename(char *filename, int size) > > > static BlockDriver *find_hdev_driver(const char *filename) > > > { > > > int score_max = 0, score; > > > + size_t i; > > > BlockDriver *drv = NULL, *d; > > > > > > + for (i = 0; i < ARRAY_SIZE(block_driver_modules); ++i) { > > > + if (block_driver_modules[i].has_probe_device) { > > > + block_module_load_one(block_driver_modules[i].library_name); > > > + } > > > + } > > > > This patch series needs to solve probing so that we don't end up loading > > all block drivers. Fam's suggestion for a built-in probe.c sounds good > > to me. > > Do we really care if probing loads all drivers ? Last time we discussed > this I thought we decided that because probing almost always leads to > security vulnerabilities, no one should use it by default and so we > don't really need to worry about optimizing it. Does this mean we can drop "has_probe" and "has_probe_device" from the generated header and load all modules for probe? If so, I'd like to again stress my preference for a "simplified" code "parser": All of current block_init() calls except quorum can be converted with this: #define BLOCK_DRIVER_EXPORT(fmt_name, prot_name, drv) \ static void bdrv_ ## fmt_name ## _ ## prot_name(void) \ { \ if (strlen(#fmt_name)) { \ drv->format_name = #fmt_name; \ } \ if (strlen(#prot_name)) { \ drv->protocol_name = #prot_name; \ } \ bdrv_register(&(drv)); \ } \ block_init(bdrv_ ## fmt_name ## prot_name) curl.c: BLOCK_DRIVER_EXPORT(http, http, bdrv_http); BLOCK_DRIVER_EXPORT(https, https, bdrv_https); BLOCK_DRIVER_EXPORT(ftp, ftp, bdrv_ftp); ... iscsi.c (on top of patch 1): BLOCK_DRIVER_EXPORT(iscsi, iscsi, bdrv_iscsi); vmdk.c: BLOCK_DRIVER_EXPORT(vmdk,, bdrv_vmdk); Then the python generator greps for BLOCK_DRIVER_EXPORT, instead of 'static BlockDriver', which is much more reliable (in the sense of whitespace subtlety, field name changing, etc). Fam