Add code that will permit a hostdev tag to specify a vhost protocol,
and parse the associated XML within it. But don't do anything with
that information just yet.
Signed-off-by: Eric Farman <farman(a)linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk(a)linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9681d6c..d6b9c42 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2225,6 +2225,14 @@
virDomainHostdevSubsysSCSIiSCSIClear(virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc
iscsisrc->auth = NULL;
}
+static void
+virDomainHostdevSubsysSCSIVhostClear(virDomainHostdevSubsysSCSIVhostPtr vhostsrc)
+{
+ if (!vhostsrc)
+ return;
+ VIR_FREE(vhostsrc->wwpn);
+}
+
void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
{
if (!def)
@@ -2261,6 +2269,9 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
if (scsisrc->protocol ==
VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
virDomainHostdevSubsysSCSIiSCSIClear(&scsisrc->u.iscsi);
+ } else if (scsisrc->protocol ==
+ VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_VHOST) {
+ virDomainHostdevSubsysSCSIVhostClear(&scsisrc->u.vhost);
} else {
VIR_FREE(scsisrc->u.host.adapter);
}
@@ -5943,6 +5954,31 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode,
}
static int
+virDomainHostdevSubsysSCSIVhostDefParseXML(xmlNodePtr sourcenode,
+ virDomainHostdevSubsysSCSIPtr def)
+{
+ virDomainHostdevSubsysSCSIVhostPtr vhostsrc = &def->u.vhost;
+
+ if (!(vhostsrc->wwpn = virXMLPropString(sourcenode, "wwpn"))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("missing vhost-scsi hostdev source path name"));
+ goto cleanup;
+ }
+
+ if (!STRPREFIX(vhostsrc->wwpn, "naa.") ||
+ strlen(vhostsrc->wwpn) != strlen("naa.") + 16) {
+ virReportError(VIR_ERR_XML_ERROR, "%s", _("malformed
'wwpn' value"));
+ goto cleanup;
+ }
+
+ return 0;
+
+ cleanup:
+ VIR_FREE(vhostsrc->wwpn);
+ return -1;
+}
+
+static int
virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode,
virDomainHostdevSubsysSCSIPtr scsisrc)
{
@@ -5962,6 +5998,8 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode,
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
ret = virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scsisrc);
+ else if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_VHOST)
+ ret = virDomainHostdevSubsysSCSIVhostDefParseXML(sourcenode, scsisrc);
else
ret = virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc);
--
1.9.1