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(a)redhat.com>
---
docs/formatdomain.html.in | 4 ++--
src/conf/domain_conf.c | 29 +++++++++++++++++++----------
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index d0c1741..e78fb26 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3355,8 +3355,8 @@
(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>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9c6c739..eabba68 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3997,7 +3997,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;
@@ -4085,6 +4085,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 devices address "));
+ return -1;
+ }
+ }
return 0;
}
@@ -11860,8 +11872,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,
@@ -11922,11 +11934,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;
}
@@ -15974,9 +15986,6 @@ virDomainDefParseXML(xmlDocPtr xml,
}
def->hostdevs[def->nhostdevs++] = hostdev;
-
- if (virDomainDefMaybeAddHostdevSCSIcontroller(def) < 0)
- goto error;
}
VIR_FREE(nodes);
--
2.1.0