https://bugzilla.redhat.com/show_bug.cgi?id=1210587 (partial)
If a SCSI subsystem <hostdev> element address is provided, we need to
make sure the address provided doesn't conflict with an existing or
libvirt generated address for a SCSI <disk> element.
This will fix the issue where the domain XML provided an <address> for
the <hostdev>, but not the <disk> element where the address provided
ends up being the same address used for the <disk>. A <disk> address
is generated using it's assigned <target> 'dev' name prior to the
check/validation of the <hostdev> address value.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/domain_conf.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 44ce71b..eba264d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11872,7 +11872,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
}
static virDomainHostdevDefPtr
-virDomainHostdevDefParseXML(const virDomainDef *vmdef ATTRIBUTE_UNUSED,
+virDomainHostdevDefParseXML(const virDomainDef *vmdef,
xmlNodePtr node,
xmlXPathContextPtr ctxt,
virHashTablePtr bootHash,
@@ -11939,6 +11939,26 @@ virDomainHostdevDefParseXML(const virDomainDef *vmdef
ATTRIBUTE_UNUSED,
_("SCSI host device must use 'drive' "
"address type"));
goto error;
+ } else if (def->info->type ==
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
+ /* Ensure provided address doesn't conflict with existing
+ * scsi disk drive address
+ */
+ virDomainDeviceDriveAddressPtr addr = &def->info->addr.drive;
+ if (virDomainDriveAddressIsUsedByDisk(vmdef,
+ VIR_DOMAIN_DISK_BUS_SCSI,
+ addr->controller,
+ addr->bus,
+ addr->target,
+ addr->unit)) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("SCSI host address controller='%u'
"
+ "bus='%u' target='%u'
unit='%u' in "
+ "use by a SCSI disk"),
+ addr->controller, addr->bus,
+ addr->target, addr->unit);
+ goto error;
+ }
}
if (virXPathBoolean("boolean(./readonly)", ctxt))
--
2.1.0