thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
a83a9f
From 0a808f2304731f2108b29c3c6777cdd966a03beb Mon Sep 17 00:00:00 2001
a83a9f
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
a83a9f
Date: Wed, 13 Apr 2022 12:33:29 +0100
a83a9f
Subject: [PATCH] migration: Read state once
a83a9f
a83a9f
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
a83a9f
RH-MergeRequest: 255: migration: Read state once
a83a9f
RH-Bugzilla: 2168221
a83a9f
RH-Acked-by: quintela1 <quintela@redhat.com>
a83a9f
RH-Acked-by: Peter Xu <peterx@redhat.com>
a83a9f
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
a83a9f
RH-Commit: [1/1] 215b2009145df37a2caee525991021ce9325686a
a83a9f
a83a9f
The 'status' field for the migration is updated normally using
a83a9f
an atomic operation from the migration thread.
a83a9f
Most readers of it aren't that careful, and in most cases it doesn't
a83a9f
matter.
a83a9f
a83a9f
In query_migrate->fill_source_migration_info the 'state'
a83a9f
is read twice; the first time to decide which state fields to fill in,
a83a9f
and then secondly to copy the state to the status field; that can end up
a83a9f
with a status that's inconsistent; e.g. setting up the fields
a83a9f
for 'setup' and then having an 'active' status.  In that case
a83a9f
libvirt gets upset by the lack of ram info.
a83a9f
The symptom is:
a83a9f
   libvirt.libvirtError: internal error: migration was active, but no RAM info was set
a83a9f
a83a9f
Read the state exactly once in fill_source_migration_info.
a83a9f
a83a9f
This is a possible fix for:
a83a9f
https://bugzilla.redhat.com/show_bug.cgi?id=2074205
a83a9f
a83a9f
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
a83a9f
Message-Id: <20220413113329.103696-1-dgilbert@redhat.com>
a83a9f
Reviewed-by: Juan Quintela <quintela@redhat.com>
a83a9f
Reviewed-by: Peter Xu <peterx@redhat.com>
a83a9f
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
a83a9f
(cherry picked from commit 552de79bfdd5e9e53847eb3c6d6e4cd898a4370e)
a83a9f
---
a83a9f
 migration/migration.c | 5 +++--
a83a9f
 1 file changed, 3 insertions(+), 2 deletions(-)
a83a9f
a83a9f
diff --git a/migration/migration.c b/migration/migration.c
a83a9f
index 5e78028df4..e417d40c44 100644
a83a9f
--- a/migration/migration.c
a83a9f
+++ b/migration/migration.c
a83a9f
@@ -1076,6 +1076,7 @@ static void populate_disk_info(MigrationInfo *info)
a83a9f
 static void fill_source_migration_info(MigrationInfo *info)
a83a9f
 {
a83a9f
     MigrationState *s = migrate_get_current();
a83a9f
+    int state = qatomic_read(&s->state);
a83a9f
     GSList *cur_blocker = migration_blockers;
a83a9f
 
a83a9f
     info->blocked_reasons = NULL;
a83a9f
@@ -1095,7 +1096,7 @@ static void fill_source_migration_info(MigrationInfo *info)
a83a9f
     }
a83a9f
     info->has_blocked_reasons = info->blocked_reasons != NULL;
a83a9f
 
a83a9f
-    switch (s->state) {
a83a9f
+    switch (state) {
a83a9f
     case MIGRATION_STATUS_NONE:
a83a9f
         /* no migration has happened ever */
a83a9f
         /* do not overwrite destination migration status */
a83a9f
@@ -1140,7 +1141,7 @@ static void fill_source_migration_info(MigrationInfo *info)
a83a9f
         info->has_status = true;
a83a9f
         break;
a83a9f
     }
a83a9f
-    info->status = s->state;
a83a9f
+    info->status = state;
a83a9f
 }
a83a9f
 
a83a9f
 typedef enum WriteTrackingSupport {
a83a9f
-- 
a83a9f
2.31.1
a83a9f