From nobody Sat May 4 18:05:45 2024 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.zoho.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 1498659066293283.9043263546803; Wed, 28 Jun 2017 07:11:06 -0700 (PDT) Received: from localhost ([::1]:33601 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQDgI-0003ql-Ul for importer@patchew.org; Wed, 28 Jun 2017 10:10:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQDeo-0002aA-CU for qemu-devel@nongnu.org; Wed, 28 Jun 2017 10:09:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQDel-0008Dn-7N for qemu-devel@nongnu.org; Wed, 28 Jun 2017 10:09:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42784) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQDek-0008DM-TB; Wed, 28 Jun 2017 10:09:23 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7FEFDC04D293; Wed, 28 Jun 2017 14:09:21 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-116-207.phx2.redhat.com [10.3.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 366FB89E62; Wed, 28 Jun 2017 14:09:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7FEFDC04D293 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lvivier@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7FEFDC04D293 From: Laurent Vivier To: David Gibson Date: Wed, 28 Jun 2017 16:09:19 +0200 Message-Id: <20170628140919.27167-1-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 28 Jun 2017 14:09:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] 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 , Thomas Huth , qemu-ppc@nongnu.org, qemu-devel@nongnu.org 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" 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 --- 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 0b447f2..bd30b4f 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