[libvirt] PATCH: 5/28: Stub out node device APIs in test driver

Daniel P. Berrange berrange at redhat.com
Sun Nov 30 23:29:25 UTC 2008


When adding the node device APIs we never added a stub for the test driver,
so  the test driver was connecting to the daemon for node device APIS,
which rather defeats the purpose of the test driver. This patch doesn't
implement the node device APIs, just stubs out the open/close methods
so we don't call into the daemon. 

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


Daniel

diff --git a/src/test.c b/src/test.c
--- a/src/test.c
+++ b/src/test.c
@@ -3220,6 +3220,22 @@ cleanup:
 }
 
 
+static virDrvOpenStatus testDevMonOpen(virConnectPtr conn,
+                                       virConnectAuthPtr auth ATTRIBUTE_UNUSED,
+                                       int flags ATTRIBUTE_UNUSED) {
+    if (STRNEQ(conn->driver->name, "Test"))
+        return VIR_DRV_OPEN_DECLINED;
+
+    conn->devMonPrivateData = conn->privateData;
+    return VIR_DRV_OPEN_SUCCESS;
+}
+
+static int testDevMonClose(virConnectPtr conn) {
+    conn->devMonPrivateData = NULL;
+    return 0;
+}
+
+
 static virDriver testDriver = {
     VIR_DRV_TEST,
     "Test",
@@ -3343,6 +3359,14 @@ static virStorageDriver testStorageDrive
     .volGetPath = testStorageVolumeGetPath,
 };
 
+static virDeviceMonitor testDevMonitor = {
+    .name = "Test",
+    .open = testDevMonOpen,
+    .close = testDevMonClose,
+};
+
+
+
 /**
  * testRegister:
  *
@@ -3357,5 +3381,8 @@ testRegister(void)
         return -1;
     if (virRegisterStorageDriver(&testStorageDriver) < 0)
         return -1;
+    if (virRegisterDeviceMonitor(&testDevMonitor) < 0)
+        return -1;
+
     return 0;
 }

-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list