On Wed, Feb 26, 2020 at 12:57:08PM +0100, Ján Tomko wrote: > Reject unsupported configurations. > > Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> > --- > src/qemu/qemu_domain.c | 82 +++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 77 insertions(+), 5 deletions(-) > > diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c > index e1ee8d4692..d85c089dce 100644 > --- a/src/qemu/qemu_domain.c > +++ b/src/qemu/qemu_domain.c > @@ -8270,11 +8270,52 @@ 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 G_GNUC_UNUSED, > - virQEMUCapsPtr qemuCaps G_GNUC_UNUSED) > + const virDomainDef *def, > + virQEMUDriverPtr driver, > + virQEMUCapsPtr qemuCaps) > { > if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT) { > virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", > @@ -8303,8 +8344,39 @@ qemuDomainDeviceDefValidateFS(virDomainFSDefPtr fs, > return -1; > > case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS: > - /* TODO: vhost-user-fs-pci */ > - return 0; > + 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: > @@ -8483,7 +8555,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, > break; > > case VIR_DOMAIN_DEVICE_FS: > - ret = qemuDomainDeviceDefValidateFS(dev->data.fs, def, qemuCaps); > + ret = qemuDomainDeviceDefValidateFS(dev->data.fs, def, driver, qemuCaps); > break; > > case VIR_DOMAIN_DEVICE_NVRAM: > -- > 2.24.1 Looks good to me. Reviewed-by: Masayoshi Mizuma <m.mizuma@xxxxxxxxxxxxxx> - Masa