From: Daniel Henrique Barboza Date: Tue, 8 Dec 2020 20:52:24 +0000 (-0300) Subject: domain_conf.c: move virDomainControllerDefValidate() to domain_validate.c X-Git-Tag: v7.0.0-rc1~246 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=84da28a86d889bf74439822ea7af4016405f229b;p=thirdparty%2Flibvirt.git domain_conf.c: move virDomainControllerDefValidate() to domain_validate.c Next patch will add more validations to this function. Let's move it to domain_validate.c beforehand. Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2e918ec763..d340b304a2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6211,43 +6211,6 @@ virDomainNetDefValidate(const virDomainNetDef *net) } -static int -virDomainControllerDefValidate(const virDomainControllerDef *controller) -{ - if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) { - const virDomainPCIControllerOpts *opts = &controller->opts.pciopts; - - if (controller->idx > 255) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller index %d too high, maximum is 255"), - controller->idx); - return -1; - } - - /* Only validate the target index if it's been set */ - if (opts->targetIndex != -1) { - - if (opts->targetIndex < 0 || opts->targetIndex > 30) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller target index '%d' out of " - "range - must be 0-30"), - opts->targetIndex); - return -1; - } - - if ((controller->idx == 0 && opts->targetIndex != 0) || - (controller->idx != 0 && opts->targetIndex == 0)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Only the PCI controller with index 0 can " - "have target index 0, and vice versa")); - return -1; - } - } - } - return 0; -} - - static int virDomainHostdevDefValidate(const virDomainHostdevDef *hostdev) { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 09ab908ea3..416c24f97b 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -517,3 +517,40 @@ virDomainDefTunablesValidate(const virDomainDef *def) return 0; } + + +int +virDomainControllerDefValidate(const virDomainControllerDef *controller) +{ + if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + const virDomainPCIControllerOpts *opts = &controller->opts.pciopts; + + if (controller->idx > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller index %d too high, maximum is 255"), + controller->idx); + return -1; + } + + /* Only validate the target index if it's been set */ + if (opts->targetIndex != -1) { + + if (opts->targetIndex < 0 || opts->targetIndex > 30) { + virReportError(VIR_ERR_XML_ERROR, + _("PCI controller target index '%d' out of " + "range - must be 0-30"), + opts->targetIndex); + return -1; + } + + if ((controller->idx == 0 && opts->targetIndex != 0) || + (controller->idx != 0 && opts->targetIndex == 0)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Only the PCI controller with index 0 can " + "have target index 0, and vice versa")); + return -1; + } + } + } + return 0; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index 2bd9e71073..e8004e358d 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -43,3 +43,4 @@ int virDomainRNGDefValidate(const virDomainRNGDef *rng, int virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard, const virDomainDef *def); int virDomainDefTunablesValidate(const virDomainDef *def); +int virDomainControllerDefValidate(const virDomainControllerDef *controller);