mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
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 <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
cf6b34c683
commit
0404d4fc38
@ -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") &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user