[PATCH 06/17] conf: Add virStorageSource member for SCSI host device config data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The backend for the SCSI host device is a storage source. While the
definition doesn't look like that it's converted to a storage source
when the VM is running.

Add the storage source to the definition object and also parse/format
it's private data which will be used for internal state storage while
the VM is running.

Note that the virStorageSourcePtr may not be allocated all the time so
the private data parser allocates it if there is any private data
present.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 24 ++++++++++++++++++++++--
 src/conf/domain_conf.h |  1 +
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 05c2c63f58..f93cd60c2b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3019,6 +3019,8 @@ virDomainHostdevSubsysSCSIClear(virDomainHostdevSubsysSCSIPtr scsisrc)
         scsisrc->u.iscsi.src = NULL;
     } else {
         VIR_FREE(scsisrc->u.host.adapter);
+        virObjectUnref(scsisrc->u.host.src);
+        scsisrc->u.host.src = NULL;
     }
 }

@@ -8263,7 +8265,9 @@ virDomainStorageNetworkParseHosts(xmlNodePtr node,
 static int
 virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
                                           xmlXPathContextPtr ctxt,
-                                          virDomainHostdevSubsysSCSIPtr scsisrc)
+                                          virDomainHostdevSubsysSCSIPtr scsisrc,
+                                          unsigned int flags,
+                                          virDomainXMLOptionPtr xmlopt)
 {
     virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
     g_autofree char *bus = NULL;
@@ -8313,6 +8317,16 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
         return -1;
     }

+    if (flags & VIR_DOMAIN_DEF_PARSE_STATUS &&
+        xmlopt && xmlopt->privateData.storageParse) {
+        if ((ctxt->node = virXPathNode("./privateData", ctxt))) {
+            if (!scsihostsrc->src &&
+                !(scsihostsrc->src = virStorageSourceNew()))
+                return -1;
+            if (xmlopt->privateData.storageParse(ctxt, scsihostsrc->src) < 0)
+                return -1;
+        }
+    }
     return 0;
 }

@@ -8413,7 +8427,8 @@ virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode,

     switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) {
     case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE:
-        return virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, ctxt, scsisrc);
+        return virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, ctxt, scsisrc,
+                                                         flags, xmlopt);

     case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI:
         return virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scsisrc, ctxt,
@@ -26305,6 +26320,11 @@ virDomainHostdevDefFormatSubsysSCSI(virBufferPtr buf,
         virBufferAsprintf(&sourceChildBuf, " bus='%u' target='%u' unit='%llu'",
                           scsihostsrc->bus, scsihostsrc->target, scsihostsrc->unit);
         virBufferAddLit(&sourceChildBuf, "/>\n");
+
+        if (scsihostsrc->src &&
+            virDomainDiskSourceFormatPrivateData(&sourceChildBuf, scsihostsrc->src,
+                                                 flags, xmlopt) < 0)
+            return -1;
     }

     virXMLFormatElement(buf, "source", &sourceAttrBuf, &sourceChildBuf);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 14a376350c..cf76f340ee 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -245,6 +245,7 @@ struct _virDomainHostdevSubsysSCSIHost {
     unsigned bus;
     unsigned target;
     unsigned long long unit;
+    virStorageSourcePtr src;
 };

 struct _virDomainHostdevSubsysSCSIiSCSI {
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux