spapr: Improve handling of memory unplug with old guests
commit73598c75df0585e039825e642adede21912dabc7
authorGreg Kurz <groug@kaod.org>
Fri, 8 Jan 2021 17:31:27 +0000 (8 18:31 +0100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Mon, 18 Jan 2021 23:20:29 +0000 (19 10:20 +1100)
treea93fe89b0b8877e353c7ec73711ca24ae71633a1
parentf17969db719ef563d2f7a1b62ea5dd5087ad774a
spapr: Improve handling of memory unplug with old guests

Since commit 1e8b5b1aa16b ("spapr: Allow memory unplug to always succeed")
trying to unplug memory from a guest that doesn't support it (eg. rhel6)
no longer generates an error like it used to. Instead, it leaves the
memory around : only a subsequent reboot or manual use of drmgr within
the guest can complete the hot-unplug sequence. A flag was added to
SpaprMachineClass so that this new behavior only applies to the default
machine type.

We can do better. CAS processes all pending hot-unplug requests. This
means that we don't really care about what the guest supports if
the hot-unplug request happens before CAS.

All guests that we care for, even old ones, set enough bits in OV5
that lead to a non-empty bitmap in spapr->ov5_cas. Use that as a
heuristic to decide if CAS has already occured or not.

Always accept unplug requests that happen before CAS since CAS will
process them. Restore the previous behavior of rejecting them after
CAS when we know that the guest doesn't support memory hot-unplug.

This behavior is suitable for all machine types : this allows to
drop the pre_6_0_memory_unplug flag.

Fixes: 1e8b5b1aa16b ("spapr: Allow memory unplug to always succeed")
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <161012708715.801107.11418801796987916516.stgit@bahia.lan>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/ppc/spapr.c
hw/ppc/spapr_events.c
hw/ppc/spapr_ovec.c
include/hw/ppc/spapr.h
include/hw/ppc/spapr_ovec.h