hostmem: Fix qemu_opt_get_bool() crash in host_memory_backend_init()
commit6b2699672d5b56f8c2902fb9db9879e8cafb2afe
authorEduardo Habkost <ehabkost@redhat.com>
Thu, 16 Jul 2015 20:29:12 +0000 (16 17:29 -0300)
committerEduardo Habkost <ehabkost@redhat.com>
Wed, 22 Jul 2015 18:09:25 +0000 (22 15:09 -0300)
tree26d83f4bcfc86a6ca1042173697d52f0bad88be5
parentb69b30532e0a80e25449244c01b0cbed000c99a3
hostmem: Fix qemu_opt_get_bool() crash in host_memory_backend_init()

This fixes the following crash, introduced by commit
49d2e648e8087d154d8bf8b91f27c8e05e79d5a6:

  $ gdb --args qemu-system-x86_64 -machine pc,mem-merge=off -object memory-backend-ram,id=ram-node0,size=1024
  [...]
  Program received signal SIGABRT, Aborted.
  (gdb) bt
  #0  0x00007ffff253b8c7 in raise () at /lib64/libc.so.6
  #1  0x00007ffff253d52a in abort () at /lib64/libc.so.6
  #2  0x00007ffff253446d in __assert_fail_base () at /lib64/libc.so.6
  #3  0x00007ffff2534522 in  () at /lib64/libc.so.6
  #4  0x00005555558bb80a in qemu_opt_get_bool_helper (opts=0x55555621b650, name=name@entry=0x5555558ec922 "mem-merge", defval=defval@entry=true, del=del@entry=false) at qemu/util/qemu-option.c:388
  #5  0x00005555558bbb5a in qemu_opt_get_bool (opts=<optimized out>, name=name@entry=0x5555558ec922 "mem-merge", defval=defval@entry=true) at qemu/util/qemu-option.c:398
  #6  0x0000555555720a24 in host_memory_backend_init (obj=0x5555562ac970) at qemu/backends/hostmem.c:226

Instead of using qemu_opt_get_bool(), that didn't work with
qemu_machine_opts for a long time, we can use the corresponding
MachineState fields.

Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
backends/hostmem.c