+ if (VIR_STRDUP_QUIET(address, hostsrc->wwpn) < 0) {
+ VIR_WARN("OOM while encoding audit message");
+ goto cleanup;
+ }
+ break;
default:
VIR_WARN("Unexpected hostdev type while encoding audit message: %d",
hostdev->source.subsys.type);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3a4123d..618a214 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2323,6 +2323,9 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
} else {
VIR_FREE(scsisrc->u.host.adapter);
}
+ } else if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) {
+ virDomainHostdevSubsysSCSIVHostPtr hostsrc = &def->source.subsys.u.scsi_host;
+ VIR_FREE(hostsrc->wwpn);
}
break;
}
@@ -6094,6 +6097,58 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode,
return ret;
}
+static int
+virDomainHostdevSubsysSCSIVHostDefParseXML(xmlNodePtr sourcenode,
+ virDomainHostdevDefPtr def)
+{
+ char *protocol = NULL;
+ virDomainHostdevSubsysSCSIVHostPtr hostsrc = &def->source.subsys.u.scsi_host;
+
+ if (!(protocol = virXMLPropString(sourcenode, "protocol"))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("Missing scsi_host subsystem protocol"));
+ return -1;
+ }
+
+ if ((hostsrc->protocol =
+ virDomainHostdevSubsysSCSIHostProtocolTypeFromString(protocol)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unknown scsi_host subsystem protocol '%s'"),
+ protocol);
+ goto cleanup;
+ }
+
+ switch ((virDomainHostdevSubsysSCSIHostProtocolType) hostsrc->protocol) {
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_VHOST:
+ if (!(hostsrc->wwpn = virXMLPropString(sourcenode, "wwpn"))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("missing vhost-scsi hostdev source wwpn"));
+ goto cleanup;
+ }
+
+ if (!STRPREFIX(hostsrc->wwpn, "naa.") ||
+ !virValidateWWN(hostsrc->wwpn + 4)) {
+ virReportError(VIR_ERR_XML_ERROR, "%s", _("malformed 'wwpn' value"));
+ goto cleanup;
+ }
+ break;
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_NONE:
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_LAST:
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Invalid hostdev protocol '%s'"),
+ virDomainHostdevSubsysSCSIHostProtocolTypeToString(hostsrc->protocol));
+ goto cleanup;
+ break;
+ }
+
+ return 0;
+
+ cleanup:
+ VIR_FREE(hostsrc->wwpn);
+ VIR_FREE(protocol);
+ return -1;
+}
+
static int
virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
@@ -6218,6 +6273,11 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
goto error;
break;
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
+ if (virDomainHostdevSubsysSCSIVHostDefParseXML(sourcenode, def) < 0)
+ goto error;
+ break;
+
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("address type='%s' not supported in hostdev interfaces"),
@@ -13023,6 +13083,15 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt,
def->shareable = true;
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
+ if (def->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ def->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
+ def->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("SCSI_host host device must use 'pci' "
+ "or 'ccw' address type"));
+ goto error;
+ }
+ break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
break;
@@ -13907,7 +13976,14 @@ virDomainHostdevMatchSubsys(virDomainHostdevDefPtr a,
else
return virDomainHostdevMatchSubsysSCSIHost(a, b);
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
- /* Fall through for now */
+ if (a->source.subsys.u.scsi_host.protocol !=
+ b->source.subsys.u.scsi_host.protocol)
+ return 0;
+ if (STREQ(a->source.subsys.u.scsi_host.wwpn,
+ b->source.subsys.u.scsi_host.wwpn))
+ return 1;
+ else
+ return 0;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
return 0;
}
@@ -20814,9 +20890,11 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
unsigned int flags,
bool includeTypeInAddr)
{
+ bool closedSource = false;
virDomainHostdevSubsysUSBPtr usbsrc = &def->source.subsys.u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &def->source.subsys.u.pci;
virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi;
+ virDomainHostdevSubsysSCSIVHostPtr hostsrc = &def->source.subsys.u.scsi_host;
virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
@@ -20857,6 +20935,15 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
protocol, iscsisrc->path);
}
+ if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) {
+ const char *protocol =
+ virDomainHostdevSubsysSCSIHostProtocolTypeToString(hostsrc->protocol);
+ closedSource = true;
+
+ virBufferAsprintf(buf, " protocol='%s' wwpn='%s'/",
+ protocol, hostsrc->wwpn);
+ }
+
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
@@ -20910,6 +20997,8 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
scsihostsrc->unit);
}
break;
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
+ break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected hostdev type %d"),
@@ -20925,6 +21014,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf,
}
virBufferAdjustIndent(buf, -2);
+ if (!closedSource)
virBufferAddLit(buf, "</source>\n");