Move validation of the filesystem device out of qemu_command. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/qemu/qemu_command.c | 25 ---------------------- src/qemu/qemu_domain.c | 46 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8617b010dc..f938ec22d3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2707,17 +2707,6 @@ qemuBuildFSStr(virDomainFSDefPtr fs) const char *driver = qemuDomainFSDriverTypeToString(fs->fsdriver); const char *wrpolicy = virDomainFSWrpolicyTypeToString(fs->wrpolicy); - if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("only supports mount filesystem type")); - goto error; - } - - if (!driver) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Filesystem driver type not supported")); - goto error; - } virBufferAdd(&opt, driver, -1); if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_PATH || @@ -2729,14 +2718,6 @@ qemuBuildFSStr(virDomainFSDefPtr fs) } else if (fs->accessmode == VIR_DOMAIN_FS_ACCESSMODE_SQUASH) { virBufferAddLit(&opt, ",security_model=none"); } - } else { - /* For other fs drivers, default(passthru) should always - * be supported */ - if (fs->accessmode != VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("only supports passthrough accessmode")); - goto error; - } } if (fs->wrpolicy) @@ -2767,12 +2748,6 @@ qemuBuildFSDevStr(const virDomainDef *def, { virBuffer opt = VIR_BUFFER_INITIALIZER; - if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("can only passthrough directories")); - goto error; - } - if (qemuBuildVirtioDevStr(&opt, "virtio-9p", qemuCaps, VIR_DOMAIN_DEVICE_FS, fs) < 0) { goto error; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 670b928c4c..bd7e8c2648 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6274,6 +6274,47 @@ qemuDomainDeviceDefValidateIOMMU(const virDomainIOMMUDef *iommu, } +static int +qemuDomainDeviceDefValidateFS(virDomainFSDefPtr fs, + const virDomainDef *def ATTRIBUTE_UNUSED, + virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED) +{ + 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_LAST: + default: + virReportEnumRangeError(virDomainFSDriverType, fs->fsdriver); + return -1; + } + + return 0; +} + + static int qemuDomainDeviceDefValidateZPCIAddress(virDomainDeviceInfoPtr info, virQEMUCapsPtr qemuCaps) @@ -6429,8 +6470,11 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, ret = qemuDomainDeviceDefValidateIOMMU(dev->data.iommu, def, qemuCaps); break; - case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: + ret = qemuDomainDeviceDefValidateFS(dev->data.fs, def, qemuCaps); + break; + + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_NVRAM: -- 2.19.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list