On 5/7/2026 11:09 AM, Cédric Le Goater wrote:
External email: Use caution opening links or attachments


On 5/5/26 10:14, Avihai Horon wrote:
Pass the device name that approved switchover to
qemu_loadvm_approve_switchover() and log it in the trace for debugging
purposes.
hmm, isn't the trace event in vfio_load_state() enough :

       trace_vfio_load_state(vbasedev->name, data);

May be we can improve it instead ?

Anyhow, I won't object to the change.

We could print "data" more nicely, but the main benefit from having a separate trace is that we can enable only switchover-ack related traces without getting noise from traces of the other VFIO_MIG_FLAG_*. Plus, future switchover-ack users won't need to add a trace of their own and we can also log switchover_ack_pending_num.

I found it very convenient when debugging/testing this feature.

Thanks.



Signed-off-by: Avihai Horon <[email protected]>
---
  migration/savevm.h     | 2 +-
  hw/vfio/migration.c    | 2 +-
  migration/savevm.c     | 4 ++--
  migration/trace-events | 2 +-
  4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/migration/savevm.h b/migration/savevm.h
index 96fdf96d4e..1efbe1d79d 100644
--- a/migration/savevm.h
+++ b/migration/savevm.h
@@ -70,7 +70,7 @@ void qemu_loadvm_state_cleanup(MigrationIncomingState *mis);
  int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis,
                             Error **errp);
  int qemu_load_device_state(QEMUFile *f, Error **errp);
-int qemu_loadvm_approve_switchover(void);
+int qemu_loadvm_approve_switchover(const char *approver);
  int qemu_savevm_state_non_iterable(QEMUFile *f, Error **errp);
  int qemu_savevm_state_non_iterable_early(QEMUFile *f,
                                           JSONWriter *vmdesc,
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 150e28656e..c3dd30d619 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -818,7 +818,7 @@ static int vfio_load_state(QEMUFile *f, void *opaque, int version_id)
                  return -EINVAL;
              }

-            ret = qemu_loadvm_approve_switchover();
+            ret = qemu_loadvm_approve_switchover(vbasedev->name);
              if (ret) {
                  error_report(
                      "%s: qemu_loadvm_approve_switchover failed, err=%d (%s)",
diff --git a/migration/savevm.c b/migration/savevm.c
index d1dd696c17..bd8c6ada5a 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -3158,7 +3158,7 @@ int qemu_load_device_state(QEMUFile *f, Error **errp)
      return 0;
  }

-int qemu_loadvm_approve_switchover(void)
+int qemu_loadvm_approve_switchover(const char *approver)
  {
      MigrationIncomingState *mis = migration_incoming_get_current();

@@ -3167,7 +3167,7 @@ int qemu_loadvm_approve_switchover(void)
      }

      mis->switchover_ack_pending_num--;
- trace_loadvm_approve_switchover(mis->switchover_ack_pending_num);
+    trace_loadvm_approve_switchover(approver, mis->switchover_ack_pending_num);

      if (mis->switchover_ack_pending_num) {
          return 0;
diff --git a/migration/trace-events b/migration/trace-events
index de99d976ab..d9084a2692 100644
--- a/migration/trace-events
+++ b/migration/trace-events
@@ -24,7 +24,7 @@ loadvm_postcopy_ram_handle_discard_end(void) ""
  loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len) "%s: %ud"
  loadvm_process_command(const char *s, uint16_t len) "com=%s len=%d"
  loadvm_process_command_ping(uint32_t val) "0x%x"
-loadvm_approve_switchover(unsigned int switchover_ack_pending_num) "Switchover ack pending num=%u" +loadvm_approve_switchover(const char *approver, unsigned int switchover_ack_pending_num) "Approver %s, switchover_ack_pending_num %u"
  postcopy_ram_listen_thread_exit(void) ""
  postcopy_ram_listen_thread_start(void) ""
  qemu_savevm_send_postcopy_advise(void) ""


Reply via email to