From nobody Sun Apr 28 21:02:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150538944064017.66195622423129; Thu, 14 Sep 2017 04:44:00 -0700 (PDT) Received: from localhost ([::1]:47063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsSYp-0000Yk-Lm for importer@patchew.org; Thu, 14 Sep 2017 07:43:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsSXd-00089j-FF for qemu-devel@nongnu.org; Thu, 14 Sep 2017 07:42:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsSXY-0005Va-JQ for qemu-devel@nongnu.org; Thu, 14 Sep 2017 07:42:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43021) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsSXY-0005UT-92 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 07:42:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4ABD081DE3 for ; Thu, 14 Sep 2017 11:42:39 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-51.ams2.redhat.com [10.36.117.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 211C65C66F; Thu, 14 Sep 2017 11:42:37 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 37F613F10F; Thu, 14 Sep 2017 13:42:36 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4ABD081DE3 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 14 Sep 2017 13:42:35 +0200 Message-Id: <20170914114236.25343-2-kraxel@redhat.com> In-Reply-To: <20170914114236.25343-1-kraxel@redhat.com> References: <20170914114236.25343-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 14 Sep 2017 11:42:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/2] add qemu_add_data_dir() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add helper function to add a directory to the qemu search path, so we don't duplicate the checks. Add a check for duplicate entries, so we stop trying to open files twice. Signed-off-by: Gerd Hoffmann --- vl.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/vl.c b/vl.c index fb1f05b937..37a3401920 100644 --- a/vl.c +++ b/vl.c @@ -2272,6 +2272,24 @@ char *qemu_find_file(int type, const char *name) return NULL; } =20 +static void qemu_add_data_dir(const char *path) +{ + int i; + + if (path =3D=3D NULL) { + return; + } + if (data_dir_idx =3D=3D ARRAY_SIZE(data_dir)) { + return; + } + for (i =3D 0; i < data_dir_idx; i++) { + if (strcmp(data_dir[i], path) =3D=3D 0) { + return; /* duplicate */ + } + } + data_dir[data_dir_idx++] =3D path; +} + static inline bool nonempty_str(const char *str) { return str && *str; @@ -3450,8 +3468,8 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_L: if (is_help_option(optarg)) { list_data_dirs =3D true; - } else if (data_dir_idx < ARRAY_SIZE(data_dir)) { - data_dir[data_dir_idx++] =3D optarg; + } else { + qemu_add_data_dir(optarg); } break; case QEMU_OPTION_bios: @@ -4216,16 +4234,10 @@ int main(int argc, char **argv, char **envp) =20 /* If no data_dir is specified then try to find it relative to the executable path. */ - if (data_dir_idx < ARRAY_SIZE(data_dir)) { - data_dir[data_dir_idx] =3D os_find_datadir(); - if (data_dir[data_dir_idx] !=3D NULL) { - data_dir_idx++; - } - } + qemu_add_data_dir(os_find_datadir()); + /* If all else fails use the install path specified when building. */ - if (data_dir_idx < ARRAY_SIZE(data_dir)) { - data_dir[data_dir_idx++] =3D CONFIG_QEMU_DATADIR; - } + qemu_add_data_dir(CONFIG_QEMU_DATADIR); =20 /* -L help lists the data directories and exits. */ if (list_data_dirs) { --=20 2.9.3 From nobody Sun Apr 28 21:02:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505389516927132.52782278574318; Thu, 14 Sep 2017 04:45:16 -0700 (PDT) Received: from localhost ([::1]:47068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsSa2-0003Jn-LW for importer@patchew.org; Thu, 14 Sep 2017 07:45:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsSXd-00089l-I6 for qemu-devel@nongnu.org; Thu, 14 Sep 2017 07:42:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsSXY-0005WU-VK for qemu-devel@nongnu.org; Thu, 14 Sep 2017 07:42:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47118) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsSXY-0005VF-Mg for qemu-devel@nongnu.org; Thu, 14 Sep 2017 07:42:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BCA197EBDC for ; Thu, 14 Sep 2017 11:42:39 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-51.ams2.redhat.com [10.36.117.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22EEA6C928; Thu, 14 Sep 2017 11:42:37 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 40F9B3F110; Thu, 14 Sep 2017 13:42:36 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BCA197EBDC Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 14 Sep 2017 13:42:36 +0200 Message-Id: <20170914114236.25343-3-kraxel@redhat.com> In-Reply-To: <20170914114236.25343-1-kraxel@redhat.com> References: <20170914114236.25343-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 14 Sep 2017 11:42:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/2] Add --firmwarepath to configure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a firmware path config option to configure. Multiple directories are accepted, with the usual colon as separator. Default value is ${prefix}/share/qemu-firmware. The path is searched in addition to the current search path (typically ${prefix}/share/qemu). This prepares qemu for the planned split of the prebuilt firmware blobs into a separate project. Distributions can also use this to get rid of the firmware symlink farm and add -- for example -- /usr/share/seabios to the firmware path instead. Signed-off-by: Gerd Hoffmann --- configure | 6 ++++++ vl.c | 12 +++++++++--- scripts/create_config | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/configure b/configure index fd7e3a5e81..870bdbd3e4 100755 --- a/configure +++ b/configure @@ -332,6 +332,7 @@ modules=3D"no" prefix=3D"/usr/local" mandir=3D"\${prefix}/share/man" datadir=3D"\${prefix}/share" +firmwarepath=3D"\${prefix}/share/qemu-firmware" qemu_docdir=3D"\${prefix}/share/doc/qemu" bindir=3D"\${prefix}/bin" libdir=3D"\${prefix}/lib" @@ -915,6 +916,8 @@ for opt do ;; --localstatedir=3D*) local_statedir=3D"$optarg" ;; + --firmwarepath=3D*) firmwarepath=3D"$optarg" + ;; --sbindir=3D*|--sharedstatedir=3D*|\ --oldincludedir=3D*|--datarootdir=3D*|--infodir=3D*|--localedir=3D*|\ --htmldir=3D*|--dvidir=3D*|--pdfdir=3D*|--psdir=3D*) @@ -1418,6 +1421,7 @@ Advanced options (experts only): --libdir=3DPATH install libraries in PATH --sysconfdir=3DPATH install config in PATH$confsuffix --localstatedir=3DPATH install local state in PATH (set at runtime o= n win32) + --firmwarepath=3DPATH search PATH for firmware files --with-confsuffix=3DSUFFIX suffix for QEMU data inside datadir/libdir/sy= sconfdir [$confsuffix] --enable-debug enable common debug build options --disable-strip disable stripping binaries @@ -5259,6 +5263,7 @@ libs_softmmu=3D"$pixman_libs $libs_softmmu" =20 echo "Install prefix $prefix" echo "BIOS directory $(eval echo $qemu_datadir)" +echo "firmware path $(eval echo $firmwarepath)" echo "binary directory $(eval echo $bindir)" echo "library directory $(eval echo $libdir)" echo "module directory $(eval echo $qemu_moddir)" @@ -5450,6 +5455,7 @@ echo "mandir=3D$mandir" >> $config_host_mak echo "sysconfdir=3D$sysconfdir" >> $config_host_mak echo "qemu_confdir=3D$qemu_confdir" >> $config_host_mak echo "qemu_datadir=3D$qemu_datadir" >> $config_host_mak +echo "qemu_firmwarepath=3D$firmwarepath" >> $config_host_mak echo "qemu_docdir=3D$qemu_docdir" >> $config_host_mak echo "qemu_moddir=3D$qemu_moddir" >> $config_host_mak if test "$mingw32" =3D "no" ; then diff --git a/vl.c b/vl.c index 37a3401920..da6dfaf9d4 100644 --- a/vl.c +++ b/vl.c @@ -3048,6 +3048,7 @@ int main(int argc, char **argv, char **envp) Error *main_loop_err =3D NULL; Error *err =3D NULL; bool list_data_dirs =3D false; + char **dirs; typedef struct BlockdevOptions_queue { BlockdevOptions *bdo; Location loc; @@ -4232,11 +4233,16 @@ int main(int argc, char **argv, char **envp) qemu_set_log(0); } =20 - /* If no data_dir is specified then try to find it relative to the - executable path. */ + /* add configured firmware directories */ + dirs =3D g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S= , 0); + for (i =3D 0; dirs[i] !=3D NULL; i++) { + qemu_add_data_dir(dirs[i]); + } + + /* try to find datadir relative to the executable path */ qemu_add_data_dir(os_find_datadir()); =20 - /* If all else fails use the install path specified when building. */ + /* add the datadir specified when building */ qemu_add_data_dir(CONFIG_QEMU_DATADIR); =20 /* -L help lists the data directories and exits. */ diff --git a/scripts/create_config b/scripts/create_config index e6929dd61e..603b826886 100755 --- a/scripts/create_config +++ b/scripts/create_config @@ -15,7 +15,7 @@ case $line in echo "#define QEMU_VERSION_MINOR $minor" echo "#define QEMU_VERSION_MICRO $micro" ;; - qemu_*dir=3D*) # qemu-specific directory configuration + qemu_*dir=3D* | qemu_*path=3D*) # qemu-specific directory configuration name=3D${line%=3D*} value=3D${line#*=3D} define_name=3D$(echo $name | LC_ALL=3DC tr '[a-z]' '[A-Z]') --=20 2.9.3