render / rpms / libvirt

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