All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Jes.Sorensen@redhat.com
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 10/16] Introduce OS specific cmdline argument handling and move SMB arg to os-posix.c
Date: Fri, 04 Jun 2010 10:15:42 +0200	[thread overview]
Message-ID: <m3fx138b81.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <1275583692-11678-11-git-send-email-Jes.Sorensen@redhat.com> (Jes Sorensen's message of "Thu, 3 Jun 2010 18:48:06 +0200")

Jes.Sorensen@redhat.com writes:

> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> 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 <Jes.Sorensen@redhat.com>
> ---
>  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

Was #ifndef _WIN32 before.  Impact?

> +    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
> +};

I agree with Richard: this is gross.

> +
> +/*
> + * 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;
> +

Ugh.

>  /* 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);
>              }
>          }
>      }

Is this minor improvement of vl.c really worth the headaches elsewhere?

  parent reply	other threads:[~2010-06-04  8:15 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-03 16:47 [Qemu-devel] [PATCH 00/16] clean up vl.c code Jes.Sorensen
2010-06-03 16:47 ` [Qemu-devel] [PATCH 01/16] vl.c: Remove double include of netinet/in.h for Solaris Jes.Sorensen
2010-06-03 16:47 ` [Qemu-devel] [PATCH 02/16] Create qemu-os-win32.h and move WIN32 specific declarations there Jes.Sorensen
2010-06-03 16:47 ` [Qemu-devel] [PATCH 03/16] Introduce os-win32.c and move polling functions from vl.c Jes.Sorensen
2010-06-03 16:48 ` [Qemu-devel] [PATCH 04/16] vl.c: Move host_main_loop_wait() to OS specific files Jes.Sorensen
2010-06-03 16:48 ` [Qemu-devel] [PATCH 05/16] Introduce os-posix.c and create os_setup_signal_handling() Jes.Sorensen
2010-06-03 20:50   ` Richard Henderson
2010-06-04  6:45     ` Jes Sorensen
2010-06-03 16:48 ` [Qemu-devel] [PATCH 06/16] Move win32 early signal handling setup to os_setup_signal_handling() Jes.Sorensen
2010-06-03 16:48 ` [Qemu-devel] [PATCH 07/16] Rename os_setup_signal_handling() to os_setup_early_signal_handling() Jes.Sorensen
2010-06-03 16:48 ` [Qemu-devel] [PATCH 08/16] Move main signal handler setup to os specificfiles Jes.Sorensen
2010-06-03 20:52   ` Richard Henderson
2010-06-04  6:45     ` Jes Sorensen
2010-06-04  7:45       ` Markus Armbruster
2010-06-03 16:48 ` [Qemu-devel] [PATCH 09/16] Move find_datadir to OS specific files Jes.Sorensen
2010-06-03 16:48 ` [Qemu-devel] [PATCH 10/16] Introduce OS specific cmdline argument handling and move SMB arg to os-posix.c Jes.Sorensen
2010-06-03 20:58   ` Richard Henderson
2010-06-04  6:47     ` Jes Sorensen
2010-06-04 14:49       ` Richard Henderson
2010-06-04 14:51         ` Jes Sorensen
2010-06-04  8:15   ` Markus Armbruster [this message]
2010-06-04  8:21     ` Jes Sorensen
2010-06-04 10:39       ` [Qemu-devel] " Paolo Bonzini
2010-06-04 11:59         ` Jes Sorensen
2010-06-04 12:04       ` [Qemu-devel] " Markus Armbruster
2010-06-04 12:11         ` Jes Sorensen
2010-06-03 16:48 ` [Qemu-devel] [PATCH 11/16] Move runas handling from vl.c to OS specific files Jes.Sorensen
2010-06-03 21:00   ` Richard Henderson
2010-06-03 16:48 ` [Qemu-devel] [PATCH 12/16] Move chroot handling " Jes.Sorensen
2010-06-03 21:02   ` Richard Henderson
2010-06-04  6:48     ` Jes Sorensen
2010-06-03 16:48 ` [Qemu-devel] [PATCH 13/16] Move daemonize " Jes.Sorensen
2010-06-03 16:48 ` [Qemu-devel] [PATCH 14/16] Make os_change_process_uid and os_change_root os-posix.c local Jes.Sorensen
2010-06-03 16:48 ` [Qemu-devel] [PATCH 15/16] Move line-buffering setup to OS specific files Jes.Sorensen
2010-06-03 16:48 ` [Qemu-devel] [PATCH 16/16] Move set_proc_name() " Jes.Sorensen
2010-06-04  8:21 ` [Qemu-devel] [PATCH 00/16] clean up vl.c code Markus Armbruster
2010-06-04  8:23   ` Jes Sorensen
2010-06-04 11:54     ` Markus Armbruster
2010-06-04 11:57       ` Jes Sorensen
2010-06-09  7:07         ` Markus Armbruster
2010-06-09  8:14           ` Jes Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3fx138b81.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.