|
|
fbe740 |
From 3366d4df5aac258013848cf5df7c95d45693c1e0 Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <3366d4df5aac258013848cf5df7c95d45693c1e0@dist-git>
|
|
|
fbe740 |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
fbe740 |
Date: Wed, 4 Mar 2020 12:42:44 +0100
|
|
|
fbe740 |
Subject: [PATCH] qemu: validate virtiofs filesystems
|
|
|
fbe740 |
MIME-Version: 1.0
|
|
|
fbe740 |
Content-Type: text/plain; charset=UTF-8
|
|
|
fbe740 |
Content-Transfer-Encoding: 8bit
|
|
|
fbe740 |
|
|
|
fbe740 |
Reject unsupported configurations.
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Tested-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
|
|
|
fbe740 |
(cherry picked from commit efaf46811c909ee5333360fba1d75ae82352964a)
|
|
|
fbe740 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
|
|
|
fbe740 |
Message-Id: <1fcb6b7d58c3791799c5d436edaa2faa07e92305.1583322091.git.jtomko@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
src/qemu/qemu_domain.c | 82 +++++++++++++++++++++++++++++++++++++++---
|
|
|
fbe740 |
1 file changed, 77 insertions(+), 5 deletions(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
fbe740 |
index 402b079b09..79d8de2e42 100644
|
|
|
fbe740 |
--- a/src/qemu/qemu_domain.c
|
|
|
fbe740 |
+++ b/src/qemu/qemu_domain.c
|
|
|
fbe740 |
@@ -8329,11 +8329,52 @@ qemuDomainDeviceDefValidateIOMMU(const virDomainIOMMUDef *iommu,
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
+static int
|
|
|
fbe740 |
+qemuDomainDefValidateVirtioFSSharedMemory(const virDomainDef *def)
|
|
|
fbe740 |
+{
|
|
|
fbe740 |
+ size_t numa_nodes = virDomainNumaGetNodeCount(def->numa);
|
|
|
fbe740 |
+ size_t i;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ if (numa_nodes == 0) {
|
|
|
fbe740 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
fbe740 |
+ _("virtiofs requires one or more NUMA nodes"));
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ for (i = 0; i < numa_nodes; i++) {
|
|
|
fbe740 |
+ virDomainMemoryAccess node_access =
|
|
|
fbe740 |
+ virDomainNumaGetNodeMemoryAccessMode(def->numa, i);
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ switch (node_access) {
|
|
|
fbe740 |
+ case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT:
|
|
|
fbe740 |
+ if (def->mem.access != VIR_DOMAIN_MEMORY_ACCESS_SHARED) {
|
|
|
fbe740 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
fbe740 |
+ _("virtiofs requires shared memory"));
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+ break;
|
|
|
fbe740 |
+ case VIR_DOMAIN_MEMORY_ACCESS_SHARED:
|
|
|
fbe740 |
+ break;
|
|
|
fbe740 |
+ case VIR_DOMAIN_MEMORY_ACCESS_PRIVATE:
|
|
|
fbe740 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
fbe740 |
+ _("virtiofs requires shared memory"));
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ case VIR_DOMAIN_MEMORY_ACCESS_LAST:
|
|
|
fbe740 |
+ default:
|
|
|
fbe740 |
+ virReportEnumRangeError(virDomainMemoryAccess, node_access);
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+ return 0;
|
|
|
fbe740 |
+}
|
|
|
fbe740 |
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
qemuDomainDeviceDefValidateFS(virDomainFSDefPtr fs,
|
|
|
fbe740 |
- const virDomainDef *def G_GNUC_UNUSED,
|
|
|
fbe740 |
- virQEMUCapsPtr qemuCaps G_GNUC_UNUSED)
|
|
|
fbe740 |
+ const virDomainDef *def,
|
|
|
fbe740 |
+ virQEMUDriverPtr driver,
|
|
|
fbe740 |
+ virQEMUCapsPtr qemuCaps)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT) {
|
|
|
fbe740 |
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
fbe740 |
@@ -8362,8 +8403,39 @@ qemuDomainDeviceDefValidateFS(virDomainFSDefPtr fs,
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS:
|
|
|
fbe740 |
- /* TODO: vhost-user-fs-pci */
|
|
|
fbe740 |
- return 0;
|
|
|
fbe740 |
+ if (!virQEMUDriverIsPrivileged(driver)) {
|
|
|
fbe740 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
fbe740 |
+ _("virtiofs is not yet supported in session mode"));
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+ if (fs->accessmode != VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH) {
|
|
|
fbe740 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
fbe740 |
+ _("virtiofs only supports passthrough accessmode"));
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+ if (fs->wrpolicy != VIR_DOMAIN_FS_WRPOLICY_DEFAULT) {
|
|
|
fbe740 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
fbe740 |
+ _("virtiofs does not support wrpolicy"));
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+ if (fs->model != VIR_DOMAIN_FS_MODEL_DEFAULT) {
|
|
|
fbe740 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
fbe740 |
+ _("virtiofs does not support model"));
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+ if (fs->format != VIR_STORAGE_FILE_NONE) {
|
|
|
fbe740 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
fbe740 |
+ _("virtiofs does not support format"));
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_USER_FS)) {
|
|
|
fbe740 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
fbe740 |
+ _("virtiofs is not supported with this QEMU binary"));
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ }
|
|
|
fbe740 |
+ if (qemuDomainDefValidateVirtioFSSharedMemory(def) < 0)
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+ break;
|
|
|
fbe740 |
|
|
|
fbe740 |
case VIR_DOMAIN_FS_DRIVER_TYPE_LAST:
|
|
|
fbe740 |
default:
|
|
|
fbe740 |
@@ -8542,7 +8614,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
|
|
|
fbe740 |
break;
|
|
|
fbe740 |
|
|
|
fbe740 |
case VIR_DOMAIN_DEVICE_FS:
|
|
|
fbe740 |
- ret = qemuDomainDeviceDefValidateFS(dev->data.fs, def, qemuCaps);
|
|
|
fbe740 |
+ ret = qemuDomainDeviceDefValidateFS(dev->data.fs, def, driver, qemuCaps);
|
|
|
fbe740 |
break;
|
|
|
fbe740 |
|
|
|
fbe740 |
case VIR_DOMAIN_DEVICE_NVRAM:
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.25.1
|
|
|
fbe740 |
|