We document that <address type='unassigned'/> can be used only
for <hostdev/>-s. However, corresponding validation rule is
missing. Let's put the rule into hypervisor agnostic part of
validation process so that all drivers can benefit.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
---
src/conf/domain_validate.c | 45 ++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index e9baf1d41a..d5e74db243 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -2257,10 +2257,55 @@ virDomainGraphicsDefValidate(const virDomainDef *def,
return 0;
}
+static int
+virDomainDeviceInfoValidate(const virDomainDeviceDef *dev)
+{
+ virDomainDeviceInfo *info;
+
+ if (!(info = virDomainDeviceGetInfo(dev)))
+ return 0;
+
+ switch ((virDomainDeviceAddressType) info->type) {
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE:
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO:
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390:
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW:
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL:
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID:
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB:
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO:
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA:
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
+ /* No validation for these address types yet */
+ break;
+
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED:
+ if (dev->type != VIR_DOMAIN_DEVICE_HOSTDEV) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("address of type '%s' is supported only for
hostdevs"),
+ virDomainDeviceAddressTypeToString(info->type));
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST:
+ default:
+ virReportEnumRangeError(virDomainDeviceAddressType, info->type);
+ return -1;
+ }
+
+ return 0;
+}
+
static int
virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
const virDomainDef *def)
{
+ if (virDomainDeviceInfoValidate(dev) < 0)
+ return -1;
+
switch ((virDomainDeviceType) dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
return virDomainDiskDefValidate(def, dev->data.disk);
--
2.34.1