From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLrVo-0008NM-0w for qemu-devel@nongnu.org; Fri, 07 Mar 2014 04:56:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLrVi-0005l7-24 for qemu-devel@nongnu.org; Fri, 07 Mar 2014 04:56:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15976) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLrVh-0005kv-Og for qemu-devel@nongnu.org; Fri, 07 Mar 2014 04:56:09 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s279u9nM003427 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 7 Mar 2014 04:56:09 -0500 From: Markus Armbruster References: <1394073416-12578-1-git-send-email-akong@redhat.com> <1394073416-12578-3-git-send-email-akong@redhat.com> Date: Fri, 07 Mar 2014 10:56:06 +0100 In-Reply-To: <1394073416-12578-3-git-send-email-akong@redhat.com> (Amos Kong's message of "Thu, 6 Mar 2014 10:36:56 +0800") Message-ID: <8738ius56x.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 2/2] query-command-line-options: query all the options in qemu-options.hx List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: pbonzini@redhat.com, lcapitulino@redhat.com, qemu-devel@nongnu.org, jyang@redhat.com, libvirt-list@redhat.com Amos Kong writes: > vm_config_groups[] only contains part of the options which have > argument, and all options which have no argument aren't added > to vm_config_groups[]. Current query-command-line-options only > checks options from vm_config_groups[], so some options will > be lost. > > We have macro in qemu-options.hx to generate a table that > contains all the options. This patch tries to query options > from the table. > > Then we won't lose the legacy options that weren't added to > vm_config_groups[] (eg: -vnc, -smbios). The options that have > no argument will also be returned (eg: -enable-fips) > > Some options that have argument have a NULL desc list, some > options don't have argument, and "parameters" is mandatory > in the past. So we add a new field "argument" to present > if the option takes unspecified arguments. > > This patch also fixes options to match their actual command-line > spelling rather than an alternate name associated with the > option table in use by the command. [...] > diff --git a/util/qemu-config.c b/util/qemu-config.c > index d2facfd..2f89b92 100644 > --- a/util/qemu-config.c > +++ b/util/qemu-config.c > @@ -6,6 +6,16 @@ > #include "hw/qdev.h" > #include "qapi/error.h" > #include "qmp-commands.h" > +#include "qemu-options.h" > + > +#define HAS_ARG 0x0001 > + > +const QEMUOption qemu_options[] = { > + { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL }, > +#define QEMU_OPTIONS_GENERATE_OPTIONS > +#include "qemu-options-wrapper.h" > + { NULL }, > +}; > > static QemuOptsList *vm_config_groups[32]; > static QemuOptsList *drive_config_groups[4]; > @@ -78,6 +88,17 @@ static CommandLineParameterInfoList *get_param_infolist(const QemuOptDesc *desc) > return param_list; > } > > +static int get_group_index(const char *name) > +{ > + int i; > + > + for (i = 0; vm_config_groups[i] != NULL; i++) { > + if (!strcmp(vm_config_groups[i]->name, name)) { > + return i; > + } > + } > + return -1; > +} > /* remove repeated entry from the info list */ > static void cleanup_infolist(CommandLineParameterInfoList *head) > { Please separate functions by an empty line. Actually, please drop get_group_index() and use existing qemu_find_opts_err(name, NULL). [...]