From nobody Tue Nov 4 15:45:45 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; 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 1503968389218374.004126143945; Mon, 28 Aug 2017 17:59:49 -0700 (PDT) Received: from localhost ([::1]:42128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUsd-0006P5-81 for importer@patchew.org; Mon, 28 Aug 2017 20:59:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCq-0001jz-Fy for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCn-000698-AY for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35200 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCn-00067v-64 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:33 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8CG017802 for ; Mon, 28 Aug 2017 20:16:32 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2ww9f-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:32 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:31 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:29 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GTwk8323330; Mon, 28 Aug 2017 17:16:29 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 217C67803F; Mon, 28 Aug 2017 18:16:29 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id E530C78037; Mon, 28 Aug 2017 18:16:28 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:42 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0020-0000-0000-00000CA0E9E3 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:31 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0021-0000-0000-00005DE891EC Message-Id: <1503965694-10794-68-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 67/79] 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: Laurent Vivier , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: 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 (cherry picked from commit e806b4db1477a1c6bfda7bba28c7f26c47f18e1e) Signed-off-by: Michael Roth --- 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 98c52e4..ecfbf01 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1893,20 +1893,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; @@ -1920,6 +1906,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.7.4