@@ -455,10 +455,9 @@ void spapr_drc_reset(SpaprDrc *drc)
}
}
-bool spapr_drc_needed(void *opaque)
+static bool spapr_drc_needed(void *opaque)
{
SpaprDrc *drc = (SpaprDrc *)opaque;
- SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
/* If no dev is plugged in there is no need to migrate the DRC state */
if (!drc->dev) {
@@ -469,7 +468,7 @@ bool spapr_drc_needed(void *opaque)
* We need to migrate the state if it's not equal to the expected
* long-term state, which is the same as the coldplugged initial
* state */
- return (drc->state != drck->ready_state);
+ return !spapr_drc_device_ready(drc);
}
static const VMStateDescription vmstate_spapr_drc = {
@@ -1642,18 +1642,24 @@ static uint32_t cas_check_pvr(SpaprMachineState *spapr, PowerPCCPU *cpu,
static bool spapr_hotplugged_dev_before_cas(void)
{
- Object *drc_container, *obj;
+ Object *drc_container;
ObjectProperty *prop;
ObjectPropertyIterator iter;
drc_container = container_get(object_get_root(), "/dr-connector");
object_property_iter_init(&iter, drc_container);
while ((prop = object_property_iter_next(&iter))) {
+ SpaprDrc *drc;
+
if (!strstart(prop->type, "link<", NULL)) {
continue;
}
- obj = object_property_get_link(drc_container, prop->name, NULL);
- if (spapr_drc_needed(obj)) {
+ drc = SPAPR_DR_CONNECTOR(object_property_get_link(drc_container,
+ prop->name, NULL));
+ if (!drc->dev) {
+ continue;
+ }
+ if (!spapr_drc_device_ready(drc)) {
return true;
}
}
@@ -269,7 +269,13 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask);
void spapr_drc_attach(SpaprDrc *drc, DeviceState *d, Error **errp);
void spapr_drc_detach(SpaprDrc *drc);
-bool spapr_drc_needed(void *opaque);
+
+static inline bool spapr_drc_device_ready(SpaprDrc *drc)
+{
+ SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
+
+ return drc->state == drck->ready_state;
+}
static inline bool spapr_drc_unplug_requested(SpaprDrc *drc)
{
We currently don't support hotplug of devices between boot and CAS. If this happens a CAS reboot is triggered. We detect this during CAS using the spapr_drc_needed() function which is essentially a VMStateDescription .needed callback. Even if the condition for CAS reboot happens to be the same as for DRC migration, it looks wrong to use a migration related helper for this. Introduce a helper with more explicit semantics (ie. the device attached to this DRC is ready or not) and use it in both CAS and DRC migration code. This doesn't change any behaviour. Signed-off-by: Greg Kurz <groug@kaod.org> --- hw/ppc/spapr_drc.c | 5 ++--- hw/ppc/spapr_hcall.c | 12 +++++++++--- include/hw/ppc/spapr_drc.h | 8 +++++++- 3 files changed, 18 insertions(+), 7 deletions(-)