Skip to content

Commit

Permalink
hw/s390x/s390-stattrib: Don't call register_savevm_live() during inst…
Browse files Browse the repository at this point in the history
…ance_init()

We must not call register_savevm_live() from an instance_init() function
(since this could be called multiple times during device introspection).
Move this to the realize() function instead.

Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231020150554.664422-4-thuth@redhat.com>
  • Loading branch information
huth authored and Juan Quintela committed Nov 1, 2023
1 parent bc1bf2a commit 8326857
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions hw/s390x/s390-stattrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,29 @@ static const TypeInfo qemu_s390_stattrib_info = {

/* Generic abstract object: */

static SaveVMHandlers savevm_s390_stattrib_handlers = {
.save_setup = cmma_save_setup,
.save_live_iterate = cmma_save_iterate,
.save_live_complete_precopy = cmma_save_complete,
.state_pending_exact = cmma_state_pending,
.state_pending_estimate = cmma_state_pending,
.save_cleanup = cmma_save_cleanup,
.load_state = cmma_load,
.is_active = cmma_active,
};

static void s390_stattrib_realize(DeviceState *dev, Error **errp)
{
bool ambiguous = false;

object_resolve_path_type("", TYPE_S390_STATTRIB, &ambiguous);
if (ambiguous) {
error_setg(errp, "storage_attributes device already exists");
return;
}

register_savevm_live(TYPE_S390_STATTRIB, 0, 0,
&savevm_s390_stattrib_handlers, dev);
}

static Property s390_stattrib_props[] = {
Expand All @@ -356,24 +371,10 @@ static void s390_stattrib_class_init(ObjectClass *oc, void *data)
device_class_set_props(dc, s390_stattrib_props);
}

static SaveVMHandlers savevm_s390_stattrib_handlers = {
.save_setup = cmma_save_setup,
.save_live_iterate = cmma_save_iterate,
.save_live_complete_precopy = cmma_save_complete,
.state_pending_exact = cmma_state_pending,
.state_pending_estimate = cmma_state_pending,
.save_cleanup = cmma_save_cleanup,
.load_state = cmma_load,
.is_active = cmma_active,
};

static void s390_stattrib_instance_init(Object *obj)
{
S390StAttribState *sas = S390_STATTRIB(obj);

register_savevm_live(TYPE_S390_STATTRIB, 0, 0,
&savevm_s390_stattrib_handlers, sas);

sas->migration_cur_gfn = 0;
}

Expand Down

0 comments on commit 8326857

Please sign in to comment.