On Wed, Jan 14, 2026 at 10:42:02 +0000, Tejus GK wrote:
> This API allows callers to pass and store file descriptors inside libvirt
> using a hash table, with a provided "name" serving as the key. The stored
> file descriptors can be queried and reused later, enabling use cases such as
> FD-based live migration.
>
> Signed-off-by: Tejus GK <[email protected]>
> ---
> include/libvirt/libvirt-domain.h | 9 +++++
> src/driver-hypervisor.h | 7 ++++
> src/libvirt-domain.c | 62 +++++++++++++++++++++++++++++
> src/libvirt_public.syms | 5 +++
> src/qemu/qemu_conf.h | 4 ++
> src/qemu/qemu_driver.c | 41 +++++++++++++++++++
> src/remote/remote_daemon_dispatch.c | 36 +++++++++++++++++
> src/remote/remote_driver.c | 22 ++++++++++
> src/remote/remote_protocol.x | 12 +++++-
> 9 files changed, 197 insertions(+), 1 deletion(-)
[...]
> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> index 74c70a0a43..7e194f7193 100644
> --- a/src/libvirt-domain.c
> +++ b/src/libvirt-domain.c
> @@ -14269,3 +14269,65 @@ virDomainDelThrottleGroup(virDomainPtr dom,
> virDispatchError(dom->conn);
> return -1;
> }
> +
> +
> +/**
> + * virDomainFDStore:
> + * @conn: a connection object
> + * @name: name for the file descriptor group
> + * @nfds: number of fds in @fds
> + * @fds: file descriptors to store
> + *
> + * Store the FDs in @fds with @conn under @name. The FDs persist unitl
> + * explicitly consumed (e.g. during a live migration) or until libvirt
> + * shuts down/ restarts.
> + *
> + * Unlike virDomainFDAssociate, this does not require a domain to exist
> + * at the time of storing the FDs.
> + *
> + * Returns 0 on success, -1 on error.
> + *
> + * Since: 12.0.0
> + */
This looks identical to as long as you are about to use the FD with a VM
object:
/**
* virDomainFDAssociate:
* @domain: a domain object
* @name: name for the file descriptor group
* @nfds: number of fds in @fds
* @fds: file descriptors to associate with domain
* @flags: optional flags; bitwise-OR of supported virDomainFDAssociateFlags
*
* Associate the FDs in @fd with @domain under @name. The FDs are associated as
* long as the connection used to associated exists and are disposed of
* afterwards. FD may still be kept open by the hypervisor for as long as it's
* needed.
*
* Security labelling (e.g. via the selinux) may be applied on the passed FDs
* when required for usage by the VM. By default libvirt does not restore the
* seclabels on the FDs afterwards to avoid keeping it open unnecessarily.
*
* Restoring of the security label can be requested by passing either
* VIR_DOMAIN_FD_ASSOCIATE_SECLABEL_RESTORE for a best-effort attempt to restore
* the security label after use.
* Requesting the restore of security label will require that the file
* descriptors are kept open for the whole time they are used by the hypervisor,
* or other additional overhead.
*
* In certain cases usage of the fd group would imply read-only access. Passing
* VIR_DOMAIN_FD_ASSOCIATE_SECLABEL_WRITABLE in @flags ensures that a writable
* security label is picked in case when the file represented by the fds may
* be used in write mode.
*
* Returns 0 on success, -1 on error.
*
* Since: 9.0.0
*/
int
virDomainFDAssociate(virDomainPtr domain,
const char *name,
unsigned int nfds,
int *fds,
unsigned int flags)
> + int
> + virDomainFDStore(virConnectPtr conn,
> + const char *name,
> + unsigned int nfds,
> + int *fds)
> + {
> + int rc;
> +
> + VIR_DEBUG("conn=%p, name='%s', nfds=%u, fds=%p",
> + conn, name, nfds, fds);