spapr: Fix QEMU abort during memory unplug
authorBharata B Rao <bharata@linux.vnet.ibm.com>
Fri, 21 Jul 2017 04:51:06 +0000 (10:21 +0530)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 25 Jul 2017 01:14:25 +0000 (11:14 +1000)
commit8d5981c4fc1342829b23666b7e7b28b4c2ce1d8a
treebae63ad39659cbbd759e5b2d5663be0c4e89c36e
parente8cd4247e96bb2158ef0ae0ff20e72746b9dd32d
spapr: Fix QEMU abort during memory unplug

Commit 0cffce56 (hw/ppc/spapr.c: adding pending_dimm_unplugs to
sPAPRMachineState) introduced a new way to track pending LMBs of DIMM
device that is marked for removal. Since this commit we can hit the
assert in spapr_pending_dimm_unplugs_add() in the following situation:

- DIMM device removal fails as the guest doesn't allow the removal.
- Subsequent attempt to remove the same DIMM would hit the assert
  as the corresponding sPAPRDIMMState is still part of the
  pending_dimm_unplugs list.

Fix this by removing the assert and conditionally adding the
sPAPRDIMMState to pending_dimm_unplugs list only when it is not
already present.

Fixes: 0cffce56ae3501c5783d779f97993ce478acf856
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
[dwg: Tweaked to avoid returning NULL when spapr_pending_dimm_unplugs_add()
 does find an existing entry]
Reviewed-by: Daniel Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/ppc/spapr.c