From patchwork Thu Jun 3 16:48:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 54507 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A4602B6ED0 for ; Fri, 4 Jun 2010 03:10:17 +1000 (EST) Received: from localhost ([127.0.0.1]:37246 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKDvq-0000mR-EY for incoming@patchwork.ozlabs.org; Thu, 03 Jun 2010 13:10:14 -0400 Received: from [140.186.70.92] (port=59636 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKDaz-0002iS-QA for qemu-devel@nongnu.org; Thu, 03 Jun 2010 12:48:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKDau-00067v-Af for qemu-devel@nongnu.org; Thu, 03 Jun 2010 12:48:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32730) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKDau-00067k-3I for qemu-devel@nongnu.org; Thu, 03 Jun 2010 12:48:36 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o53GmYLn023088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Jun 2010 12:48:34 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o53GmE8l028747; Thu, 3 Jun 2010 12:48:33 -0400 From: Jes.Sorensen@redhat.com To: anthony@codemonkey.ws Date: Thu, 3 Jun 2010 18:48:06 +0200 Message-Id: <1275583692-11678-11-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1275583692-11678-1-git-send-email-Jes.Sorensen@redhat.com> References: <1275583692-11678-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Jes Sorensen , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 10/16] Introduce OS specific cmdline argument handling and move SMB arg to os-posix.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jes Sorensen Introduce OS specific cmdline argument handling by calling os_parse_cmd_args() at the end of switch() statement. In addition move SMB argument to os-posix.c Signed-off-by: Jes Sorensen --- os-posix.c | 34 ++++++++++++++++++++++++++++++++++ os-win32.c | 22 ++++++++++++++++++++++ sysemu.h | 9 +++++++++ vl.c | 15 ++------------- 4 files changed, 67 insertions(+), 13 deletions(-) diff --git a/os-posix.c b/os-posix.c index 621ad06..66f2bf5 100644 --- a/os-posix.c +++ b/os-posix.c @@ -33,6 +33,7 @@ /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" #include "sysemu.h" +#include "net/slirp.h" void os_setup_early_signal_handling(void) { @@ -130,3 +131,36 @@ char *os_find_datadir(const char *argv0) } #undef SHARE_SUFFIX #undef BUILD_SUFFIX + +/* + * Duplicate definition from vl.c to avoid messing up the entire build + */ +enum { +#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ + opt_enum, +#define DEFHEADING(text) +#include "qemu-options.h" +#undef DEF +#undef DEFHEADING +#undef GEN_DOCS +}; + +/* + * Parse OS specific command line options. + * return 0 if option handled, -1 otherwise + */ +int os_parse_cmd_args(const QEMUOption *popt, const char *optarg) +{ + int ret = 0; + switch (popt->index) { +#ifdef CONFIG_SLIRP + case QEMU_OPTION_smb: + if (net_slirp_smb(optarg) < 0) + exit(1); + break; +#endif + default: + ret = -1; + } + return ret; +} diff --git a/os-win32.c b/os-win32.c index 1758538..a311a90 100644 --- a/os-win32.c +++ b/os-win32.c @@ -204,3 +204,25 @@ char *os_find_datadir(const char *argv0) } return NULL; } + +/* + * Duplicate definition from vl.c to avoid messing up the entire build + */ +enum { +#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ + opt_enum, +#define DEFHEADING(text) +#include "qemu-options.h" +#undef DEF +#undef DEFHEADING +#undef GEN_DOCS +}; + +/* + * Parse OS specific command line options. + * return 0 if option handled, -1 otherwise + */ +int os_parse_cmd_args(const QEMUOption *popt, const char *optarg) +{ + return -1; +} diff --git a/sysemu.h b/sysemu.h index 72f3734..08ec323 100644 --- a/sysemu.h +++ b/sysemu.h @@ -79,9 +79,18 @@ int qemu_loadvm_state(QEMUFile *f); /* SLIRP */ void do_info_slirp(Monitor *mon); +/* This is needed for vl.c and the OS specific files */ +typedef struct QEMUOption { + const char *name; + int flags; + int index; + uint32_t arch_mask; +} QEMUOption; + /* OS specific functions */ void os_setup_early_signal_handling(void); char *os_find_datadir(const char *argv0); +int os_parse_cmd_args(const QEMUOption *popt, const char *optarg); typedef enum DisplayType { diff --git a/vl.c b/vl.c index 7f22733..838e109 100644 --- a/vl.c +++ b/vl.c @@ -1909,13 +1909,6 @@ enum { #undef GEN_DOCS }; -typedef struct QEMUOption { - const char *name; - int flags; - int index; - uint32_t arch_mask; -} QEMUOption; - static const QEMUOption qemu_options[] = { { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL }, #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ @@ -2624,12 +2617,6 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_bootp: legacy_bootp_filename = optarg; break; -#ifndef _WIN32 - case QEMU_OPTION_smb: - if (net_slirp_smb(optarg) < 0) - exit(1); - break; -#endif case QEMU_OPTION_redir: if (net_slirp_redir(optarg) < 0) exit(1); @@ -3126,6 +3113,8 @@ int main(int argc, char **argv, char **envp) fclose(fp); break; } + default: + os_parse_cmd_args(popt, optarg); } } }