[Libvir] PATCH: 15/16: stub test driver

Daniel P. Berrange berrange at redhat.com
Tue Feb 12 04:41:09 UTC 2008


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




More information about the libvir-list mailing list