Move the rest of the validations to the vaidation code.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/domain_conf.c | 44 --------------------------------------
src/conf/domain_validate.c | 44 ++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 867d74f31f..ff408188d5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9440,8 +9440,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
if (!(wwn = virXMLNodeContentString(cur)))
return NULL;
- if (!virValidateWWN(wwn))
- return NULL;
} else if (!vendor &&
virXMLNodeNameEqual(cur, "vendor")) {
if (!(vendor = virXMLNodeContentString(cur)))
@@ -9462,48 +9460,6 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt,
}
}
- /* Only CDROM and Floppy devices are allowed missing source path
- * to indicate no media present. LUN is for raw access CD-ROMs
- * that are not attached to a physical device presently */
- if (virStorageSourceIsEmpty(def->src) &&
- def->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
- virReportError(VIR_ERR_NO_SOURCE,
- target ? "%s" : NULL, target);
- return NULL;
- }
-
- if (!target) {
- if (def->src->srcpool) {
- tmp = g_strdup_printf("pool = '%s', volume =
'%s'",
- def->src->srcpool->pool,
def->src->srcpool->volume);
-
- virReportError(VIR_ERR_NO_TARGET, "%s", tmp);
- VIR_FREE(tmp);
- } else {
- virReportError(VIR_ERR_NO_TARGET, def->src->path ? "%s" :
NULL, def->src->path);
- }
- return NULL;
- }
-
- if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
- !STRPREFIX(target, "fd")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Invalid floppy device name: %s"), target);
- return NULL;
- }
-
- if ((def->device == VIR_DOMAIN_DISK_DEVICE_DISK ||
- def->device == VIR_DOMAIN_DISK_DEVICE_LUN) &&
- !STRPREFIX((const char *)target, "hd") &&
- !STRPREFIX((const char *)target, "sd") &&
- !STRPREFIX((const char *)target, "vd") &&
- !STRPREFIX((const char *)target, "xvd") &&
- !STRPREFIX((const char *)target, "ubd")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Invalid harddisk device name: %s"), target);
- return NULL;
- }
-
if (snapshot) {
def->snapshot = virDomainSnapshotLocationTypeFromString(snapshot);
if (def->snapshot <= 0) {
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 1073da3bfa..686b9e8d16 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -699,6 +699,50 @@ 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") &&
+ !STRPREFIX(disk->dst, "sd") &&
+ !STRPREFIX(disk->dst, "vd") &&
+ !STRPREFIX(disk->dst, "xvd") &&
+ !STRPREFIX(disk->dst, "ubd")) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid harddisk device name: %s"), disk->dst);
+ return -1;
+ }
+
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
+ !STRPREFIX(disk->dst, "fd")) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid floppy device name: %s"), disk->dst);
+ return -1;
+ }
+
+ /* Only CDROM and Floppy devices are allowed missing source path to
+ * indicate no media present. LUN is for raw access CD-ROMs that are not
+ * attached to a physical device presently */
+ if (virStorageSourceIsEmpty(disk->src) &&
+ disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
+ virReportError(VIR_ERR_NO_SOURCE, "%s", disk->dst);
+ return -1;
+ }
+
return 0;
}
--
2.30.2