From: Peter Krempa Date: Tue, 13 Apr 2021 12:05:15 +0000 (+0200) Subject: virDomainDiskDefValidate: Consolidate conditions X-Git-Tag: v7.3.0-rc1~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ceca89d43d383193c5637f79a20e87ff0553af7e;p=thirdparty%2Flibvirt.git virDomainDiskDefValidate: Consolidate conditions Consolidate the checks for '' and viritio queues under already existing blocks which have the same condition. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 570279cd92..4d253599af 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -451,13 +451,12 @@ virDomainDiskDefValidate(const virDomainDef *def, "device='lun'"), disk->dst); return -1; } - } - - if (disk->src->pr && - disk->device != VIR_DOMAIN_DISK_DEVICE_LUN) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _(" allowed only for lun devices")); - return -1; + } else { + if (disk->src->pr) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _(" allowed only for lun devices")); + return -1; + } } /* Reject disks with a bus type that is not compatible with the @@ -474,13 +473,6 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } - if (disk->queues && disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("queues attribute in disk driver element is only " - "supported by virtio-blk")); - return -1; - } - if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) { if (disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO || disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL || @@ -492,6 +484,12 @@ virDomainDiskDefValidate(const virDomainDef *def, return -1; } + if (disk->queues) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("queues attribute in disk driver element is only supported by virtio-blk")); + return -1; + } + if (virDomainCheckVirtioOptionsAreAbsent(disk->virtio) < 0) return -1; }