From patchwork Wed May 2 16:07:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 156484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5459EB6FA5 for ; Thu, 3 May 2012 02:08:01 +1000 (EST) Received: from localhost ([::1]:43990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPc5u-0003UR-Jm for incoming@patchwork.ozlabs.org; Wed, 02 May 2012 12:07:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPc5M-0002eC-Mv for qemu-devel@nongnu.org; Wed, 02 May 2012 12:07:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPc5C-0008Je-H9 for qemu-devel@nongnu.org; Wed, 02 May 2012 12:07:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27129) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPc5C-0008J1-8J for qemu-devel@nongnu.org; Wed, 02 May 2012 12:07:14 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q42G7B1B015597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 2 May 2012 12:07:11 -0400 Received: from blackpad.lan.raisama.net (ovpn-116-79.ams2.redhat.com [10.36.116.79]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q42G756E025446; Wed, 2 May 2012 12:07:06 -0400 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id A248620088C; Wed, 2 May 2012 13:07:30 -0300 (BRT) From: Eduardo Habkost To: qemu-devel@nongnu.org, Anthony Liguori Date: Wed, 2 May 2012 13:07:25 -0300 Message-Id: <1335974850-30180-2-git-send-email-ehabkost@redhat.com> In-Reply-To: <1335974850-30180-1-git-send-email-ehabkost@redhat.com> References: <1335974850-30180-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: libvir-list@redhat.com, Jiri Denemark Subject: [Qemu-devel] [PATCH qemu 1/6] move code to read default config files to a separate function (v2) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Function added to arch_init.c because it depends on arch-specific settings. Changes v1 -> v2: - Move qemu_read_default_config_file() prototype to qemu-config.h Signed-off-by: Eduardo Habkost --- arch_init.c | 18 ++++++++++++++++++ qemu-config.h | 4 ++++ vl.c | 10 ++-------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/arch_init.c b/arch_init.c index 9a35aee..4008115 100644 --- a/arch_init.c +++ b/arch_init.c @@ -112,6 +112,24 @@ const uint32_t arch_type = QEMU_ARCH; #define ALL_EQ(v1, v2) ((v1) == (v2)) #endif + +int qemu_read_default_config_files(void) +{ + int ret; + + ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf"); + if (ret < 0 && ret != -ENOENT) { + return ret; + } + + ret = qemu_read_config_file(arch_config_name); + if (ret < 0 && ret != -ENOENT) { + return ret; + } + + return 0; +} + static int is_dup_page(uint8_t *page) { VECTYPE *p = (VECTYPE *)page; diff --git a/qemu-config.h b/qemu-config.h index 20d707f..ff934a1 100644 --- a/qemu-config.h +++ b/qemu-config.h @@ -16,4 +16,8 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname); int qemu_read_config_file(const char *filename); +/* Read default Qemu config files + */ +int qemu_read_default_config_files(void); + #endif /* QEMU_CONFIG_H */ diff --git a/vl.c b/vl.c index ae91a8a..1e5e593 100644 --- a/vl.c +++ b/vl.c @@ -2354,14 +2354,8 @@ int main(int argc, char **argv, char **envp) if (defconfig) { int ret; - - ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf"); - if (ret < 0 && ret != -ENOENT) { - exit(1); - } - - ret = qemu_read_config_file(arch_config_name); - if (ret < 0 && ret != -ENOENT) { + ret = qemu_read_default_config_files(); + if (ret < 0) { exit(1); } }