From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLUjR-0008UG-Gm for qemu-devel@nongnu.org; Tue, 09 Oct 2012 04:00:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLUjM-0006TJ-KG for qemu-devel@nongnu.org; Tue, 09 Oct 2012 04:00:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9384) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLUjM-0006TD-BN for qemu-devel@nongnu.org; Tue, 09 Oct 2012 03:59:56 -0400 Message-ID: <5073D971.8050907@redhat.com> Date: Tue, 09 Oct 2012 09:59:45 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <9ca2ad159f27ffc4b108a1058718d2c7c13b3e7c.1349749915.git.jbaron@redhat.com> In-Reply-To: <9ca2ad159f27ffc4b108a1058718d2c7c13b3e7c.1349749915.git.jbaron@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 19/21] Add a fallback bios file search, if -L fails. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Baron Cc: aliguori@us.ibm.com, juzhang@redhat.com, mst@redhat.com, jan.kiszka@siemens.com, qemu-devel@nongnu.org, agraf@suse.de, blauwirbel@gmail.com, yamahata@valinux.co.jp, alex.williamson@redhat.com, kevin@koconnor.net, avi@redhat.com, mkletzan@redhat.com, lcapitulino@redhat.com, afaerber@suse.de, armbru@redhat.com, kraxel@redhat.com Il 09/10/2012 05:30, Jason Baron ha scritto: > From: Jason Baron > > If -L is specified, and qemu does not find the bios file in , then > the search fails. Add infrastructure such that the search will continue in > the default paths, if not found in the -L path. > > Signed-off-by: Jason Baron Reviewed-by: Paolo Bonzini > --- > vl.c | 36 +++++++++++++++++++++++++----------- > 1 files changed, 25 insertions(+), 11 deletions(-) > > diff --git a/vl.c b/vl.c > index 77af809..704cff9 100644 > --- a/vl.c > +++ b/vl.c > @@ -177,6 +177,7 @@ int main(int argc, char **argv) > #define MAX_VIRTIO_CONSOLES 1 > > static const char *data_dir; > +static const char *data_dir_fallback; > const char *bios_name = NULL; > enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; > DisplayType display_type = DT_DEFAULT; > @@ -1882,16 +1883,16 @@ static int balloon_parse(const char *arg) > return -1; > } > > -char *qemu_find_file(int type, const char *name) > +static char *qemu_find_file_in_dir(int type, const char *name, const char *dir) > { > int len; > const char *subdir; > char *buf; > > - /* Try the name as a straight path first */ > - if (access(name, R_OK) == 0) { > - return g_strdup(name); > + if (!dir) { > + return NULL; > } > + > switch (type) { > case QEMU_FILE_TYPE_BIOS: > subdir = ""; > @@ -1902,9 +1903,9 @@ char *qemu_find_file(int type, const char *name) > default: > abort(); > } > - len = strlen(data_dir) + strlen(name) + strlen(subdir) + 2; > + len = strlen(dir) + strlen(name) + strlen(subdir) + 2; > buf = g_malloc0(len); > - snprintf(buf, len, "%s/%s%s", data_dir, subdir, name); > + snprintf(buf, len, "%s/%s%s", dir, subdir, name); > if (access(buf, R_OK)) { > g_free(buf); > return NULL; > @@ -1912,6 +1913,21 @@ char *qemu_find_file(int type, const char *name) > return buf; > } > > +char *qemu_find_file(int type, const char *name) > +{ > + char *filename; > + > + /* Try the name as a straight path first */ > + if (access(name, R_OK) == 0) { > + return g_strdup(name); > + } > + filename = qemu_find_file_in_dir(type, name, data_dir); > + if (!filename) { > + filename = qemu_find_file_in_dir(type, name, data_dir_fallback); > + } > + return filename; > +} > + > static int device_help_func(QemuOpts *opts, void *opaque) > { > return qdev_device_help(opts); > @@ -3349,12 +3365,10 @@ int main(int argc, char **argv, char **envp) > > /* If no data_dir is specified then try to find it relative to the > executable path. */ > - if (!data_dir) { > - data_dir = os_find_datadir(argv[0]); > - } > + data_dir_fallback = os_find_datadir(argv[0]); > /* If all else fails use the install path specified when building. */ > - if (!data_dir) { > - data_dir = CONFIG_QEMU_DATADIR; > + if (!data_dir_fallback) { > + data_dir_fallback = CONFIG_QEMU_DATADIR; > } > > /* >