Re: [PATCH 0/1] vfio: fix KVM reference leak on QEMU CPR
From: Jason Gunthorpe
Date: Fri Nov 20 2026 - 13:54:26 EST
On Fri, Nov 20, 2026 at 05:52:09PM +0100, Paolo Bonzini wrote:
> On 11/20/26 16:47, Andrey Drobyshev wrote:
> > When a VM has a VFIO device and QEMU does a CPR (CheckPoint and Restart)
> > live update, QEMU creates a new VM and keeps the device open. The
> > device holds a reference to the VM it was opened with, so the old VM is
> > not destroyed. It stays until the device is closed, which usually means
> > for as long as the guest runs.
> >
> > It is one stale VM, not one per update. It is also visible: after
> > cpr-exec the kernel logs "kvm: debugfs: duplicate directory <pid>-<fd>",
> > and the new VM gets no debugfs directory.
> >
> > This patch makes the device take that reference only if its driver uses
> > it.
>
> There are two problems with this patch:
>
> 1) It sweeps the bug under the carpet and only solves the case that *you*
> care about. If the device keeps a reference to the VM it was first bound
> to, the problem is that there's no handoff from the old file descriptor to
> the new one.
Yeah, reflowing the kvm fd is not something vfio broadly supports at
all, there a several issues with even trying to do this this I think.
If qemu is doing a live update it probably has to keep the kvm fd
alive across the update too..
Ie when we get to things like confidential VMs there is state inside
that the kvm FD that cannot be checkpointed.
Jason