Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_domain.c | 119 +--------------------------------------
src/qemu/qemu_validate.c | 119 +++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_validate.h | 4 ++
3 files changed, 124 insertions(+), 118 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index ca9e642632..110d5b3fb2 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5727,123 +5727,6 @@ qemuDomainDeviceDefValidateIOMMU(const virDomainIOMMUDef *iommu,
return 0;
}
-static int
-qemuDomainDefValidateVirtioFSSharedMemory(const virDomainDef *def)
-{
- size_t numa_nodes = virDomainNumaGetNodeCount(def->numa);
- size_t i;
-
- if (numa_nodes == 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtiofs requires one or more NUMA nodes"));
- return -1;
- }
-
- for (i = 0; i < numa_nodes; i++) {
- virDomainMemoryAccess node_access =
- virDomainNumaGetNodeMemoryAccessMode(def->numa, i);
-
- switch (node_access) {
- case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT:
- if (def->mem.access != VIR_DOMAIN_MEMORY_ACCESS_SHARED) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtiofs requires shared memory"));
- return -1;
- }
- break;
- case VIR_DOMAIN_MEMORY_ACCESS_SHARED:
- break;
- case VIR_DOMAIN_MEMORY_ACCESS_PRIVATE:
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtiofs requires shared memory"));
- return -1;
-
- case VIR_DOMAIN_MEMORY_ACCESS_LAST:
- default:
- virReportEnumRangeError(virDomainMemoryAccess, node_access);
- return -1;
-
- }
- }
- return 0;
-}
-
-static int
-qemuDomainDeviceDefValidateFS(virDomainFSDefPtr fs,
- const virDomainDef *def,
- virQEMUDriverPtr driver,
- virQEMUCapsPtr qemuCaps)
-{
- if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("only supports mount filesystem type"));
- return -1;
- }
-
- switch ((virDomainFSDriverType) fs->fsdriver) {
- case VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT:
- case VIR_DOMAIN_FS_DRIVER_TYPE_PATH:
- break;
-
- case VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE:
- if (fs->accessmode != VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("only supports passthrough accessmode"));
- return -1;
- }
- break;
-
- case VIR_DOMAIN_FS_DRIVER_TYPE_LOOP:
- case VIR_DOMAIN_FS_DRIVER_TYPE_NBD:
- case VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP:
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("Filesystem driver type not supported"));
- return -1;
-
- case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS:
- if (!virQEMUDriverIsPrivileged(driver)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtiofs is not yet supported in session
mode"));
- return -1;
- }
- if (fs->accessmode != VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtiofs only supports passthrough
accessmode"));
- return -1;
- }
- if (fs->wrpolicy != VIR_DOMAIN_FS_WRPOLICY_DEFAULT) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtiofs does not support wrpolicy"));
- return -1;
- }
- if (fs->model != VIR_DOMAIN_FS_MODEL_DEFAULT) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtiofs does not support model"));
- return -1;
- }
- if (fs->format != VIR_STORAGE_FILE_NONE) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtiofs does not support format"));
- return -1;
- }
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_USER_FS)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("virtiofs is not supported with this QEMU
binary"));
- return -1;
- }
- if (qemuDomainDefValidateVirtioFSSharedMemory(def) < 0)
- return -1;
- break;
-
- case VIR_DOMAIN_FS_DRIVER_TYPE_LAST:
- default:
- virReportEnumRangeError(virDomainFSDriverType, fs->fsdriver);
- return -1;
- }
-
- return 0;
-}
-
static int
qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
@@ -5940,7 +5823,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
break;
case VIR_DOMAIN_DEVICE_FS:
- ret = qemuDomainDeviceDefValidateFS(dev->data.fs, def, driver, qemuCaps);
+ ret = qemuValidateDomainDeviceDefFS(dev->data.fs, def, driver, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_NVRAM:
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 5438431e93..79fc56b849 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -2893,3 +2893,122 @@ qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef
*graphics,
return 0;
}
+
+
+static int
+qemuValidateDomainDefVirtioFSSharedMemory(const virDomainDef *def)
+{
+ size_t numa_nodes = virDomainNumaGetNodeCount(def->numa);
+ size_t i;
+
+ if (numa_nodes == 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtiofs requires one or more NUMA nodes"));
+ return -1;
+ }
+
+ for (i = 0; i < numa_nodes; i++) {
+ virDomainMemoryAccess node_access =
+ virDomainNumaGetNodeMemoryAccessMode(def->numa, i);
+
+ switch (node_access) {
+ case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT:
+ if (def->mem.access != VIR_DOMAIN_MEMORY_ACCESS_SHARED) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtiofs requires shared memory"));
+ return -1;
+ }
+ break;
+ case VIR_DOMAIN_MEMORY_ACCESS_SHARED:
+ break;
+ case VIR_DOMAIN_MEMORY_ACCESS_PRIVATE:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtiofs requires shared memory"));
+ return -1;
+
+ case VIR_DOMAIN_MEMORY_ACCESS_LAST:
+ default:
+ virReportEnumRangeError(virDomainMemoryAccess, node_access);
+ return -1;
+
+ }
+ }
+ return 0;
+}
+
+
+int
+qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs,
+ const virDomainDef *def,
+ virQEMUDriverPtr driver,
+ virQEMUCapsPtr qemuCaps)
+{
+ if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("only supports mount filesystem type"));
+ return -1;
+ }
+
+ switch ((virDomainFSDriverType) fs->fsdriver) {
+ case VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT:
+ case VIR_DOMAIN_FS_DRIVER_TYPE_PATH:
+ break;
+
+ case VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE:
+ if (fs->accessmode != VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("only supports passthrough accessmode"));
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_FS_DRIVER_TYPE_LOOP:
+ case VIR_DOMAIN_FS_DRIVER_TYPE_NBD:
+ case VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Filesystem driver type not supported"));
+ return -1;
+
+ case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS:
+ if (!virQEMUDriverIsPrivileged(driver)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtiofs is not yet supported in session
mode"));
+ return -1;
+ }
+ if (fs->accessmode != VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtiofs only supports passthrough
accessmode"));
+ return -1;
+ }
+ if (fs->wrpolicy != VIR_DOMAIN_FS_WRPOLICY_DEFAULT) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtiofs does not support wrpolicy"));
+ return -1;
+ }
+ if (fs->model != VIR_DOMAIN_FS_MODEL_DEFAULT) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtiofs does not support model"));
+ return -1;
+ }
+ if (fs->format != VIR_STORAGE_FILE_NONE) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtiofs does not support format"));
+ return -1;
+ }
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_USER_FS)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtiofs is not supported with this QEMU
binary"));
+ return -1;
+ }
+ if (qemuValidateDomainDefVirtioFSSharedMemory(def) < 0)
+ return -1;
+ break;
+
+ case VIR_DOMAIN_FS_DRIVER_TYPE_LAST:
+ default:
+ virReportEnumRangeError(virDomainFSDriverType, fs->fsdriver);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/src/qemu/qemu_validate.h b/src/qemu/qemu_validate.h
index 3b34cd55a2..623f80fcb2 100644
--- a/src/qemu/qemu_validate.h
+++ b/src/qemu/qemu_validate.h
@@ -56,3 +56,7 @@ int qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef
*graphics,
const virDomainDef *def,
virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps);
+int qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs,
+ const virDomainDef *def,
+ virQEMUDriverPtr driver,
+ virQEMUCapsPtr qemuCaps);
--
2.25.1