ivshmem: Fix unplug of device "ivshmem-plain"pull-misc-2018-10-10
commitb266f1d1123396f9f5df865508f7555ab0c9582a
authorMarkus Armbruster <armbru@redhat.com>
Wed, 26 Sep 2018 16:37:09 +0000 (26 18:37 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 10 Oct 2018 06:01:36 +0000 (10 08:01 +0200)
tree6490da983849564fdc73ff7c5efbca01eeadeb03
parent70b1105930e71813a22f40e4139adcc5d540a5f0
ivshmem: Fix unplug of device "ivshmem-plain"

Commit 2aece63c8a "hostmem: detect host backend memory is being used
properly" fixed "ivshmem-plain" to reject memory backends that are
already in use, and to block their deletion while in use.  Two bugs
escaped review:

* New ivshmem_plain_exit() fails to call ivshmem_exit().  This breaks
  unplug.  Reproducer: migration after unplug still fails with
  "Migration is disabled when using feature 'peer mode' in device
  'ivshmem'".

* It failed to update legacy "ivshmem".  Harmless, because it creates
  the memory backend itself, and nothing else should use it.

Fix by moving the two host_memory_backend_set_mapped() calls into
ivshmem_common_realize() and ivshmem_exit(), guarded by s->hostmem.

Fixes: 2aece63c8a9d2c3a8ff41d2febc4cdeff2633331
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180926163709.22876-1-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
hw/misc/ivshmem.c