We never check for disks with duplicate targets connected to the same controller/bus/etc. That means we go ahead, create the same IDs for them and pass them to qemu, which subsequently fails to start. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=968899 Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> --- src/conf/domain_conf.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3398d8b..01720e1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2629,6 +2629,45 @@ virDomainDeviceInfoIterate(virDomainDefPtr def, static int +virDomainDefRejectDuplicateDiskTargets(virDomainDefPtr def) +{ + char *disk_id = NULL; + int ret = -1; + size_t i = 0; + virHashTablePtr targets = NULL; + + if (!(targets = virHashCreate(def->ndisks, NULL))) + goto cleanup; + + for (i = 0; i < def->ndisks; i++) { + virDomainDiskDefPtr disk = def->disks[i]; + + if (virAsprintf(&disk_id, "%d%s%d%d%d%d", + disk->bus, + NULLSTR(disk->dst), + disk->info.addr.drive.controller, + disk->info.addr.drive.bus, + disk->info.addr.drive.target, + disk->info.addr.drive.unit) < 0) + goto cleanup; + + if (virHashAddEntry(targets, disk_id, NULL) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Multiple disks with same address and target ('%s')"), + def->disks[i]->dst); + VIR_FREE(disk_id); + goto cleanup; + } + VIR_FREE(disk_id); + } + + ret = 0; + cleanup: + virHashFree(targets); + return ret; +} + +static int virDomainDefRejectDuplicateControllers(virDomainDefPtr def) { int max_idx[VIR_DOMAIN_CONTROLLER_TYPE_LAST]; @@ -2762,7 +2801,8 @@ virDomainDefPostParseInternal(virDomainDefPtr def, } } - if (virDomainDefRejectDuplicateControllers(def) < 0) + if (virDomainDefRejectDuplicateControllers(def) < 0 || + virDomainDefRejectDuplicateDiskTargets(def) < 0) return -1; return 0; } -- 1.8.3.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list