]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
Set conn->driver before running driver connectOpen method
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 2 May 2013 15:55:52 +0000 (16:55 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 24 Jun 2013 14:24:36 +0000 (15:24 +0100)
The access control checks in the 'connectOpen' driver method
will require 'conn->driver' to be non-NULL. Set this before
running the 'connectOpen' method and NULL-ify it again on
failure.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/libvirt.c

index b467679d0b9a35cae36ac30bd838758768d939b3..8e8f415cac91885b5126dcba1258a0edeb27b0db 100644 (file)
@@ -1201,6 +1201,7 @@ do_open(const char *name,
         }
 
         VIR_DEBUG("trying driver %d (%s) ...", i, virDriverTab[i]->name);
+        ret->driver = virDriverTab[i];
         res = virDriverTab[i]->connectOpen(ret, auth, flags);
         VIR_DEBUG("driver %d %s returned %s",
                   i, virDriverTab[i]->name,
@@ -1209,10 +1210,12 @@ do_open(const char *name,
                   (res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status")));
 
         if (res == VIR_DRV_OPEN_SUCCESS) {
-            ret->driver = virDriverTab[i];
             break;
         } else if (res == VIR_DRV_OPEN_ERROR) {
+            ret->driver = NULL;
             goto failed;
+        } else {
+            ret->driver = NULL;
         }
     }