]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Change when virDomainHostdevAssignAddress is called
authorJohn Ferlan <jferlan@redhat.com>
Fri, 19 Jun 2015 18:23:13 +0000 (14:23 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 3 Aug 2015 20:48:45 +0000 (16:48 -0400)
Rather than calling virDomainHostdevAssignAddress during the parsing
of the XML, move the setting of a default hostdev address to domain/
device post processing.

Since the parse code no longer generates an address, we can remove
the virDomainDefMaybeAddHostdevSCSIcontroller since the call to
virDomainHostdevAssignAddress will attempt to add the controllers
that were not already defined in the XML.

This patch will also enforce that the address type is type 'drive'
when a SCSI subsystem <hostdev> element is provided with an <address>.

Signed-off-by: John Ferlan <jferlan@redhat.com>
docs/formatdomain.html.in
src/conf/domain_conf.c

index d0c174105081d9c41b1a00f63b8b9c5892659aab..e78fb265684c15ce61ad4268d08558bc526eed66 100644 (file)
       (starting with 0x) or octal (starting with 0) form.
       For PCI devices the element carries 4 attributes allowing to designate
       the device as can be found with the <code>lspci</code> or
-      with <code>virsh
-      nodedev-list</code>. <a href="#elementsAddress">See above</a> for
+      with <code>virsh nodedev-list</code>. For SCSI devices a 'drive'
+      address type must be used. <a href="#elementsAddress">See above</a> for
       more details on the address element.</dd>
       <dt><code>driver</code></dt>
       <dd>
index f0951209d75293162090f1ff0196d4e4b2eea19d..78142ce1ac7e1d93a05ef7d6de9d740cdf10b1c2 100644 (file)
@@ -4029,7 +4029,7 @@ static int
 virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
                                     const virDomainDef *def,
                                     virCapsPtr caps ATTRIBUTE_UNUSED,
-                                    virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED)
+                                    virDomainXMLOptionPtr xmlopt)
 {
     if (dev->type == VIR_DOMAIN_DEVICE_CHR) {
         virDomainChrDefPtr chr = dev->data.chr;
@@ -4117,6 +4117,18 @@ virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
         video->vram = VIR_ROUND_UP_POWER_OF_TWO(video->vram);
     }
 
+    if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
+        virDomainHostdevDefPtr hdev = dev->data.hostdev;
+
+        if (hdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+            hdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
+            hdev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+            virDomainHostdevAssignAddress(xmlopt, def, hdev) < 0) {
+                virReportError(VIR_ERR_XML_ERROR, "%s",
+                               _("Cannot assign SCSI host device address"));
+                return -1;
+        }
+    }
     return 0;
 }
 
@@ -11887,8 +11899,8 @@ virDomainVideoDefParseXML(xmlNodePtr node,
 }
 
 static virDomainHostdevDefPtr
-virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt,
-                            const virDomainDef *vmdef,
+virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
+                            const virDomainDef *vmdef ATTRIBUTE_UNUSED,
                             xmlNodePtr node,
                             xmlXPathContextPtr ctxt,
                             virHashTablePtr bootHash,
@@ -11949,11 +11961,11 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt,
             }
             break;
         case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
-            if (def->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
-                virDomainHostdevAssignAddress(xmlopt, vmdef, def) < 0) {
-
+            if (def->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+                def->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
                 virReportError(VIR_ERR_XML_ERROR, "%s",
-                               _("SCSI host devices must have address specified"));
+                               _("SCSI host device must use 'drive' "
+                                 "address type"));
                 goto error;
             }
 
@@ -15995,9 +16007,6 @@ virDomainDefParseXML(xmlDocPtr xml,
         }
 
         def->hostdevs[def->nhostdevs++] = hostdev;
-
-        if (virDomainDefMaybeAddHostdevSCSIcontroller(def) < 0)
-            goto error;
     }
     VIR_FREE(nodes);