[libvirt] [PATCH 4/4] test: Support virStorageFindPoolSources

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

 



The results are hardcoded into the test driver, no option to read from a
testfile is implemented at this time.

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 src/test/test_driver.c |   75 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 71 insertions(+), 4 deletions(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 888bc9c..aabad9a 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -225,6 +225,29 @@ static const char *defaultPoolXML =
 "  </target>"
 "</pool>";
 
+static const char *defaultPoolSourcesLogicalXML =
+"<sources>\n"
+"  <source>\n"
+"    <device path='/dev/sda20'/>\n"
+"    <name>testvg1</name>\n"
+"    <format type='lvm2'/>\n"
+"  </source>\n"
+"  <source>\n"
+"    <device path='/dev/sda21'/>\n"
+"    <name>testvg2</name>\n"
+"    <format type='lvm2'/>\n"
+"  </source>\n"
+"</sources>\n";
+
+static const char *defaultPoolSourcesNetFSXML =
+"<sources>\n"
+"  <source>\n"
+"    <host name='%s'/>\n"
+"    <dir path='/testshare'/>\n"
+"    <format type='nfs'/>\n"
+"  </source>\n"
+"</sources>\n";
+
 static const char *defaultNodeXML =
 "<device>"
 "  <name>computer</name>"
@@ -3210,12 +3233,56 @@ cleanup:
 }
 
 static char *
-testStorageFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
-                           const char *type ATTRIBUTE_UNUSED,
-                           const char *srcSpec ATTRIBUTE_UNUSED,
+testStorageFindPoolSources(virConnectPtr conn,
+                           const char *type,
+                           const char *srcSpec,
                            unsigned int flags ATTRIBUTE_UNUSED)
 {
-    return NULL;
+    virStoragePoolSourcePtr source = NULL;
+    int pool_type;
+    char *ret = NULL;
+
+    pool_type = virStoragePoolTypeFromString(type);
+    if (!pool_type) {
+        testError(conn, VIR_ERR_INTERNAL_ERROR,
+                  _("unknown storage pool type %s"), type);
+        goto cleanup;
+    }
+
+    if (srcSpec) {
+        source = virStoragePoolDefParseSourceString(conn, srcSpec, pool_type);
+        if (!source)
+            goto cleanup;
+    }
+
+    switch (pool_type) {
+
+    case VIR_STORAGE_POOL_LOGICAL:
+        ret = strdup(defaultPoolSourcesLogicalXML);
+        if (!ret)
+            virReportOOMError(conn);
+        break;
+
+    case VIR_STORAGE_POOL_NETFS:
+        if (!source || !source->host.name) {
+            testError(conn, VIR_ERR_INVALID_ARG,
+                      "%s", "hostname must be specified for netfs sources");
+            goto cleanup;
+        }
+
+        if (virAsprintf(&ret, defaultPoolSourcesNetFSXML,
+                        source->host.name) < 0)
+            virReportOOMError(conn);
+        break;
+
+    default:
+        testError(conn, VIR_ERR_NO_SUPPORT,
+                  _("pool type '%s' does not support source discovery"), type);
+    }
+
+cleanup:
+    virStoragePoolSourceFree(source);
+    return ret;
 }
 
 
-- 
1.6.0.6

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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]