domain_conf.c: move blkio path check to domain_validate.c

Move this check to a new virDomainDefTunablesValidate(), which
is called by virDomainDefValidateInternal().

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Daniel Henrique Barboza 2020-12-04 11:28:31 -03:00
parent fee929dd20
commit 388ad4432d
3 changed files with 26 additions and 10 deletions

View File

@ -6983,6 +6983,9 @@ virDomainDefValidateInternal(const virDomainDef *def,
if (virDomainDefVideoValidate(def) < 0)
return -1;
if (virDomainDefTunablesValidate(def) < 0)
return -1;
if (virDomainNumaDefValidate(def->numa) < 0)
return -1;
@ -20880,7 +20883,7 @@ virDomainDefTunablesParse(virDomainDefPtr def,
unsigned int flags)
{
g_autofree xmlNodePtr *nodes = NULL;
size_t i, j;
size_t i;
int n;
/* Extract blkio cgroup tunables */
@ -20901,15 +20904,6 @@ virDomainDefTunablesParse(virDomainDefPtr def,
&def->blkio.devices[i]) < 0)
return -1;
def->blkio.ndevices++;
for (j = 0; j < i; j++) {
if (STREQ(def->blkio.devices[j].path,
def->blkio.devices[i].path)) {
virReportError(VIR_ERR_XML_ERROR,
_("duplicate blkio device path '%s'"),
def->blkio.devices[i].path);
return -1;
}
}
}
VIR_FREE(nodes);

View File

@ -496,3 +496,24 @@ virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard,
return 0;
}
int
virDomainDefTunablesValidate(const virDomainDef *def)
{
size_t i, j;
for (i = 0; i < def->blkio.ndevices; i++) {
for (j = 0; j < i; j++) {
if (STREQ(def->blkio.devices[j].path,
def->blkio.devices[i].path)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("duplicate blkio device path '%s'"),
def->blkio.devices[i].path);
return -1;
}
}
}
return 0;
}

View File

@ -42,3 +42,4 @@ int virDomainRNGDefValidate(const virDomainRNGDef *rng,
const virDomainDef *def);
int virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard,
const virDomainDef *def);
int virDomainDefTunablesValidate(const virDomainDef *def);