The disk target is mandatory and used as a designator in error messages of other validation steps, so we must validate it first. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/conf/domain_validate.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 9069b60e37..1bc62c364d 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -597,6 +597,20 @@ virDomainDiskDefValidate(const virDomainDef *def, { virStorageSource *next; + /* disk target is used widely in other code so it must be validated first */ + if (!disk->dst) { + if (disk->src->srcpool) { + virReportError(VIR_ERR_NO_TARGET, _("pool = '%s', volume = '%s'"), + disk->src->srcpool->pool, + disk->src->srcpool->volume); + } else { + virReportError(VIR_ERR_NO_TARGET, + disk->src->path ? "%s" : NULL, disk->src->path); + } + + return -1; + } + if (virDomainDiskDefValidateSource(disk->src) < 0) return -1; @@ -776,19 +790,6 @@ virDomainDiskDefValidate(const virDomainDef *def, if (disk->wwn && !virValidateWWN(disk->wwn)) return -1; - if (!disk->dst) { - if (disk->src->srcpool) { - virReportError(VIR_ERR_NO_TARGET, _("pool = '%s', volume = '%s'"), - disk->src->srcpool->pool, - disk->src->srcpool->volume); - } else { - virReportError(VIR_ERR_NO_TARGET, - disk->src->path ? "%s" : NULL, disk->src->path); - } - - return -1; - } - if ((disk->device == VIR_DOMAIN_DISK_DEVICE_DISK || disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) && !STRPREFIX(disk->dst, "hd") && -- 2.31.1