nvme: don't unref ctrl_mem when device unrealized
commit20faf0f5f8aba33405a6206cd26f0d2b49ac174a
authorLi Qiang <liq3ea@gmail.com>
Mon, 29 Oct 2018 06:29:40 +0000 (28 23:29 -0700)
committerKevin Wolf <kwolf@redhat.com>
Mon, 12 Nov 2018 16:46:57 +0000 (12 17:46 +0100)
tree995a7904cb927686fe068d092eeeb292ef2ac45e
parentd52e1a0e967a532867149c2d95c2dd664ca22fe8
nvme: don't unref ctrl_mem when device unrealized

Currently, when hotplug/unhotplug nvme device, it will cause an
assert in object.c. Following is the backtrack:

ERROR:qom/object.c:981:object_unref: assertion failed: (obj->ref > 0)

Thread 2 "qemu-system-x86" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffcbd32700 (LWP 18844)]
0x00007fffdb9e4fff in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
/lib/x86_64-linux-gnu/libglib-2.0.so.0
/lib/x86_64-linux-gnu/libglib-2.0.so.0
qom/object.c:981
/home/liqiang02/qemu-upstream/qemu/memory.c:1732
/home/liqiang02/qemu-upstream/qemu/memory.c:285
util/qemu-thread-posix.c:504
/lib/x86_64-linux-gnu/libpthread.so.0

This is caused by memory_region_unref in nvme_exit.

Remove it to make the PCIdevice refcount correct.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/block/nvme.c