diff -Nru qemu-7.0+dfsg/debian/changelog qemu-7.0+dfsg/debian/changelog --- qemu-7.0+dfsg/debian/changelog 2022-09-19 16:07:24.000000000 +1000 +++ qemu-7.0+dfsg/debian/changelog 2022-10-26 15:22:07.000000000 +1000 @@ -1,3 +1,10 @@ +qemu (1:7.0+dfsg-7ubuntu2lp1982284b1) kinetic; urgency=medium + + * d/p/lp1982284-migration-Read-state-once.patch + (LP: #1982284) + + -- Brett Milford Wed, 26 Oct 2022 05:22:07 +0000 + qemu (1:7.0+dfsg-7ubuntu2) kinetic; urgency=medium [ Paride Legovini ] diff -Nru qemu-7.0+dfsg/debian/patches/lp1982284-migration-Read-state-once.patch qemu-7.0+dfsg/debian/patches/lp1982284-migration-Read-state-once.patch --- qemu-7.0+dfsg/debian/patches/lp1982284-migration-Read-state-once.patch 1970-01-01 10:00:00.000000000 +1000 +++ qemu-7.0+dfsg/debian/patches/lp1982284-migration-Read-state-once.patch 2022-10-26 15:21:56.000000000 +1000 @@ -0,0 +1,61 @@ +From 552de79bfdd5e9e53847eb3c6d6e4cd898a4370e Mon Sep 17 00:00:00 2001 +From: "Dr. David Alan Gilbert" +Date: Wed, 13 Apr 2022 12:33:29 +0100 +Subject: [PATCH] migration: Read state once + +The 'status' field for the migration is updated normally using +an atomic operation from the migration thread. +Most readers of it aren't that careful, and in most cases it doesn't +matter. + +In query_migrate->fill_source_migration_info the 'state' +is read twice; the first time to decide which state fields to fill in, +and then secondly to copy the state to the status field; that can end up +with a status that's inconsistent; e.g. setting up the fields +for 'setup' and then having an 'active' status. In that case +libvirt gets upset by the lack of ram info. +The symptom is: + libvirt.libvirtError: internal error: migration was active, but no RAM info was set + +Read the state exactly once in fill_source_migration_info. + +This is a possible fix for: +https://bugzilla.redhat.com/show_bug.cgi?id=2074205 + +Signed-off-by: Dr. David Alan Gilbert +Message-Id: <20220413113329.103696-1-dgilbert@redhat.com> +Reviewed-by: Juan Quintela +Reviewed-by: Peter Xu +Signed-off-by: Dr. David Alan Gilbert +--- + migration/migration.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/migration/migration.c ++++ b/migration/migration.c +@@ -1073,6 +1073,7 @@ static void populate_disk_info(Migration + static void fill_source_migration_info(MigrationInfo *info) + { + MigrationState *s = migrate_get_current(); ++ int state = qatomic_read(&s->state); + GSList *cur_blocker = migration_blockers; + + info->blocked_reasons = NULL; +@@ -1092,7 +1093,7 @@ static void fill_source_migration_info(M + } + info->has_blocked_reasons = info->blocked_reasons != NULL; + +- switch (s->state) { ++ switch (state) { + case MIGRATION_STATUS_NONE: + /* no migration has happened ever */ + /* do not overwrite destination migration status */ +@@ -1137,7 +1138,7 @@ static void fill_source_migration_info(M + info->has_status = true; + break; + } +- info->status = s->state; ++ info->status = state; + } + + typedef enum WriteTrackingSupport { diff -Nru qemu-7.0+dfsg/debian/patches/series qemu-7.0+dfsg/debian/patches/series --- qemu-7.0+dfsg/debian/patches/series 2022-09-19 16:07:24.000000000 +1000 +++ qemu-7.0+dfsg/debian/patches/series 2022-10-26 15:21:50.000000000 +1000 @@ -38,3 +38,4 @@ ubuntu/lp-1981339-target-s390x-Exit-tb-after-executing-ex_value.patch ubuntu/lp1988710-silence-openbios-array-bounds-false-positive.patch ubuntu/lp1988710-opensbi-Makefile-fix-build-with-binutils-2.38.patch +lp1982284-migration-Read-state-once.patch