From nobody Mon Feb 9 08:06:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1708766806; cv=none; d=zohomail.com; s=zohoarc; b=IXchkJWSyWz+3Y9jJHJRAuAyeDLDui9F6hrGCiWowsd/CdgbehizoPvrw6DveD1Y1V8nd736emzzDP/s0jAHQlCzpaNPD0/4JfXTMtGK51vyV51QGOHXh97XwbXTaYCj8V+EhR99K5Vuv8v4IVWmnKb5LO2nYToro4LLKOo+0aE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708766806; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=53XyZW+eFVvoAPfI8083D4zbyq4zLHK5w/Vl/6iTbj0=; b=OvDabGpRLce4c99WMFlqdoRSkIdqCkHeaRkWssCK+Rpcu1wQrWS6AXN3xr9gWsb6zpXSrujv8HMciE29xUcuPX0c2I1TvH3cUuI6bNdsSmZgX4C7ip1ng0Jur6u1a92fkJkRSo9fU1RB1wcA9tnGDVquZIsdthx9YhnZSVGJZQA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708766806138295.0553875274936; Sat, 24 Feb 2024 01:26:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdoHu-0007F4-TR; Sat, 24 Feb 2024 04:25:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rdoHs-00079b-Hg for qemu-devel@nongnu.org; Sat, 24 Feb 2024 04:25:40 -0500 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdoHq-0002tb-RR for qemu-devel@nongnu.org; Sat, 24 Feb 2024 04:25:40 -0500 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5dca1efad59so1521903a12.2 for ; Sat, 24 Feb 2024 01:25:37 -0800 (PST) Received: from localhost ([157.82.203.206]) by smtp.gmail.com with UTF8SMTPSA id dt15-20020a17090afa4f00b0029954a48c38sm847129pjb.38.2024.02.24.01.25.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 Feb 2024 01:25:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1708766736; x=1709371536; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=53XyZW+eFVvoAPfI8083D4zbyq4zLHK5w/Vl/6iTbj0=; b=kRg5w/IzmQzpHHM2l3aVD/AapVeRToZlgbT/HjkRGhxy1HvXn6qdh7GO4ZR06tcQb8 RLuK1UZtg2xQazqfvecov+YuEvyFET2s4RYkULynwtytmg1lPBDUhVnOBcvvDneQfCz5 UjXGnxuTEFmUAsuMNEN3u8urHwxZ1guRGQxO0JMa/AF/ZnIBaSU4Pr6i2GfJ92emZdJq ARYQm8n7qTgBLKapcFB4uIo0zrq4eRNgMBB6mhtKtKG5HrX6Khl5srgxXWps+Zdw/K18 u3ob42+z7ua993UuWJE/NTJeN2+ZGX7PAUVKauvA5dXaw5UgMtziPhXABC7cLg9GNAmI kKdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708766736; x=1709371536; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=53XyZW+eFVvoAPfI8083D4zbyq4zLHK5w/Vl/6iTbj0=; b=mMxZszbeiNBH7y2PbJOSeEVRdAE9aj2aiBVfUhm1Mx3Y/iTX3EE70Gm2fe9Ruk9x84 h7EvFZrRnTUz9emr4r+yFj75jklR+t5WR0cOYtISf1nPIlxyHiNoNgy91P/RiqzDuojw xEjxrmUfvlodVHKf3TBkVtuNSGnAms6I5nNcrRg+WvVQW/lQozsPJOFCV8fu1CXC2ZPG 5SQiNaoBRz4XAh8payQd9XxSTCO57JkHKiRtel+sQ/fdt0W5bNix76FLuGo1EgrTAmo9 /luPJR+W+gqOxDULIjMhCTMUBd7kBxPPpLNiSpK+YvF6lmVYn5sOqmbbCiutGiWlHFEV zy+A== X-Gm-Message-State: AOJu0Yy5SBGRBFhSDWSyzGHmwxUEdMJVGCaeHOvurN3hbW3dz4M29+Oi Mt8KYC5huUEKf5YxuHQNuq4HsdF1UR4Xdm/7phRV0Al4q5mjMqePMZggr2LY9G8= X-Google-Smtp-Source: AGHT+IGqDqvo/u0iRU0Wc0/FCIqu9x5HRXEjgtt+Txz9d/kt9sb1c7Llbsi9bMLlNGIiiaoxPUW7QQ== X-Received: by 2002:a17:90a:1b82:b0:299:41de:9fea with SMTP id w2-20020a17090a1b8200b0029941de9feamr1649181pjc.15.1708766736474; Sat, 24 Feb 2024 01:25:36 -0800 (PST) From: Akihiko Odaki Date: Sat, 24 Feb 2024 18:24:43 +0900 Subject: [PATCH v7 11/16] pcie_sriov: Register VFs after migration MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240224-reuse-v7-11-29c14bcb952e@daynix.com> References: <20240224-reuse-v7-0-29c14bcb952e@daynix.com> In-Reply-To: <20240224-reuse-v7-0-29c14bcb952e@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::52d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1708766807315100011 pcie_sriov doesn't have code to restore its state after migration, but igb, which uses pcie_sriov, naively claimed its migration capability. Add code to register VFs after migration and fix igb migration. Fixes: 3a977deebe6b ("Intrdocue igb device emulation") Signed-off-by: Akihiko Odaki --- include/hw/pci/pcie_sriov.h | 2 ++ hw/pci/pci.c | 7 +++++++ hw/pci/pcie_sriov.c | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 793d03c5f12e..d576a8c6be19 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -57,6 +57,8 @@ void pcie_sriov_pf_add_sup_pgsize(PCIDevice *dev, uint16_= t opt_sup_pgsize); void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, uint32_t val, int len); =20 +void pcie_sriov_pf_post_load(PCIDevice *dev); + /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev); =20 diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 750c2ba696d1..54b375da2d26 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -733,10 +733,17 @@ static bool migrate_is_not_pcie(void *opaque, int ver= sion_id) return !pci_is_express((PCIDevice *)opaque); } =20 +static int pci_post_load(void *opaque, int version_id) +{ + pcie_sriov_pf_post_load(opaque); + return 0; +} + const VMStateDescription vmstate_pci_device =3D { .name =3D "PCIDevice", .version_id =3D 2, .minimum_version_id =3D 1, + .post_load =3D pci_post_load, .fields =3D (const VMStateField[]) { VMSTATE_INT32_POSITIVE_LE(version_id, PCIDevice), VMSTATE_BUFFER_UNSAFE_INFO_TEST(config, PCIDevice, diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index fb48c1a18c9a..09a53ed30027 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -239,6 +239,13 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t = address, } } =20 +void pcie_sriov_pf_post_load(PCIDevice *dev) +{ + if (dev->exp.sriov_cap) { + register_vfs(dev); + } +} + =20 /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev) --=20 2.43.2