From: Peter Krempa Date: Tue, 7 Sep 2021 08:01:39 +0000 (+0200) Subject: virDomainDiskDefValidate: Move validation of disk target X-Git-Tag: v7.8.0-rc1~295 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0404d4fc386d29231f94e2b8b4736d290e403aca;p=thirdparty%2Flibvirt.git virDomainDiskDefValidate: Move validation of disk target 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 Reviewed-by: Michal Privoznik --- 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") &&