]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fixed QEMU uri parsing/detection
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 21 Sep 2007 19:32:02 +0000 (19:32 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 21 Sep 2007 19:32:02 +0000 (19:32 +0000)
ChangeLog
src/qemu_driver.c

index a25c0ef7d4e6553408585b66605462e652e944e5..cc7b4aa14c8a11bb4cead381bd360cbfbe35ad8d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Sep 21 15:06:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
+
+       * src/qemu_driver.c: Use libxml for parsing & checking URIs
+
 Thu Sep 20 19:37:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
 
        * src/bridge.c, src/qemu_driver.c, configure.in: Try to detect
index 6482e0a10679456ce6dcfd6148d4d038a000738c..be75081002041c7de2f8874ebd8154a5939920ab 100644 (file)
@@ -45,6 +45,7 @@
 #include <pwd.h>
 #include <stdio.h>
 #include <sys/wait.h>
+#include <libxml/uri.h>
 
 #include <libvirt/virterror.h>
 
@@ -1362,25 +1363,39 @@ static int qemudMonitorCommand(struct qemud_driver *driver ATTRIBUTE_UNUSED,
 
 
 static virDrvOpenStatus qemudOpen(virConnectPtr conn,
-                           const char *name,
-                           int flags ATTRIBUTE_UNUSED) {
+                                  const char *name,
+                                  int flags ATTRIBUTE_UNUSED) {
+    xmlURIPtr uri = NULL;
     uid_t uid = getuid();
 
     if (qemu_driver == NULL)
         return VIR_DRV_OPEN_DECLINED;
 
+    uri = xmlParseURI(name);
+    if (uri == NULL || uri->scheme == NULL || uri->path == NULL)
+        goto decline;
+
+    if (STRNEQ (uri->scheme, "qemu"))
+        goto decline;
+
     if (uid != 0) {
-        if (STRNEQ (name, "qemu:///session"))
-            return VIR_DRV_OPEN_DECLINED;
+        if (STRNEQ (uri->path, "/session"))
+            goto decline;
     } else { /* root */
-        if (STRNEQ (name, "qemu:///system") &&
-            STRNEQ (name, "qemu:///session"))
-            return VIR_DRV_OPEN_DECLINED;
+        if (STRNEQ (uri->path, "/system") &&
+            STRNEQ (uri->path, "/session"))
+            goto decline; 
     }
 
     conn->privateData = qemu_driver;
 
+    xmlFreeURI(uri);
     return VIR_DRV_OPEN_SUCCESS;
+
+ decline:
+    if (uri != NULL)
+        xmlFreeURI(uri);
+    return VIR_DRV_OPEN_DECLINED;    
 }
 
 static int qemudClose(virConnectPtr conn) {