render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
d76c62
From 5e76dbcf3922074cbf708c3ffe8adc6e108bac76 Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <5e76dbcf3922074cbf708c3ffe8adc6e108bac76@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Mon, 16 Mar 2020 22:11:59 +0100
d76c62
Subject: [PATCH] qemuDomainValidateStorageSource: Validate new network storage
d76c62
 parameters
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Ensure that the new fields are allowed only when -blockdev is used or
d76c62
when they are in the detected part of the backing chain where qemu will
d76c62
handle them internally.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
(cherry picked from commit c1409e308f8e10f28ff4977309b2573a1a2d8763)
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
d76c62
Message-Id: <3b47d0ff8f492506588d6ddeda49d2e4e43cc5aa.1584391727.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_domain.c | 75 ++++++++++++++++++++++++++++++++++++++++++
d76c62
 1 file changed, 75 insertions(+)
d76c62
d76c62
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
d76c62
index 65df463acc..2920e699f6 100644
d76c62
--- a/src/qemu/qemu_domain.c
d76c62
+++ b/src/qemu/qemu_domain.c
d76c62
@@ -6953,6 +6953,81 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src,
d76c62
         }
d76c62
     }
d76c62
 
d76c62
+    if (src->sslverify != VIR_TRISTATE_BOOL_ABSENT) {
d76c62
+        if (actualType != VIR_STORAGE_TYPE_NETWORK ||
d76c62
+            (src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTPS &&
d76c62
+             src->protocol != VIR_STORAGE_NET_PROTOCOL_FTPS)) {
d76c62
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
d76c62
+                           _("ssl verification is supported only with HTTPS/FTPS protocol"));
d76c62
+            return -1;
d76c62
+        }
d76c62
+
d76c62
+        if (!src->detected &&
d76c62
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
d76c62
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
d76c62
+                           _("ssl verification setting is not supported by this QEMU binary"));
d76c62
+            return -1;
d76c62
+        }
d76c62
+    }
d76c62
+
d76c62
+    if (src->ncookies > 0) {
d76c62
+        if (actualType != VIR_STORAGE_TYPE_NETWORK ||
d76c62
+            (src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTPS &&
d76c62
+             src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTP)) {
d76c62
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
d76c62
+                           _("http cookies are supported only with HTTP(S) protocol"));
d76c62
+            return -1;
d76c62
+        }
d76c62
+
d76c62
+        if (!src->detected &&
d76c62
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
d76c62
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
d76c62
+                           _("http cookies are not supported by this QEMU binary"));
d76c62
+            return -1;
d76c62
+        }
d76c62
+
d76c62
+        if (virStorageSourceNetCookiesValidate(src) < 0)
d76c62
+            return -1;
d76c62
+    }
d76c62
+
d76c62
+    if (src->readahead > 0) {
d76c62
+        if (actualType != VIR_STORAGE_TYPE_NETWORK ||
d76c62
+            (src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTPS &&
d76c62
+             src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTP &&
d76c62
+             src->protocol != VIR_STORAGE_NET_PROTOCOL_FTP &&
d76c62
+             src->protocol != VIR_STORAGE_NET_PROTOCOL_FTPS)) {
d76c62
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
d76c62
+                           _("readaehad is supported only with HTTP(S)/FTP(s) protocols"));
d76c62
+            return -1;
d76c62
+        }
d76c62
+
d76c62
+        if (!src->detected &&
d76c62
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
d76c62
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
d76c62
+                           _("readahead setting is not supported with this QEMU binary"));
d76c62
+            return -1;
d76c62
+        }
d76c62
+    }
d76c62
+
d76c62
+    if (src->timeout > 0) {
d76c62
+        if (actualType != VIR_STORAGE_TYPE_NETWORK ||
d76c62
+            (src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTPS &&
d76c62
+             src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTP &&
d76c62
+             src->protocol != VIR_STORAGE_NET_PROTOCOL_FTP &&
d76c62
+             src->protocol != VIR_STORAGE_NET_PROTOCOL_FTPS)) {
d76c62
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
d76c62
+                           _("timeout is supported only with HTTP(S)/FTP(s) protocols"));
d76c62
+            return -1;
d76c62
+        }
d76c62
+
d76c62
+        if (!src->detected &&
d76c62
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
d76c62
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
d76c62
+                           _("timeout setting is not supported with this QEMU binary"));
d76c62
+            return -1;
d76c62
+        }
d76c62
+    }
d76c62
+
d76c62
     return 0;
d76c62
 }
d76c62
 
d76c62
-- 
d76c62
2.25.1
d76c62