From nobody Tue Apr 30 07:53:19 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.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 1499914615036251.3519900574014; Wed, 12 Jul 2017 19:56:55 -0700 (PDT) Received: from localhost ([::1]:56955 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVUJA-000214-I8 for importer@patchew.org; Wed, 12 Jul 2017 22:56:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVUIG-0001Zg-Gl for qemu-devel@nongnu.org; Wed, 12 Jul 2017 22:55:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVUIF-00028P-KV for qemu-devel@nongnu.org; Wed, 12 Jul 2017 22:55:56 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:41059) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVUIF-000264-6q; Wed, 12 Jul 2017 22:55:55 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3x7L6b5PS6z9s65; Thu, 13 Jul 2017 12:55:51 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1499914551; bh=7ZCDq9YA/E7c3sN225qIpWUGt6Y0LJbf0HwZsoBxrlk=; h=From:To:Cc:Subject:Date:From; b=PqgcQOdvi3uueO7urcQDwFxo1iXLafc0aCMCumqOUIJMdbgKBYVd9zi/t1JzrsRil EU4UAG9FnGzHvhHAMGkwvZdXlzOOGdqATEfc97mZme7XNFtOnf0wh4qeb3Xt1LLqRA WdDFbyr2UJzB28SQ8iT0pz3pcpYY81eso4aEE6NY= From: David Gibson To: mdroth@linux.vnet.ibm.com, qemu-stable@nongnu.org Date: Thu, 13 Jul 2017 12:55:47 +1000 Message-Id: <20170713025547.820-1-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PATCH for qemu-2.9] 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 , David Gibson , qemu-ppc@nongnu.org, groug@kaod.org, qemu-devel@nongnu.org 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 (cherry picked from commit e806b4db1477a1c6bfda7bba28c7f26c47f18e1e) --- 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.9.4