lib: Introduce virDomainFDAssociate API

The API can be used to associate one or more (e.g. a RO and RW fd for a
disk backend image) FDs to a VM. They can be then used per definition.

The primary use case for now is for complex deployment where
libvirtd/virtqemud may be run inside a container and getting the image
into the container is complicated.

In the future it will also allow passing e.g. vhost FDs and other
resources to a VM without the need to have a filesystem representation
for it.

Passing raw FDs has few intricacies and thus libvirt will by default not
restore security labels.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa
2022-02-24 17:01:40 +01:00
parent 3ebfeaa206
commit abd9025c2f
8 changed files with 199 additions and 1 deletions

View File

@@ -6458,4 +6458,24 @@ int virDomainStartDirtyRateCalc(virDomainPtr domain,
int seconds,
unsigned int flags);
/**
* virDomainFDAssociateFlags:
*
* Since: 9.0.0
*/
typedef enum {
/* Attempt a best-effort restore of security labels after use (Since: 9.0.0) */
VIR_DOMAIN_FD_ASSOCIATE_SECLABEL_RESTORE = (1 << 0),
/* Use a seclabel allowing writes for the FD even if usage implies read-only mode (Since: 9.0.0) */
VIR_DOMAIN_FD_ASSOCIATE_SECLABEL_WRITABLE = (1 << 1),
} virDomainFDAssociateFlags;
int virDomainFDAssociate(virDomainPtr domain,
const char *name,
unsigned int nfds,
int *fds,
unsigned int flags);
#endif /* LIBVIRT_DOMAIN_H */