From nobody Wed Nov 5 09:06:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499748762492432.27344244351013; Mon, 10 Jul 2017 21:52:42 -0700 (PDT) Received: from localhost ([::1]:44176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUnA9-0004rt-8R for importer@patchew.org; Tue, 11 Jul 2017 00:52:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUmxo-0002nN-GN for qemu-devel@nongnu.org; Tue, 11 Jul 2017 00:39:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUmxl-0007jL-Rt for qemu-devel@nongnu.org; Tue, 11 Jul 2017 00:39:56 -0400 Received: from ozlabs.org ([103.22.144.67]:44707) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dUmxl-0007iP-FJ; Tue, 11 Jul 2017 00:39:53 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3x68Vw6fMLz9t0F; Tue, 11 Jul 2017 14:39:20 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1499747960; bh=SQnZ6B+t5ngqtgcxZM8HsBE4zZb6/e0GEBPGoSscccU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fsR6Kdc8wKZSPTDcTXMBrotUtYqqWVS1WVv3B2u2AUfbRUD8Plank/7oP28lXIE5C DUt5Qiu7fk0UhzjdydDFNwdzdBr108UUGoFoQS156aVII18DreWN97srNVhAobkOSZ ZlefH01iPoSvoYcwekfk4AeHxANMPk/x3Ll5q57w= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 11 Jul 2017 14:39:04 +1000 Message-Id: <20170711043917.1757-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170711043917.1757-1-david@gibson.dropbear.id.au> References: <20170711043917.1757-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 04/17] spapr: fix migration to pseries machine < 2.8 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, surajjs@au1.ibm.com, aik@ozlabs.ru, sbobroff@au1.ibm.com, groug@kaod.org, agraf@suse.de, qemu-ppc@nongnu.org, bharata@linux.vnet.ibm.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Laurent Vivier since commit 5c4537bd ("spapr: Fix 2.7<->2.8 migration of PCI host bridge"), some migration fields are forged from the new ones in spapr_pci_pre_save(). It works well, except when the number of MSI devices is 0, because in this case the function exits immediately. This fix moves the migration code before the exit code. The problem can be reproduced with these commands: source qemu-2.9: qemu-system-ppc64 -monitor stdio -M pseries-2.6 -nodefaults -S destination qemu-2.6: qemu-system-ppc64 -monitor stdio -M pseries-2.6 -nodefaults \ -incoming tcp:0:4444 on the source: migrate tcp:localhost:4444 Destination fails with the following error: qemu-system-ppc64: error while loading state for instance 0x0 of device 'spapr_pci' qemu-system-ppc64: load of migration failed: Invalid argument Signed-off-by: Laurent Vivier Reviewed-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/spapr_pci.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 3b37dcd..f09b4e1 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1873,20 +1873,6 @@ static void spapr_pci_pre_save(void *opaque) gpointer key, value; int i; =20 - g_free(sphb->msi_devs); - sphb->msi_devs =3D NULL; - sphb->msi_devs_num =3D g_hash_table_size(sphb->msi); - if (!sphb->msi_devs_num) { - return; - } - sphb->msi_devs =3D g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_= mig)); - - g_hash_table_iter_init(&iter, sphb->msi); - for (i =3D 0; g_hash_table_iter_next(&iter, &key, &value); ++i) { - sphb->msi_devs[i].key =3D *(uint32_t *) key; - sphb->msi_devs[i].value =3D *(spapr_pci_msi *) value; - } - if (sphb->pre_2_8_migration) { sphb->mig_liobn =3D sphb->dma_liobn[0]; sphb->mig_mem_win_addr =3D sphb->mem_win_addr; @@ -1900,6 +1886,20 @@ static void spapr_pci_pre_save(void *opaque) sphb->mig_mem_win_size +=3D sphb->mem64_win_size; } } + + g_free(sphb->msi_devs); + sphb->msi_devs =3D NULL; + sphb->msi_devs_num =3D g_hash_table_size(sphb->msi); + if (!sphb->msi_devs_num) { + return; + } + sphb->msi_devs =3D g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_= mig)); + + g_hash_table_iter_init(&iter, sphb->msi); + for (i =3D 0; g_hash_table_iter_next(&iter, &key, &value); ++i) { + sphb->msi_devs[i].key =3D *(uint32_t *) key; + sphb->msi_devs[i].value =3D *(spapr_pci_msi *) value; + } } =20 static int spapr_pci_post_load(void *opaque, int version_id) --=20 2.9.4