[PATCH 6/8] qemuDomainVirStorageSourceFindByNodeName: Extract nodename matching

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

 



Extract the matching of the node name of a single virStorage source so
that the logic can be extended in the upcoming patch.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d28ff0cd22..150f0736f3 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2884,6 +2884,25 @@ qemuDomainObjPrivateXMLParseBlockjobChain(xmlNodePtr node,
 }


+/**
+ * qemuDomainVirStorageSourceMatchNodename:
+ * @src: storage source to match
+ * @nodeName to match
+ *
+ * Returns true if any of the nodenames of @src matches @nodeName.
+ */
+static bool
+qemuDomainVirStorageSourceMatchNodename(virStorageSource *src,
+                                        const char *nodeName)
+{
+    const char *nodestorage = qemuBlockStorageSourceGetStorageNodename(src);
+    const char *nodeformat = qemuBlockStorageSourceGetFormatNodename(src);
+
+    return (nodeformat && STREQ(nodeformat, nodeName)) ||
+           (nodestorage && STREQ(nodestorage, nodeName));
+}
+
+
 /**
  * qemuDomainVirStorageSourceFindByNodeName:
  * @top: backing chain top
@@ -2900,11 +2919,7 @@ qemuDomainVirStorageSourceFindByNodeName(virStorageSource *top,
     virStorageSource *tmp;

     for (tmp = top; virStorageSourceIsBacking(tmp); tmp = tmp->backingStore) {
-        const char *nodestorage = qemuBlockStorageSourceGetStorageNodename(tmp);
-        const char *nodeformat = qemuBlockStorageSourceGetFormatNodename(tmp);
-
-        if ((nodeformat && STREQ(nodeformat, nodeName)) ||
-            (nodestorage && STREQ(nodestorage, nodeName)))
+        if (qemuDomainVirStorageSourceMatchNodename(tmp, nodeName))
             return tmp;
     }

-- 
2.47.0




[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