From nobody Mon Feb 9 03:52:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1657504097; cv=none; d=zohomail.com; s=zohoarc; b=d0jM0QrLxyu8dlxYUUASZlJ1jGGPgl4lsFXXvlaWohSAgnvqxLtQnfZqt36Ro6H7SQWLi4B9kLuAI2VADh6qC2pELNLCEM9n6TfIY5AjBP0F3n4Bh1STdATX4LCxp22RHuYI/WZVG5jw/VtxH72OsrsQ5044tGSV4Iv0O/ZinJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657504097; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=jTVorroAKpMaW+/SOZpjZbiRXUMQGyChib5Xb/HvO/k=; b=T6iMfCLwkktP+cNI42EKGzn09IBJhuf89nrY13m9wJIQfOasNR4mX4D04n9fkN15GEhVh2gNcRCYJY/r67eGfIbvAfunchYdAU3pBqiBe2bqw9tSy4uRIsqYdAmWp9zqBVePT0/BCZwYQM+/wyczxe3bZasOudpmDSFEGsPqGSY= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657504097527446.89774343754084; Sun, 10 Jul 2022 18:48:17 -0700 (PDT) Received: from localhost ([::1]:35452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oAiX1-0003MF-MK for importer@patchew.org; Sun, 10 Jul 2022 21:48:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oAiWH-0002hG-WA for qemu-devel@nongnu.org; Sun, 10 Jul 2022 21:47:30 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:3946) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oAiWF-0003YS-Ek for qemu-devel@nongnu.org; Sun, 10 Jul 2022 21:47:29 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lh6Cn5v8BzlVtQ; Mon, 11 Jul 2022 09:45:41 +0800 (CST) Received: from kwepemm600007.china.huawei.com (7.193.23.208) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 11 Jul 2022 09:47:08 +0800 Received: from DESKTOP-6NKE0BC.china.huawei.com (10.174.185.210) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 11 Jul 2022 09:47:07 +0800 To: Alex Williamson , Kirti Wankhede , "open list:All patches CC here" CC: , , Kunkun Jiang Subject: [PATCH] vfio/migration: Fix incorrect initialization value for parameters in VFIOMigration Date: Mon, 11 Jul 2022 09:46:51 +0800 Message-ID: <20220711014651.1327-1-jiangkunkun@huawei.com> X-Mailer: git-send-email 2.26.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.185.210] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600007.china.huawei.com (7.193.23.208) X-CFilter-Loop: Reflected 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: pass client-ip=45.249.212.187; envelope-from=jiangkunkun@huawei.com; helo=szxga01-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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" Reply-to: Kunkun Jiang From: Kunkun Jiang via X-ZM-MESSAGEID: 1657504100299100001 Content-Type: text/plain; charset="utf-8" The structure VFIOMigration of a VFIODevice is allocated and initialized in vfio_migration_init(). "device_state" and "vm_running" are initialized to 0, indicating that VFIO device is_STOP and VM is not-running. The initialization value is incorrect. According to the agreement, default state of VFIO device is _RUNNING. And if a VFIO device is hot-plugged while the VM is running, "vm_running" should be 1. This patch fixes it. Fixes: 02a7e71b1e5 (vfio: Add VM state change handler to know state of VM) Signed-off-by: Kunkun Jiang --- hw/vfio/migration.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index a6ad1f8945..3de4252111 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -806,6 +806,8 @@ static int vfio_migration_init(VFIODevice *vbasedev, } =20 vbasedev->migration =3D g_new0(VFIOMigration, 1); + vbasedev->migration->device_state =3D VFIO_DEVICE_STATE_RUNNING; + vbasedev->migration->vm_running =3D runstate_is_running(); =20 ret =3D vfio_region_setup(obj, vbasedev, &vbasedev->migration->region, info->index, "migration"); --=20 2.27.0