diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e7d4ac90fa766864125f1e20c20896903d880718..e4eba1a957eb1eb997468ed779765a1b0c6dd8e6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12992,31 +12992,6 @@ virDomainDiskControllerMatch(int controller_type, int disk_bus) return false; } -/* Return true if there's a duplicate disk[]->dst name for the same bus */ -bool -virDomainDiskDefDstDuplicates(virDomainDefPtr def) -{ - size_t i, j; - - /* optimization */ - if (def->ndisks <= 1) - return false; - - for (i = 1; i < def->ndisks; i++) { - for (j = 0; j < i; j++) { - if (STREQ(def->disks[i]->dst, def->disks[j]->dst)) { - virReportError(VIR_ERR_XML_ERROR, - _("target '%s' duplicated for disk sources " - "'%s' and '%s'"), - def->disks[i]->dst, - NULLSTR(virDomainDiskGetSource(def->disks[i])), - NULLSTR(virDomainDiskGetSource(def->disks[j]))); - return true; - } - } - } - return false; -} int virDomainDiskIndexByAddress(virDomainDefPtr def, @@ -23992,6 +23967,15 @@ int virDomainDiskDefCheckDuplicateInfo(virDomainDiskDefPtr a, virDomainDiskDefPtr b) { + if (STREQ(a->dst, b->dst)) { + virReportError(VIR_ERR_XML_ERROR, + _("target '%s' duplicated for disk sources '%s' and '%s'"), + a->dst, + NULLSTR(virDomainDiskGetSource(a)), + NULLSTR(virDomainDiskGetSource(b))); + return -1; + } + if (a->wwn && b->wwn && STREQ(a->wwn, b->wwn)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Disks '%s' and '%s' have identical WWN"), @@ -24017,12 +24001,10 @@ virDomainDefCheckDuplicateDiskInfo(virDomainDefPtr def) size_t j; for (i = 0; i < def->ndisks; i++) { - if (def->disks[i]->wwn || def->disks[i]->serial) { - for (j = i + 1; j < def->ndisks; j++) { - if (virDomainDiskDefCheckDuplicateInfo(def->disks[i], - def->disks[j]) < 0) - return -1; - } + for (j = i + 1; j < def->ndisks; j++) { + if (virDomainDiskDefCheckDuplicateInfo(def->disks[i], + def->disks[j]) < 0) + return -1; } } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index aa1908efc4363e5348562d0f50519842ec6360f7..4afae59c785f21694b8f9dc5584603b075afabc1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2770,7 +2770,6 @@ int virDomainDefCompatibleDevice(virDomainDefPtr def, void virDomainRNGDefFree(virDomainRNGDefPtr def); -bool virDomainDiskDefDstDuplicates(virDomainDefPtr def); int virDomainDiskIndexByAddress(virDomainDefPtr def, virDevicePCIAddressPtr pci_controller, unsigned int bus, unsigned int target, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 23a15a4e25b7a1a48a6f5f1484615e619d1b9574..516e07375f2df2039f3900ccee5ee25487e07a0d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -258,7 +258,6 @@ virDomainDiskCacheTypeFromString; virDomainDiskCacheTypeToString; virDomainDiskDefAssignAddress; virDomainDiskDefCheckDuplicateInfo; -virDomainDiskDefDstDuplicates; virDomainDiskDefForeachPath; virDomainDiskDefFree; virDomainDiskDefNew; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8943270176520a6e6ee964a4284c3e12df76bd0a..d7f19f37e60476c4bbbdc53d2ba03c570bfa9763 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4228,9 +4228,6 @@ qemuBuildDriveDevStr(virDomainDefPtr def, const char *contAlias; int controllerModel; - if (virDomainDiskDefDstDuplicates(def)) - goto error; - if (qemuCheckDiskConfig(disk) < 0) goto error; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6fc11c6a08b749e1171c944b9fee0a255df5171b..d10808b56a49b2228f4b0d33d271a18118020cf3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7278,6 +7278,9 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator))) goto cleanup; + if (qemuProcessStartValidate(def, qemuCaps, false, false) < 0) + goto cleanup; + /* Since we're just exporting args, we can't do bridge/network/direct * setups, since libvirt will normally create TAP/macvtap devices * directly. We convert those configs into generic 'ethernet' diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 18a5a12d2af960e44d3a0aed085d551f90fb68f0..87717804bf27db8143804d57d8a842e27ac10191 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -794,12 +794,6 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, case VIR_DOMAIN_DISK_DEVICE_DISK: case VIR_DOMAIN_DISK_DEVICE_LUN: for (i = 0; i < vm->def->ndisks; i++) { - if (STREQ(vm->def->disks[i]->dst, disk->dst)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("target %s already exists"), disk->dst); - goto cleanup; - } - if (virDomainDiskDefCheckDuplicateInfo(vm->def->disks[i], disk) < 0) goto cleanup; }