Skip to contentSkip to conversation

Migration: Add trace points for vmstate handler insertion/removal

PATCH In review Peter Xu 2 participants 3 messages Oct 18, 2024

lore
Share & tools
lore

Peter Xu

author
#0 lore raw

PATCH 1/1 Migration: Add trace points for vmstate handler insertion/removal

SaveStateEntry has lots of magics internally, on alias_id, get_id() being able to overwrite the original idstr, compat fields, ID_ANY, and so on. It may not be always clear that what all these fields are being registered for some device we care.

Add trace points for SaveStateEntry insertions/removals, so that we know what was being registered. For insertions, we dump everything that might be useful. For removal, only section_id is needed because that's the unique identifier for an SeveStateEntry.

Cc Laurent Vivier <[email protected]>
Cc Fabiano Rosas <[email protected]>
---
 migration/savevm.c     | 7 +++++++
 migration/trace-events | 2 ++
 2 files changed, 9 insertions(+)
migration/savevm.c +7 -0
index e796436979..57f058bd40 100644
@@ -718,6 +718,11 @@ static void savevm_state_handler_insert(SaveStateEntry *nse)
 
     assert(priority <= MIG_PRI_MAX);
 
+    trace_vmstate_handler_insert(
+        nse->idstr, nse->instance_id, nse->alias_id, nse->version_id,
+        nse->section_id, nse->compat ? nse->compat->idstr : NULL,
+        nse->compat ? nse->compat->instance_id : 0);
+
     /*
      * This should never happen otherwise migration will probably fail
      * silently somewhere because we can be wrongly applying one
@@ -754,6 +759,8 @@ static void savevm_state_handler_remove(SaveStateEntry *se)
     SaveStateEntry *next;
     MigrationPriority priority = save_state_priority(se);
 
+    trace_vmstate_handler_remove(se->section_id);
+
     if (se == savevm_state.handler_pri_head[priority]) {
         next = QTAILQ_NEXT(se, entry);
         if (next != NULL && save_state_priority(next) == priority) {
migration/trace-events +2 -0
index 0638183056..3411f2f699 100644
@@ -50,6 +50,8 @@ vmstate_load(const char *idstr, const char *vmsd_name) "%s, %s"
 vmstate_downtime_save(const char *type, const char *idstr, uint32_t instance_id, int64_t downtime) "type=%s idstr=%s instance_id=%d downtime=%"PRIi64
 vmstate_downtime_load(const char *type, const char *idstr, uint32_t instance_id, int64_t downtime) "type=%s idstr=%s instance_id=%d downtime=%"PRIi64
 vmstate_downtime_checkpoint(const char *checkpoint) "%s"
+vmstate_handler_insert(char *idstr, uint32_t instance_id, int alias_id, int version_id, int section_id, char *compat_idstr, int compat_instance_id) "id=%s instance_id=%"PRIu32" alias_id=%d version_id=%d section_id=%d compat_id=%s compat_instance_id=%d"
+vmstate_handler_remove(int section_id) "section_id=%d"
 postcopy_pause_incoming(void) ""
 postcopy_pause_incoming_continued(void) ""
 postcopy_page_req_sync(void *host_addr) "sync page req %p"
Signature · 1 line
2.45.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Peter Xu

SaveStateEntry has lots of magics internally, on alias_id, get_id() being able to overwrite the original idstr, compat fields, ID_ANY, and so on. It may not be always clear that what all these fields are being registered for some device we care.

Quoted 8 lines

Add trace points for SaveStateEntry insertions/removals, so that we know what was being registered. For insertions, we dump everything that might be useful. For removal, only section_id is needed because that's the unique identifier for an SeveStateEntry.

Cc Laurent Vivier <[email protected]>
Cc Fabiano Rosas <[email protected]>
author
#2 lore raw
In reply to Peter Xu
Quoted 5 lines · Peter Xu

SaveStateEntry has lots of magics internally, on alias_id, get_id() being able to overwrite the original idstr, compat fields, ID_ANY, and so on. It may not be always clear that what all these fields are being registered for some device we care.

Quoted 8 lines

Add trace points for SaveStateEntry insertions/removals, so that we know what was being registered. For insertions, we dump everything that might be useful. For removal, only section_id is needed because that's the unique identifier for an SeveStateEntry.

Cc Laurent Vivier <[email protected]>
Cc Fabiano Rosas <[email protected]>

queued.

Signature · 1 line
Peter Xu