From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 025D8C6FD1F for ; Wed, 22 Mar 2023 12:57:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pey0z-0006bN-Ci; Wed, 22 Mar 2023 08:56:29 -0400 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 1pey0w-0006aU-HP for qemu-devel@nongnu.org; Wed, 22 Mar 2023 08:56:26 -0400 Received: from 6.mo552.mail-out.ovh.net ([188.165.49.222]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pey0u-0006cQ-Hj for qemu-devel@nongnu.org; Wed, 22 Mar 2023 08:56:26 -0400 Received: from mxplan5.mail.ovh.net (unknown [10.108.4.108]) by mo552.mail-out.ovh.net (Postfix) with ESMTPS id 99B502B298; Wed, 22 Mar 2023 12:56:19 +0000 (UTC) Received: from kaod.org (37.59.142.105) by DAG4EX2.mxp5.local (172.16.2.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 22 Mar 2023 13:56:18 +0100 Authentication-Results: garm.ovh; auth=pass (GARM-105G00687bcd0ab-1be3-4e7e-96b5-7050d7f7ea17, 0238FB4F90E64FBF2D0582C5546B9BA65CD8F58A) smtp.auth=clg@kaod.org X-OVh-ClientIp: 82.64.250.170 Message-ID: <62b9e8b3-a619-573d-c641-d80a12c3ab59@kaod.org> Date: Wed, 22 Mar 2023 13:56:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: About the instance_finalize callback in VFIO PCI Content-Language: en-US To: Yang Zhong CC: Alex Williamson , Paolo Bonzini , References: <1d364b78-3dbb-87cb-daff-e92f40444ab7@kaod.org> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [37.59.142.105] X-ClientProxiedBy: DAG1EX1.mxp5.local (172.16.2.1) To DAG4EX2.mxp5.local (172.16.2.32) X-Ovh-Tracer-GUID: 661365ac-ece5-4fc6-9a18-bc984d2ec397 X-Ovh-Tracer-Id: 18082796932707879904 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvdegvddggeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgihesthekredttdefjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucggtffrrghtthgvrhhnpeffudefleeiudejfeffhfejffeigffhhffhvdekieejheelvdeufffhjedtheeggeenucfkphepuddvjedrtddrtddruddpfeejrdehledrudegvddruddtheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoegtlhhgsehkrghougdrohhrgheqpdhnsggprhgtphhtthhopedupdhrtghpthhtohephigrnhhgrdiihhhonhhgsehlihhnuhigrdhinhhtvghlrdgtohhmpdgrlhgvgidrfihilhhlihgrmhhsohhnsehrvgguhhgrthdrtghomhdpphgsohhniihinhhisehrvgguhhgrthdrtghomhdpqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghdpoffvtefjohhsthepmhhoheehvddpmhhouggvpehsmhhtphhouhht Received-SPF: pass client-ip=188.165.49.222; envelope-from=clg@kaod.org; helo=6.mo552.mail-out.ovh.net 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, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On 3/22/23 13:28, Yang Zhong wrote: > On Tue, Mar 21, 2023 at 06:30:14PM +0100, Cédric Le Goater wrote: >> On 3/20/23 10:31, Yang Zhong wrote: >>> Hello Alex and Paolo, >>> >>> There is one instance_finalize callback definition in hw/vfio/pci.c, but >>> i find this callback(vfio_instance_finalize()) never be called during the >>> VM shutdown with close VM or "init 0" command in guest. >>> >>> The Qemu related command: >>> ...... >>> -device vfio-pci,host=d9:00.0 >>> ...... >> >> well, the finalize op is correctly called for hot unplugged devices, using >> device_add. >> > Thanks Cédric, i can use device_del command in the monitor to > trigger this instance_finalize callback function in the VFIO PCI. > thanks! yes. I think that in the shutdown case, QEMU simply relies on exit() to do the cleanup. On the kernel side, unmaps, fds being closed trigger any allocated resources. Out of curiosity, what were you trying to achieve in the finalize op ? Thanks, C.