qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, Amos Kong <akong@redhat.com>
Cc: pbonzini@redhat.com, libvirt-list@redhat.com, afaerber@suse.de,
	anthony@codemonkey.ws, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v5 for 2.0 3/3] abort QEMU if group name in option table doesn't match with defined option name
Date: Fri, 28 Mar 2014 09:19:15 -0600	[thread overview]
Message-ID: <533592F3.3000503@redhat.com> (raw)
In-Reply-To: <87bnwqxti2.fsf@blackfin.pond.sub.org>

[-- Attachment #1: Type: text/plain, Size: 2685 bytes --]

On 03/28/2014 08:55 AM, Markus Armbruster wrote:
> Amos Kong <akong@redhat.com> writes:
> 
>> All the options are defined in qemu-options.hx. If we can't find a
>> matched option definition by group name of option table, then the
>> group name doesn't match with defined option name, it's not allowed
>> from 2.0
>>

>> @@ -193,6 +215,12 @@ void qemu_add_opts(QemuOptsList *list)
>>      for (i = 0; i < entries; i++) {
>>          if (vm_config_groups[i] == NULL) {
>>              vm_config_groups[i] = list;
>> +            if (!opt_is_defined(list->name)) {
>> +                error_report("Didn't find a matched option definition, "
>> +                             "group name (%s) of option table must match with "
>> +                             "defined option name (Since 2.0)", list->name);
>> +                abort();
>> +            }
>>              return;
>>          }
>>      }
> 
> Simple!  Wish it was my idea ;)
> 
> Why not simply assert(opt_is_defined(list->name))?

Indeed, using assert() would also solve the problem of the error message
being awkward.

>>  
>> -#define HAS_ARG 0x0001
>> -

>> -
>> -static const QEMUOption qemu_options[] = {
>> -    { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL },
>> -#define QEMU_OPTIONS_GENERATE_OPTIONS
>> -#include "qemu-options-wrapper.h"
>> -    { NULL },
>> -};

>>  
>> +#undef HAS_ARG

HAS_ARG is not very namespace clean.  Prior to your patch, it was used
only in a single file (where we know it doesn't collide).  After your
patch, it is now in a header used by multiple files.

>> +
>>  static gpointer malloc_and_trace(gsize n_bytes)
>>  {
>>      void *ptr = malloc(n_bytes);
> 
> Undefining HAS_ARG here, where it hasn't done any harm, while letting it
> pollute every other compilation unit including qemu-options.h makes no
> sense.

Maybe a better approach would be to create an enum in qemu-options.h of
actual flag values:

typedef enum {
    QEMU_OPT_HAS_ARG = 1,
} QEMUOptionFlags;

and use QEMU_OPT_HAS_ARG instead of HAS_ARG in vl.c.  Additionally, you
either have to s/HAS_ARG/QEMU_OPT_HAS_ARG/ throughout the .hx file, or
you can take a shortcut in qemu-config.c:

#define HAS_ARG QEMU_OPT_HAS_ARG

const QEMUOption qemu_options[] = {
    { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL },
#define QEMU_OPTIONS_GENERATE_OPTIONS
#include "qemu-options-wrapper.h"
    { NULL },
};

#undef HAS_ARG

since that is the only place that includes the .hx file at a point where
HAS_ARG has to be expanded to something useful.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-03-28 15:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-27 13:04 [Qemu-devel] [PATCH v5 for 2.0 0/3] ABI change: change group name of option table to match with option name Amos Kong
2014-03-27 13:04 ` [Qemu-devel] [PATCH v5 for 2.0 1/3] only add qemu_tpmdev_opts when CONFIG_TPM is defined Amos Kong
2014-03-28 12:04   ` Markus Armbruster
2014-03-28 15:47     ` [Qemu-devel] [libvirt] " Eric Blake
2014-03-28 17:46       ` Markus Armbruster
2014-03-27 13:04 ` [Qemu-devel] [PATCH v5 for 2.0 2/3] update names in option tables to match with actual command-line spelling Amos Kong
2014-03-27 13:04 ` [Qemu-devel] [PATCH v5 for 2.0 3/3] abort QEMU if group name in option table doesn't match with defined option name Amos Kong
2014-03-28 12:53   ` Leandro Dorileo
2014-03-28 14:55   ` Markus Armbruster
2014-03-28 15:19     ` Eric Blake [this message]
2014-03-28 17:43       ` Markus Armbruster

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=533592F3.3000503@redhat.com \
    --to=eblake@redhat.com \
    --cc=afaerber@suse.de \
    --cc=akong@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=armbru@redhat.com \
    --cc=libvirt-list@redhat.com \
    --cc=pbonzini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).