From patchwork Thu Jul 16 20:39:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 496869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5ECDF140773 for ; Fri, 17 Jul 2015 06:39:47 +1000 (AEST) Received: from localhost ([::1]:41844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFpwX-0004AG-K9 for incoming@patchwork.ozlabs.org; Thu, 16 Jul 2015 16:39:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFpwG-0003P0-RK for qemu-devel@nongnu.org; Thu, 16 Jul 2015 16:39:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFpwD-0006Pe-LN for qemu-devel@nongnu.org; Thu, 16 Jul 2015 16:39:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFpwD-0006NV-Fu for qemu-devel@nongnu.org; Thu, 16 Jul 2015 16:39:25 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 3AB8719F25D for ; Thu, 16 Jul 2015 20:39:24 +0000 (UTC) Received: from localhost (ovpn-113-45.phx2.redhat.com [10.3.113.45]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6GKdN08014519; Thu, 16 Jul 2015 16:39:23 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 16 Jul 2015 17:39:17 -0300 Message-Id: <1437079157-6316-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Marcel Apfelbaum Subject: [Qemu-devel] [PATCH] hostmem: Fix qemu_opt_get_bool() crash in host_memory_backend_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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=, 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 machine QOM properties directly. Signed-off-by: Eduardo Habkost Reviewed-by: Marcel Apfelbaum --- backends/hostmem.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index 61c1ac0..38a32ed 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -10,6 +10,7 @@ * See the COPYING file in the top-level directory. */ #include "sysemu/hostmem.h" +#include "hw/boards.h" #include "qapi/visitor.h" #include "qapi-types.h" #include "qapi-visit.h" @@ -223,10 +224,10 @@ static void host_memory_backend_init(Object *obj) { HostMemoryBackend *backend = MEMORY_BACKEND(obj); - backend->merge = qemu_opt_get_bool(qemu_get_machine_opts(), - "mem-merge", true); - backend->dump = qemu_opt_get_bool(qemu_get_machine_opts(), - "dump-guest-core", true); + backend->merge = object_property_get_bool(OBJECT(current_machine), + "mem-merge", &error_abort); + backend->dump = object_property_get_bool(OBJECT(current_machine), + "dump-guest-core", &error_abort); backend->prealloc = mem_prealloc; object_property_add_bool(obj, "merge",