From fae7a7354c29938faacf9a2406f90f93e30fec9d Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Thu, 14 Sep 2017 11:01:40 -0400 Subject: [PATCH] conf: Move encryption validation Rather than checking during XML processing, move the check for valid into virDomainDiskDefParseValidate and alter the text of the message slightly to be a bit more correct. --- src/conf/domain_conf.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index aefe6f989e..f1b2447def 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8605,6 +8605,19 @@ virDomainDiskDefParseValidate(const virDomainDiskDef *def) if (virDomainDiskSourceDefParseAuthValidate(def->src) < 0) return -1; + if (def->src->encryption) { + virStorageEncryptionPtr encryption = def->src->encryption; + + if (encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS && + encryption->encinfo.cipher_name) { + + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("supplying for domain disk definition " + "is unnecessary")); + return -1; + } + } + return 0; } @@ -9095,17 +9108,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, def->startupPolicy = val; } - if (encryption) { - if (encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS && - encryption->encinfo.cipher_name) { - - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("supplying the for a domain is " - "unnecessary")); - goto error; - } - } - def->dst = target; target = NULL; def->src->auth = authdef; -- 2.47.2