qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About the instance_finalize callback in VFIO PCI


From: Alex Williamson
Subject: Re: About the instance_finalize callback in VFIO PCI
Date: Wed, 22 Mar 2023 12:22:27 -0600

On Wed, 22 Mar 2023 09:10:20 -0400
Yang Zhong <yang.zhong@linux.intel.com> wrote:

> On Wed, Mar 22, 2023 at 01:56:13PM +0100, Cédric Le Goater wrote:
> > 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 ?
> >   
>  
>  We are doing one new feature, which need this callback to do some
>  cleanup work with VFIO/iommufd kernel module. thanks!

This sounds dangerously like relying on userspace for cleanup.  Kernel
drivers need to be able to perform all cleanup themselves when file
descriptors are closed.  They must expect that userspace can be killed
at any point in time w/o an opportunity to do cleanup work.  Thanks,

Alex




reply via email to

[Prev in Thread] Current Thread [Next in Thread]