From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=57818 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKVdE-0002gg-0B for qemu-devel@nongnu.org; Fri, 04 Jun 2010 08:04:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKVdC-0002t5-IG for qemu-devel@nongnu.org; Fri, 04 Jun 2010 08:04:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38209) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKVdC-0002sq-1x for qemu-devel@nongnu.org; Fri, 04 Jun 2010 08:04:10 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 10/16] Introduce OS specific cmdline argument handling and move SMB arg to os-posix.c References: <1275583692-11678-1-git-send-email-Jes.Sorensen@redhat.com> <1275583692-11678-11-git-send-email-Jes.Sorensen@redhat.com> <4C08B797.7060702@redhat.com> Date: Fri, 04 Jun 2010 14:04:02 +0200 In-Reply-To: <4C08B797.7060702@redhat.com> (Jes Sorensen's message of "Fri, 04 Jun 2010 10:21:43 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jes Sorensen Cc: qemu-devel@nongnu.org Jes Sorensen writes: > On 06/04/10 10:15, Markus Armbruster wrote: >> Jes.Sorensen@redhat.com writes: >>> + * 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 >> >> Was #ifndef _WIN32 before. Impact? > > It was moved to os-posix.c which is only built for non _WIN32, so it has > the same effect, except it's not full of ugly #ifdef's I missed the fact that it is under #ifdef CONFIG_SLIRP in the current code. Sorry for the noise. >>> +/* >>> + * 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 >>> +}; >> >> I agree with Richard: this is gross. > > The enum creation is gross by itself. Only way to get around not > duplicating it is to create a new header file to hold just that? > >>> +/* 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; >>> + >> >> Ugh. > > What do you mean? The real ugh! here is that it was created as a > typedef. I can change the function to pass in just the index, but I > don't know if we will have cases where the rest is needed. Moving stuff out of the vl.c grabbag is cool. Moving stuff into the sysemu.h grabbag is very uncool. >> Is this minor improvement of vl.c really worth the headaches elsewhere? > > vl.c as it is today is gross and un-maintainable. This patch gets rid of > a lot of the ugly #ifdefs and makes the code easier to read and maintain. I'm not arguing against your patch, just trying to help making it even better.