Re: [PATCH 0/1] vfio: fix KVM reference leak on QEMU CPR

From: Paolo Bonzini

Date: Fri Nov 20 2026 - 11:52:32 EST


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.

2) Even worse, the above text is 101% copied from Claude.

Please come back once you have a patch that works for everyone and anyway only after having read Documentation/process/generated-content.rst:

"You are expected to understand and to be able to defend
everything you submit. If you are unable to do so, then do not submit
the resulting changes. If you do so anyway, maintainers are entitled to reject your series without detailed review."

Paolo