[PATCH v2 04/22] vfio/pci: Register a file handler with Live Update Orchestrator

Pranjal Shrivastava praan at google.com
Wed Feb 25 14:06:18 PST 2026


On Wed, Feb 25, 2026 at 02:33:28PM -0700, Alex Williamson wrote:
> On Thu, 29 Jan 2026 21:24:51 +0000
> David Matlack <dmatlack at google.com> wrote:
> > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> > index 0c771064c0b8..19e88322af2c 100644
> > --- a/drivers/vfio/pci/vfio_pci.c
> > +++ b/drivers/vfio/pci/vfio_pci.c
> > @@ -258,6 +258,10 @@ static int __init vfio_pci_init(void)
> >  	int ret;
> >  	bool is_disable_vga = true;
> >  
> > +	ret = vfio_pci_liveupdate_init();
> > +	if (ret)
> > +		return ret;
> > +
> >  #ifdef CONFIG_VFIO_PCI_VGA
> >  	is_disable_vga = disable_vga;
> >  #endif
> > @@ -266,8 +270,10 @@ static int __init vfio_pci_init(void)
> >  
> >  	/* Register and scan for devices */
> >  	ret = pci_register_driver(&vfio_pci_driver);
> > -	if (ret)
> > +	if (ret) {
> > +		vfio_pci_liveupdate_cleanup();
> >  		return ret;
> > +	}
> >  
> >  	vfio_pci_fill_ids();
> >  
> > @@ -281,6 +287,7 @@ module_init(vfio_pci_init);
> >  static void __exit vfio_pci_cleanup(void)
> >  {
> >  	pci_unregister_driver(&vfio_pci_driver);
> > +	vfio_pci_liveupdate_cleanup();
> >  }
> >  module_exit(vfio_pci_cleanup);
> >  
> > diff --git a/drivers/vfio/pci/vfio_pci_liveupdate.c b/drivers/vfio/pci/vfio_pci_liveupdate.c
> > new file mode 100644
> > index 000000000000..b84e63c0357b
> > --- /dev/null
> > +++ b/drivers/vfio/pci/vfio_pci_liveupdate.c
> > @@ -0,0 +1,69 @@
> ...
> > +static const struct liveupdate_file_ops vfio_pci_liveupdate_file_ops = {
> > +	.can_preserve = vfio_pci_liveupdate_can_preserve,
> > +	.preserve = vfio_pci_liveupdate_preserve,
> > +	.unpreserve = vfio_pci_liveupdate_unpreserve,
> > +	.retrieve = vfio_pci_liveupdate_retrieve,
> > +	.finish = vfio_pci_liveupdate_finish,
> > +	.owner = THIS_MODULE,
> > +};
> > +
> > +static struct liveupdate_file_handler vfio_pci_liveupdate_fh = {
> > +	.ops = &vfio_pci_liveupdate_file_ops,
> > +	.compatible = VFIO_PCI_LUO_FH_COMPATIBLE,
> > +};
> > +
> > +int __init vfio_pci_liveupdate_init(void)
> > +{
> > +	if (!liveupdate_enabled())
> > +		return 0;
> > +
> > +	return liveupdate_register_file_handler(&vfio_pci_liveupdate_fh);
> > +}
> 
> liveupdate_register_file_handler() "pins" vfio-pci with a
> try_module_get().  Since this is done in our module_init function and
> unregister occurs in our module_exit function, rather than relative
> to any actual device binding or usage, this means vfio-pci CANNOT be
> unloaded.  That seems bad.  Thanks,

Hmm... IIUC the concern here is about liveupdate policy if the user 
wants to unload a module which was previously marked for preservation?

AFAICT, In such a case, the user is expected to close the LUO session FD,
which "unpreserves" the FD. Finally, when rmmod is executed, the __exit 
(vfio_pci_cleanup) calls vfio_pci_liveupdate_cleanup() which ends up 
calling liveupdate_unregister_file_handler(), thereby dropping the ref
held by the liveupdate orchestrator which allows the module to be
unloaded.

I think we should document this policy somewhere or have a dev_warn to
scream at the users when they try unloading the module without closing
the session FD.

Thanks,
Praan

> 
> Alex
> 
> > +
> > +void vfio_pci_liveupdate_cleanup(void)
> > +{
> > +	if (!liveupdate_enabled())
> > +		return;
> > +
> > +	liveupdate_unregister_file_handler(&vfio_pci_liveupdate_fh);
> > +}



More information about the kexec mailing list