diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 7ceb1fa63df5c458d0cff40213ed657bd68efc74..e9217496921831240be8c6fd487df39d53a2dd3d 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2453,7 +2453,8 @@
wwn
If present, this element specifies the WWN (World Wide Name)
of a virtual hard disk or CD-ROM drive. It must be composed
- of 16 hexadecimal digits.
+ of 16 hexadecimal digits and must be unique (at least among
+ disks of a single domain)
Since 0.10.1
vendor
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8ccf7631758c085d9e2c3df4507da3be808ec3e1..58b98c639c55c419de44e558052d7309a6617637 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23186,3 +23186,28 @@ virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
return false;
}
+
+
+int
+virDomainDefCheckDuplicateDiskWWN(virDomainDefPtr def)
+{
+ size_t i;
+ size_t j;
+
+ for (i = 0; i < def->ndisks; i++) {
+ if (def->disks[i]->wwn) {
+ for (j = i + 1; j < def->ndisks; j++) {
+ if (STREQ_NULLABLE(def->disks[i]->wwn,
+ def->disks[j]->wwn)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Disks '%s' and '%s' have identical WWN"),
+ def->disks[i]->dst,
+ def->disks[j]->dst);
+ return -1;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 95cbb9cbce20c212fa3f22d110b204fbcd388ec6..e6fa3c922079a51b74ef86f81c56f366b3c35d80 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3080,4 +3080,7 @@ virDomainParseMemory(const char *xpath,
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
ATTRIBUTE_NONNULL(1);
+int virDomainDefCheckDuplicateDiskWWN(virDomainDefPtr def)
+ ATTRIBUTE_NONNULL(1);
+
#endif /* __DOMAIN_CONF_H */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 67ab526e2f75d84647322db55a0f57b69fc0307c..716628368a95bf78ff4ce524d3f53c1b45920d10 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -198,6 +198,7 @@ virDomainCpuPlacementModeTypeFromString;
virDomainCpuPlacementModeTypeToString;
virDomainDefAddImplicitControllers;
virDomainDefCheckABIStability;
+virDomainDefCheckDuplicateDiskWWN;
virDomainDefCheckUnsupportedMemoryHotplug;
virDomainDefClearCCWAddresses;
virDomainDefClearDeviceAliases;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 753afe8ae84b3aa21a100644e37da97ba703242f..d9611c9ac7549bde25e455ce78164d39d16c3463 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4568,6 +4568,9 @@ int qemuProcessStart(virConnectPtr conn,
goto cleanup;
}
+ if (virDomainDefCheckDuplicateDiskWWN(vm->def) < 0)
+ goto cleanup;
+
/* "volume" type disk's source must be translated before
* cgroup and security setting.
*/