Received: from eggs.gnu.org ([2001:4830:134:3::10]:40824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJLvS-0001U0-Oi for qemu-devel@nongnu.org; Fri, 09 Jun 2017 11:34:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJLvO-0004HK-19 for qemu-devel@nongnu.org; Fri, 09 Jun 2017 11:34:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52926) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJLvN-0004Gp-R3 for qemu-devel@nongnu.org; Fri, 09 Jun 2017 11:34:09 -0400 Date: Fri, 9 Jun 2017 12:34:02 -0300 From: Eduardo Habkost Message-ID: <20170609153402.GR5016@thinpad.lan.raisama.net> References: <20170609151615.2589-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170609151615.2589-1-stefanha@redhat.com> Subject: Re: [Qemu-devel] [PATCH] hw/i386: fix nvdimm check error path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, Paolo Bonzini , "Michael S. Tsirkin" , Richard Henderson , Haozhong Zhang On Fri, Jun 09, 2017 at 04:16:15PM +0100, Stefan Hajnoczi wrote: > Commit e987c37aee1752177906847630d32477da57e705 ("hw/i386: check if > nvdimm is enabled before plugging") introduced a check to reject nvdimm > hotplug if -machine pc,nvdimm=on was not given. > > This check executes after pc_dimm_memory_plug() has already completed > and does not reverse the effect of this function in the case of failure. > > Perform the check before calling pc_dimm_memory_plug(). This fixes the > following abort: > > $ qemu -M accel=kvm -m 1G,slots=4,maxmem=8G \ > -object memory-backend-file,id=mem1,share=on,mem-path=nvdimm.dat,size=1G > (qemu) device_add nvdimm,memdev=mem1 > nvdimm is not enabled: missing 'nvdimm' in '-M' > (qemu) device_add nvdimm,memdev=mem1 > Core dumped > > The backtrace is: > > #0 0x00007fffdb5b191f in raise () at /lib64/libc.so.6 > #1 0x00007fffdb5b351a in abort () at /lib64/libc.so.6 > #2 0x00007fffdb5a9da7 in __assert_fail_base () at /lib64/libc.so.6 > #3 0x00007fffdb5a9e52 in () at /lib64/libc.so.6 > #4 0x000055555577a5fa in qemu_ram_set_idstr (new_block=0x555556747a00, name=, dev=dev@entry=0x555556705590) at qemu/exec.c:1709 > #5 0x0000555555a0fe86 in vmstate_register_ram (mr=mr@entry=0x55555673a0e0, dev=dev@entry=0x555556705590) at migration/savevm.c:2293 > #6 0x0000555555965088 in pc_dimm_memory_plug (dev=dev@entry=0x555556705590, hpms=hpms@entry=0x5555566bb0e0, mr=mr@entry=0x555556705630, align=, errp=errp@entry=0x7fffffffc660) > at hw/mem/pc-dimm.c:110 > #7 0x000055555581d89b in pc_dimm_plug (errp=0x7fffffffc6c0, dev=0x555556705590, hotplug_dev=) at qemu/hw/i386/pc.c:1713 > #8 0x000055555581d89b in pc_machine_device_plug_cb (hotplug_dev=, dev=0x555556705590, errp=0x7fffffffc6c0) at qemu/hw/i386/pc.c:2004 > #9 0x0000555555914da6 in device_set_realized (obj=, value=, errp=0x7fffffffc7e8) at hw/core/qdev.c:926 > > Cc: Haozhong Zhang > Signed-off-by: Stefan Hajnoczi Reviewed-by: Eduardo Habkost -- Eduardo