From 0d8b24f6b66304c65265c66770d000062c1bc03d Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Fri, 19 Jun 2015 14:23:13 -0400 Subject: [PATCH] conf: Change when virDomainHostdevAssignAddress is called 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 element is provided with an
. Signed-off-by: John Ferlan --- 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 d0c174105..e78fb2656 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 lspci or - with virsh - nodedev-list. See above for + with virsh nodedev-list. For SCSI devices a 'drive' + address type must be used. See above for more details on the address element.
driver
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f0951209d..78142ce1a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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); -- 2.39.5