From 1c71e06619c769bd14b64fc9f43408d30de81884 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 16 Feb 2022 16:33:22 +0100 Subject: [PATCH] virDomainCreate(XML)WithFiles: Add check for VIR_DRV_FEATURE_FD_PASSING MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All APIs using FD passing have this check to prevent sending a 'VIR_NET_CALL_WITH_FDS' to an older daemon but virDomainCreateXMLWithFiles was missing it. Now the LXC driver was historically not exposing VIR_DRV_FEATURE_FD_PASSING, but that is not a problem as LXC always goes through the remote driver which intercepts it and injects VIR_DRV_FEATURE_FD_PASSING when it was implemented. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko Reviewed-by: Andrea Bolognani --- src/libvirt-domain.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index b8a6f10333..8be2c21194 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -244,6 +244,18 @@ virDomainCreateXMLWithFiles(virConnectPtr conn, const char *xmlDesc, virCheckNonNullArgGoto(xmlDesc, error); virCheckReadOnlyGoto(conn->flags, error); + if (nfiles > 0) { + int rc; + + if ((rc = VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, + VIR_DRV_FEATURE_FD_PASSING)) <= 0) { + if (rc == 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("fd passing is not supported by this connection")); + goto error; + } + } + if (conn->driver->domainCreateXMLWithFiles) { virDomainPtr ret; ret = conn->driver->domainCreateXMLWithFiles(conn, xmlDesc, @@ -6869,6 +6881,18 @@ virDomainCreateWithFiles(virDomainPtr domain, unsigned int nfiles, virCheckReadOnlyGoto(conn->flags, error); + if (nfiles > 0) { + int rc; + + if ((rc = VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, + VIR_DRV_FEATURE_FD_PASSING)) <= 0) { + if (rc == 0) + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("fd passing is not supported by this connection")); + goto error; + } + } + if (conn->driver->domainCreateWithFiles) { int ret; ret = conn->driver->domainCreateWithFiles(domain,