From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLNp5-0000nK-7N for qemu-devel@nongnu.org; Sun, 15 Sep 2013 21:42:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VLNoz-0008UI-5P for qemu-devel@nongnu.org; Sun, 15 Sep 2013 21:41:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51084) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLNoy-0008UA-UJ for qemu-devel@nongnu.org; Sun, 15 Sep 2013 21:41:49 -0400 Date: Mon, 16 Sep 2013 09:41:36 +0800 From: Fam Zheng Message-ID: <20130916014136.GC2700@T430s.nay.redhat.com> References: <1379066356-14986-1-git-send-email-famz@redhat.com> <1379066356-14986-6-git-send-email-famz@redhat.com> <5233269B.3030803@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5233269B.3030803@twiddle.net> Subject: Re: [Qemu-devel] [PATCH v9 5/8] module: implement module loading Reply-To: famz@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: peter.maydell@linaro.org, mjt@tls.msk.ru, qemu-devel@nongnu.org, alex@alex.org.uk, pbonzini@redhat.com, vilanova@ac.upc.edu On Fri, 09/13 07:52, Richard Henderson wrote: > On 09/13/2013 02:59 AM, Fam Zheng wrote: > > + const char *module_whitelist[] = { > > + CONFIG_MODULE_WHITELIST > > + }; > > static const char * const module_whitelist[] = ... > OK, thanks. > > + switch (type) { > > + case MODULE_LOAD_BLOCK: > > + path = CONFIG_MODDIR "/block/"; > > + break; > > + case MODULE_LOAD_UI: > > + path = CONFIG_MODDIR "/ui/"; > > + break; > > + case MODULE_LOAD_NET: > > + path = CONFIG_MODDIR "/net/"; > > + break; > > Also, separate the whitelists by type. I.e. > > static const char * const modules_block[] = ... > static const char * const modules_ui[] = ... > static const char * const modules_net[] = ... > > switch (type) { > case MODULE_LOAD_BLOCK: > list = modules_block; > n = ARRAY_SIZE(modules_block); > break; > ... > } > > No need for null termination of the array, as you're currently using. > It's that I'd like to be consistent with block whitelist code style as in bdrv_is_whitelisted(). > > + for (mp = &module_whitelist[0]; *mp; mp++) { > > + fname = g_strdup_printf("%s%s" HOST_DSOSUF, path, *mp); > > + module_load_file(fname); > > + g_free(fname); > > + } > > Why this bizzare mix of g_strdup_printf and compile-time string concatenation? > Certainly you could have arranged for HOST_DSOSUF to be built into the module > name as seen in the arrays. > > Then we're back to the subdirectory vs filename prefix and CONFIG_MODDIR vs any > of several module search path options, the debate of which I don't believe has > concluded. > Perhaps using module type as prefix and building into whitelist can save us creating subdirs for each type and also the separation of the list as you suggested above: switch (type) { case MODULE_LOAD_BLOCK: prefix = "block-"; break; ... } for (mp = &module_whitelist[0]; *mp; mp++) { if (!strncmp(prefix, *mp, sizeof(prefix))) { /* load */ } }