mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu_conf: check for duplicate security drivers
Using the same driver multiple times is pointless and it can result in confusing errors: $ virsh start test error: Failed to start domain test error: internal error: security label already defined for VM https://bugzilla.redhat.com/show_bug.cgi?id=1153891
This commit is contained in:
parent
5c703ca396
commit
d16704fd60
@ -460,7 +460,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
|
|||||||
|
|
||||||
p = virConfGetValue(conf, "security_driver");
|
p = virConfGetValue(conf, "security_driver");
|
||||||
if (p && p->type == VIR_CONF_LIST) {
|
if (p && p->type == VIR_CONF_LIST) {
|
||||||
size_t len;
|
size_t len, j;
|
||||||
virConfValuePtr pp;
|
virConfValuePtr pp;
|
||||||
|
|
||||||
/* Calc length and check items */
|
/* Calc length and check items */
|
||||||
@ -476,6 +476,13 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0, pp = p->list; pp; i++, pp = pp->next) {
|
for (i = 0, pp = p->list; pp; i++, pp = pp->next) {
|
||||||
|
for (j = 0; j < i; j++) {
|
||||||
|
if (STREQ(pp->str, cfg->securityDriverNames[j])) {
|
||||||
|
virReportError(VIR_ERR_CONF_SYNTAX,
|
||||||
|
_("Duplicate security driver %s"), pp->str);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (VIR_STRDUP(cfg->securityDriverNames[i], pp->str) < 0)
|
if (VIR_STRDUP(cfg->securityDriverNames[i], pp->str) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user