qemu-e2k/util
Markus Armbruster 6d4cd40868 qemu-option: Fix qemu_opts_set_defaults() for corner cases
Commit 4f6dd9a changed the initialization of opts in opts_parse() to
this:

    if (defaults) {
        if (!id && !QTAILQ_EMPTY(&list->head)) {
            opts = qemu_opts_find(list, NULL);
        } else {
            opts = qemu_opts_create(list, id, 0);
        }
    } else {
        opts = qemu_opts_create(list, id, 1);
    }

Same as before for !defaults.

If defaults is true, and params has no ID, and options exist, we use
the first assignment.  It sets opts to null if all options have an ID.
opts_parse() then returns null.  qemu_opts_set_defaults() asserts the
value is non-null.  It's the only caller that passes true for
defaults.

To reproduce, try "-M xenpv -machine id=foo" (yes, "id=foo" is silly,
but it shouldn't crash).

I believe the function 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

A straightforward call of qemu_opts_create() does exactly that.

Cc: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1372943363-24081-3-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-07-09 13:38:57 -05:00
..
Makefile.objs create qemu_openpty_raw() helper function and move it to a separate file 2013-06-14 14:28:43 +04:00
acl.c acl: acl_add can't insert before last list element, fix 2013-06-21 22:52:50 +04:00
aes.c aes: make Td[0-5] and Te[0-5] tables non static 2013-04-13 13:51:57 +02:00
bitmap.c build: move libqemuutil.a components to util/ 2013-01-12 18:42:50 +01:00
bitops.c bitops: unroll while loop in find_next_bit() 2013-03-26 13:32:32 +01:00
cache-utils.c build: move libqemuutil.a components to util/ 2013-01-12 18:42:50 +01:00
compatfd.c build: move libqemuutil.a components to util/ 2013-01-12 18:42:50 +01:00
crc32c.c qemu: add castagnoli crc32c checksum algorithm 2013-05-03 10:31:58 +02:00
cutils.c qemu-io: Move qemu_strsep() to cutils.c 2013-06-06 11:27:04 +02:00
envlist.c util: Fix compilation of envlist.c for MinGW 2013-02-02 20:13:19 +00:00
error.c error: add error_setg_file_open() helper 2013-06-17 11:01:14 -04:00
event_notifier-posix.c sysemu: avoid proliferation of include/ subdirectories 2013-04-15 18:19:25 +02:00
event_notifier-win32.c build: move libqemuutil.a components to util/ 2013-01-12 18:42:50 +01:00
fifo8.c hw: move fifo.[ch] to libqemuutil 2013-03-01 13:53:10 +01:00
hbitmap.c hbitmap: Use non-bitops ctzl 2013-02-16 11:11:34 +00:00
hexdump.c Rename hexdump to avoid FreeBSD libutil conflict 2013-05-20 08:20:08 -05:00
host-utils.c host-utils: Improve mulu64 and muls64 2013-02-17 14:28:58 +00:00
iov.c Rename hexdump to avoid FreeBSD libutil conflict 2013-05-20 08:20:08 -05:00
module.c build: move libqemuutil.a components to util/ 2013-01-12 18:42:50 +01:00
notify.c notify: add NotiferWithReturn so notifier list can abort 2013-06-28 09:20:26 +02:00
osdep.c win32: add readv/writev emulation 2013-04-29 10:52:36 +02:00
oslib-posix.c osdep: add qemu_get_local_state_pathname() 2013-05-30 11:37:37 -05:00
oslib-win32.c osdep: add qemu_get_local_state_pathname() 2013-05-30 11:37:37 -05:00
path.c Replace non-portable asprintf by g_strdup_printf 2013-01-19 10:24:43 +00:00
qemu-config.c monitor: introduce query-command-line-options 2013-04-25 10:07:06 -04:00
qemu-error.c build: move libqemuutil.a components to util/ 2013-01-12 18:42:50 +01:00
qemu-openpty.c create qemu_openpty_raw() helper function and move it to a separate file 2013-06-14 14:28:43 +04:00
qemu-option.c qemu-option: Fix qemu_opts_set_defaults() for corner cases 2013-07-09 13:38:57 -05:00
qemu-progress.c build: move libqemuutil.a components to util/ 2013-01-12 18:42:50 +01:00
qemu-sockets.c qemu-socket: don't leak opts on error 2013-06-28 22:10:34 +04:00
qemu-thread-posix.c build: move libqemuutil.a components to util/ 2013-01-12 18:42:50 +01:00
qemu-thread-win32.c build: move libqemuutil.a components to util/ 2013-01-12 18:42:50 +01:00
qemu-timer-common.c Allow clock_gettime() monotonic clock to be utilized on more OS's 2013-04-04 20:22:45 -05:00
unicode.c unicode: New mod_utf8_codepoint() 2013-04-13 19:39:59 +00:00
uri.c clean unnecessary code: don't check g_strdup arg for NULL 2013-05-12 13:25:55 +04:00