]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Enforce WWN to be unique among VM's disks
authorPeter Krempa <pkrempa@redhat.com>
Tue, 7 Apr 2015 14:08:32 +0000 (16:08 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 14 Apr 2015 06:44:36 +0000 (08:44 +0200)
Operating systems use the identifier to name the disks. As the name
suggests the ID should be unique.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1208009

docs/formatdomain.html.in
src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms
src/qemu/qemu_process.c

index 7ceb1fa63df5c458d0cff40213ed657bd68efc74..e9217496921831240be8c6fd487df39d53a2dd3d 100644 (file)
       <dt><code>wwn</code></dt>
       <dd>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)
         <span class='since'>Since 0.10.1</span>
       </dd>
       <dt><code>vendor</code></dt>
index 8ccf7631758c085d9e2c3df4507da3be808ec3e1..58b98c639c55c419de44e558052d7309a6617637 100644 (file)
@@ -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;
+}
index 95cbb9cbce20c212fa3f22d110b204fbcd388ec6..e6fa3c922079a51b74ef86f81c56f366b3c35d80 100644 (file)
@@ -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 */
index 67ab526e2f75d84647322db55a0f57b69fc0307c..716628368a95bf78ff4ce524d3f53c1b45920d10 100644 (file)
@@ -198,6 +198,7 @@ virDomainCpuPlacementModeTypeFromString;
 virDomainCpuPlacementModeTypeToString;
 virDomainDefAddImplicitControllers;
 virDomainDefCheckABIStability;
+virDomainDefCheckDuplicateDiskWWN;
 virDomainDefCheckUnsupportedMemoryHotplug;
 virDomainDefClearCCWAddresses;
 virDomainDefClearDeviceAliases;
index 753afe8ae84b3aa21a100644e37da97ba703242f..d9611c9ac7549bde25e455ce78164d39d16c3463 100644 (file)
@@ -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.
      */