]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainCreate(XML)WithFiles: Add check for VIR_DRV_FEATURE_FD_PASSING
authorPeter Krempa <pkrempa@redhat.com>
Wed, 16 Feb 2022 15:33:22 +0000 (16:33 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 17 Feb 2022 12:15:46 +0000 (13:15 +0100)
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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
src/libvirt-domain.c

index b8a6f103333e9c2939a0edb3ca195969d9827613..8be2c211949824ce6a07a5bcfd56ed1e5f455902 100644 (file)
@@ -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,