From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCTXa-000552-1G for qemu-devel@nongnu.org; Fri, 14 Sep 2012 06:54:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TCTXT-0001U4-UH for qemu-devel@nongnu.org; Fri, 14 Sep 2012 06:54:29 -0400 Received: from mail-ie0-f173.google.com ([209.85.223.173]:35604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCTXT-0001Tu-PU for qemu-devel@nongnu.org; Fri, 14 Sep 2012 06:54:23 -0400 Received: by iebc10 with SMTP id c10so6148245ieb.4 for ; Fri, 14 Sep 2012 03:54:22 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 14 Sep 2012 11:54:22 +0100 Message-ID: From: Peter Maydell Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH 24/25] 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, 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 On 13 September 2012 21:12, Jason Baron wrote: > 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. > @@ -1872,12 +1873,15 @@ static int balloon_parse(const char *arg) > return -1; > } > > -char *qemu_find_file(int type, const char *name) > +static char *__qemu_find_file(int type, const char *name, const char *dir) > { > int len; > const char *subdir; > char *buf; > > + if (!dir) > + return NULL; > + > /* Try the name as a straight path first */ > if (access(name, R_OK) == 0) { > return g_strdup(name); This means that every try with a different directory will check the name as a straight path again, which is a bit pointless. The "just try the name" code shouldn't be in this function (which as Paolo suggests should be named qemu_find_file_in_dir()), it should be pulled out into your new qemu_find_file(), which will then look like: * try as plain pathname * try in directory 1 * try in directory 2 -- PMM