« Previous | Next » 

Revision cb77d192


Added by Markus Armbruster over 7 years ago

qemu-option: Guard against qemu_opts_set_defaults() misuse

Commit 6d4cd40 fixed qemu_opts_set_defaults() for an existing corner
case, but broke it for another one that can't be reached in current

Quote from its commit message:

I believe [opts_parse()] attempts to do the following:
If options don't yet exist, create new options
Else, if defaults, modify the existing options
Else, if list->merge_lists, modify the existing options
Else, fail

The only caller that passes true for defaults is

The commit message then claims:

A straightforward call of qemu_opts_create() does exactly that.

Wrong. When !list->merge_lists, and the option string doesn't contain
id=, and options without ID exist, then we don't actually modify the
existing options, we create new ones.

Not reachable, because we never pass lists with !list->merge_lists to

Guard against possible (if unlikely) future misuse with assert().

Reported-by: Peter Maydell <>
Signed-off-by: Markus Armbruster <>
Reviewed-by: Eric Blake <>
Signed-off-by: Anthony Liguori <>


  • added
  • modified
  • copied
  • renamed
  • deleted

View differences