Re: PATCH: 15/16: stub test driver

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

 



This just stubs out an empty no-op storage driver impl for the test
driver. This is basically to prevent the ensure the test suite does
not try to contact the daemon for storage APIs, which would cause
tests to fail.

This needs to be extended to provide a fully-fledged test impl of
the storage APIs in the future. It is intended that the test driver
be able to leverage the XML parsing & formatting code from the
storage_conf.{c,h} files, allowing greater code re-use across the
dummy test and real storage drivers.

 test.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff -r e2a1678e316e src/test.c
--- a/src/test.c	Thu Feb 07 12:34:16 2008 -0500
+++ b/src/test.c	Thu Feb 07 12:34:21 2008 -0500
@@ -2208,6 +2208,22 @@ static int testNetworkSetAutostart(virNe
     privnet->autostart = autostart ? 1 : 0;
     RELEASE_NETWORK();
     return (0);
+}
+
+static virDrvOpenStatus testStorageOpen(virConnectPtr conn,
+                                        xmlURIPtr uri ATTRIBUTE_UNUSED,
+                                        virConnectAuthPtr auth ATTRIBUTE_UNUSED,
+                                        int flags ATTRIBUTE_UNUSED) {
+    if (STRNEQ(conn->driver->name, "Test"))
+        return VIR_DRV_OPEN_DECLINED;
+
+    conn->storagePrivateData = conn->privateData;
+    return VIR_DRV_OPEN_SUCCESS;
+}
+
+static int testStorageClose(virConnectPtr conn) {
+    conn->storagePrivateData = NULL;
+    return 0;
 }
 
 
@@ -2301,6 +2317,12 @@ static virNetworkDriver testNetworkDrive
 };
 
 
+static virStorageDriver testStorageDriver = {
+    .name = "Test",
+    .open = testStorageOpen,
+    .close = testStorageClose,
+};
+
 /**
  * testRegister:
  *
@@ -2312,6 +2334,8 @@ testRegister(void)
     if (virRegisterDriver(&testDriver) < 0)
         return -1;
     if (virRegisterNetworkDriver(&testNetworkDriver) < 0)
+        return -1;
+    if (virRegisterStorageDriver(&testStorageDriver) < 0)
         return -1;
     return 0;
 }

-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

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