]> xenbits.xensource.com Git - libvirt.git/commitdiff
node_device_driver.c: use virConnectValidateURIPath()
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Thu, 26 Sep 2019 14:56:40 +0000 (11:56 -0300)
committerCole Robinson <crobinso@redhat.com>
Thu, 26 Sep 2019 21:25:20 +0000 (17:25 -0400)
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/node_device/node_device_driver.c

index 8fb00d0c86ad2632ffdbcff7894f40b1c10a42a7..578489c5be6658db7f95a9e1c25fc5635fe9cfb1 100644 (file)
@@ -58,21 +58,10 @@ nodeConnectOpen(virConnectPtr conn,
         return VIR_DRV_OPEN_ERROR;
     }
 
-    if (driver->privileged) {
-        if (STRNEQ(conn->uri->path, "/system")) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("unexpected nodedev URI path '%s', try nodedev:///system"),
-                           conn->uri->path);
-            return VIR_DRV_OPEN_ERROR;
-        }
-    } else {
-        if (STRNEQ(conn->uri->path, "/session")) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("unexpected nodedev URI path '%s', try nodedev:///session"),
-                           conn->uri->path);
-            return VIR_DRV_OPEN_ERROR;
-        }
-    }
+    if (!virConnectValidateURIPath(conn->uri->path,
+                                   "nodedev",
+                                   driver->privileged))
+        return VIR_DRV_OPEN_ERROR;
 
     if (virConnectOpenEnsureACL(conn) < 0)
         return VIR_DRV_OPEN_ERROR;