]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Wed May 2 18:38:00 BST 2007 Richard Jones <rjones@redhat.com>
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 2 May 2007 17:36:25 +0000 (17:36 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 2 May 2007 17:36:25 +0000 (17:36 +0000)
* src/proxy_internal.c, src/qemu_internal.c, src/test.c,
  src/xen_unified.c, src/xend_internal.c, src/xs_internal.c:
  During virConnectOpen, be careful to call __virRaiseError
  with conn = NULL so that the error message is not
  discarded.

ChangeLog
src/proxy_internal.c
src/qemu_internal.c
src/test.c
src/xen_unified.c
src/xend_internal.c
src/xs_internal.c

index 28ee8c0020e16a9146eec8ced23bbbfc4802f382..74dff1edb2749c71d388c0e36c6931a29908b53b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed May  2 18:38:00 BST 2007 Richard Jones <rjones@redhat.com>
+
+       * src/proxy_internal.c, src/qemu_internal.c, src/test.c,
+         src/xen_unified.c, src/xend_internal.c, src/xs_internal.c:
+         During virConnectOpen, be careful to call __virRaiseError
+         with conn = NULL so that the error message is not
+         discarded.
+
 Wed May  2 17:55:12 IST 2007 Mark McLoughlin <markmc@redhat.com>
 
        * qemud/libvirtd.in: synchronously restart the daemon in
index 006911da9b3ccdea967dd2ab3482edbf14efd89b..267ffd071958110fe0eca645fb9e14e6f4495ab8 100644 (file)
@@ -544,7 +544,7 @@ xenProxyOpen(virConnectPtr conn, const char *name ATTRIBUTE_UNUSED, int flags)
 
     fd = virProxyOpenClientSocket(PROXY_SOCKET_PATH);
     if (fd < 0) {
-           virProxyError(conn, VIR_ERR_NO_XEN, PROXY_SOCKET_PATH);
+           virProxyError(NULL, VIR_ERR_NO_XEN, PROXY_SOCKET_PATH);
         return(-1);
     }
     priv->proxy = fd;
@@ -554,7 +554,7 @@ xenProxyOpen(virConnectPtr conn, const char *name ATTRIBUTE_UNUSED, int flags)
     req.len = sizeof(req);
     ret = xenProxyCommand(conn, &req, NULL, 1);
     if ((ret < 0) || (req.command != VIR_PROXY_NONE)) {
-           virProxyError(conn, VIR_ERR_OPERATION_FAILED, __FUNCTION__);
+           virProxyError(NULL, VIR_ERR_OPERATION_FAILED, __FUNCTION__);
         xenProxyClose(conn);
        return(-1);
     }
index e8c7708e468383b7439ee079010d4cc66f73701b..1e677a21d2e1cdef0af4408262fe2e432170a771 100644 (file)
@@ -146,7 +146,7 @@ qemuForkServer(void)
     int ret, pid, status;
 
     if (!proxyPath) {
-        fprintf(stderr, "failed to find qemu\n");
+        qemuError (NULL, NULL, VIR_ERR_INVALID_ARG, "no proxyPath");
         return(-1);
     }
 
@@ -231,6 +231,7 @@ qemuOpenClientUNIX(virConnectPtr conn ATTRIBUTE_UNUSED,
  retry:
     fd = socket(PF_UNIX, SOCK_STREAM, 0);
     if (fd < 0) {
+        qemuError (NULL, NULL, VIR_ERR_SYSTEM_ERROR, "socket");
         return VIR_DRV_OPEN_ERROR;
     }
 
@@ -256,6 +257,10 @@ qemuOpenClientUNIX(virConnectPtr conn ATTRIBUTE_UNUSED,
             usleep(5000 * trials * trials);
             goto retry;
         }
+        __virRaiseError (NULL, NULL, NULL,
+                         VIR_FROM_QEMU, VIR_ERR_SYSTEM_ERROR, VIR_ERR_ERROR,
+                         "connect", NULL, NULL, errno, 0,
+                         "connect: %s: %s", path, strerror (errno));
         return VIR_DRV_OPEN_ERROR;
     }
 
@@ -346,34 +351,43 @@ static int qemuOpenConnection(virConnectPtr conn, xmlURIPtr uri, int readonly) {
     int autostart = 0;
 
     if (uri->server != NULL) {
+        qemuError (NULL, NULL, VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
         return VIR_DRV_OPEN_ERROR;
     }
 
-    if (!strcmp(uri->path, "/system")) {
+    if (strcmp(uri->path, "/system") == 0) {
         if (readonly) {
             if (snprintf(path, sizeof(path), "%s/run/libvirt/qemud-sock-ro", LOCAL_STATE_DIR) >= (int)sizeof(path)) {
+                qemuError (NULL, NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
                 return VIR_DRV_OPEN_ERROR;
             }
         } else {
             if (snprintf(path, sizeof(path), "%s/run/libvirt/qemud-sock", LOCAL_STATE_DIR) >= (int)sizeof(path)) {
+                qemuError (NULL, NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
                 return VIR_DRV_OPEN_ERROR;
             }
         }
-    } else if (!strcmp(uri->path, "/session")) {
+    } else if (strcmp(uri->path, "/session") == 0) {
         struct passwd *pw;
         int uid;
 
         if ((uid = geteuid()) < 0) {
+            qemuError (NULL, NULL, VIR_ERR_SYSTEM_ERROR, "geteuid");
             return VIR_DRV_OPEN_ERROR;
         }
 
-        if (!(pw = getpwuid(uid)))
+        if (!(pw = getpwuid(uid))) {
+            qemuError (NULL, NULL, VIR_ERR_SYSTEM_ERROR, "getpwuid");
             return VIR_DRV_OPEN_ERROR;
+        }
 
         if (snprintf(path, sizeof(path), "@%s/.libvirt/qemud-sock", pw->pw_dir) == sizeof(path)) {
             return VIR_DRV_OPEN_ERROR;
         }
         autostart = 1;
+    } else {
+        qemuError (NULL, NULL, VIR_ERR_INVALID_ARG, "path should be /system or /session - for example, qemu:///session");
+        return VIR_DRV_OPEN_ERROR;
     }
     return qemuOpenClientUNIX(conn, path, autostart);
 }
@@ -395,7 +409,7 @@ static int qemuOpen(virConnectPtr conn,
 
     uri = xmlParseURI(name);
     if (uri == NULL) {
-        qemuError(conn, NULL, VIR_ERR_NO_SUPPORT, name);
+        qemuError(NULL, NULL, VIR_ERR_NO_SUPPORT, name);
         return VIR_DRV_OPEN_DECLINED;
     }
 
@@ -409,7 +423,7 @@ static int qemuOpen(virConnectPtr conn,
     /* Create per-connection private data. */
     priv = conn->privateData = malloc (sizeof *priv);
     if (!priv) {
-        qemuError (conn, NULL, VIR_ERR_NO_MEMORY, __FUNCTION__);
+        qemuError (NULL, NULL, VIR_ERR_NO_MEMORY, __FUNCTION__);
         return VIR_DRV_OPEN_ERROR;
     }
 
index 2ae2948969b7040093d8bd128da5cdd60406c37a..c748d2dc8a9833c9aa0d69292f1a02b5a485f3bc 100644 (file)
@@ -562,7 +562,7 @@ static int testOpenFromFile(virConnectPtr conn,
     if (ret == 0) {
         nodeInfo->nodes = l;
     } else if (ret == -2) {
-       testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu numa nodes"));
+       testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node cpu numa nodes"));
        goto error;
     }
 
@@ -570,7 +570,7 @@ static int testOpenFromFile(virConnectPtr conn,
     if (ret == 0) {
         nodeInfo->sockets = l;
     } else if (ret == -2) {
-       testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu sockets"));
+       testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node cpu sockets"));
        goto error;
     }
 
@@ -578,7 +578,7 @@ static int testOpenFromFile(virConnectPtr conn,
     if (ret == 0) {
         nodeInfo->cores = l;
     } else if (ret == -2) {
-       testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu cores"));
+       testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node cpu cores"));
        goto error;
     }
 
@@ -586,7 +586,7 @@ static int testOpenFromFile(virConnectPtr conn,
     if (ret == 0) {
         nodeInfo->threads = l;
     } else if (ret == -2) {
-       testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu threads"));
+       testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node cpu threads"));
        goto error;
     }
 
@@ -597,14 +597,14 @@ static int testOpenFromFile(virConnectPtr conn,
            nodeInfo->cpus = l;
        }
     } else if (ret == -2) {
-       testError(conn, NULL, VIR_ERR_XML_ERROR, _("node active cpu"));
+       testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node active cpu"));
        goto error;
     }
     ret = virXPathLong("string(/node/cpu/mhz[1])", ctxt, &l);
     if (ret == 0) {
         nodeInfo->mhz = l;
     } else if (ret == -2) {
-        testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu mhz"));
+        testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node cpu mhz"));
        goto error;
     }
 
@@ -619,7 +619,7 @@ static int testOpenFromFile(virConnectPtr conn,
     if (ret == 0) {
         nodeInfo->memory = l;
     } else if (ret == -2) {
-        testError(conn, NULL, VIR_ERR_XML_ERROR, _("node memory"));
+        testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node memory"));
        goto error;
     }
 
@@ -717,7 +717,7 @@ int testOpen(virConnectPtr conn,
 
     uri = xmlParseURI(name);
     if (uri == NULL) {
-        testError(conn, NULL, VIR_ERR_NO_SUPPORT, name);
+        testError(NULL, NULL, VIR_ERR_NO_SUPPORT, name);
         return VIR_DRV_OPEN_DECLINED;
     }
 
@@ -730,7 +730,7 @@ int testOpen(virConnectPtr conn,
     if (!uri->path
         || uri->path[0] == '\0'
         || (uri->path[0] == '/' && uri->path[1] == '\0')) {
-        testError (conn, NULL, VIR_ERR_INVALID_ARG,
+        testError (NULL, NULL, VIR_ERR_INVALID_ARG,
                    _("testOpen: supply a path or use test:///default"));
         return VIR_DRV_OPEN_ERROR;
     }
@@ -743,7 +743,7 @@ int testOpen(virConnectPtr conn,
     /* Allocate per-connection private data. */
     priv = conn->privateData = malloc (sizeof (struct _testPrivate));
     if (!priv) {
-        testError(conn, NULL, VIR_ERR_NO_MEMORY, _("allocating private data"));
+        testError(NULL, NULL, VIR_ERR_NO_MEMORY, _("allocating private data"));
         return VIR_DRV_OPEN_ERROR;
     }
     priv->handle = -1;
index 12b542e890e23aa6b4376f242ad6ce4196671b69..5c740d87452cb5ded5a3893c7931d13a3002742c 100644 (file)
@@ -95,7 +95,7 @@ xenUnifiedOpen (virConnectPtr conn, const char *name, int flags)
     /* Allocate per-connection private data. */
     priv = malloc (sizeof *priv);
     if (!priv) {
-        xenUnifiedError (conn, VIR_ERR_NO_MEMORY, "allocating private data");
+        xenUnifiedError (NULL, VIR_ERR_NO_MEMORY, "allocating private data");
         return VIR_DRV_OPEN_ERROR;
     }
     conn->privateData = priv;
index 1358c0b26c324a673658a2e288ebe12cf81f01b7..49b28f6d3f8b18c6f3cc3b1c238cf2ef2c4bdb28 100644 (file)
@@ -894,7 +894,7 @@ xenDaemonOpen_tcp(virConnectPtr conn, const char *host, int port)
     pent = gethostbyname(host);
     if (pent == NULL) {
         if (inet_aton(host, &ip) == 0) {
-            virXendError(conn, VIR_ERR_UNKNOWN_HOST, host);
+            virXendError(NULL, VIR_ERR_UNKNOWN_HOST, host);
             errno = ESRCH;
             return (-1);
         }
@@ -1960,14 +1960,14 @@ xenDaemonOpen(virConnectPtr conn, const char *name,
          */
         uri = xmlParseURI(name);
         if (uri == NULL) {
-            virXendError(conn, VIR_ERR_NO_SUPPORT, name);
+            virXendError(NULL, VIR_ERR_NO_SUPPORT, name);
             goto failed;
         }
 
         if (uri->scheme == NULL) {
             /* It should be a file access */
             if (uri->path == NULL) {
-                virXendError(conn, VIR_ERR_NO_SUPPORT, name);
+                virXendError(NULL, VIR_ERR_NO_SUPPORT, name);
                 goto failed;
             }
             ret = xenDaemonOpen_unix(conn, uri->path);
@@ -1985,7 +1985,7 @@ xenDaemonOpen(virConnectPtr conn, const char *name,
             if (ret == -1)
                 goto failed;
         } else {
-            virXendError(conn, VIR_ERR_NO_SUPPORT, name);
+            virXendError(NULL, VIR_ERR_NO_SUPPORT, name);
             goto failed;
         }
     }
index 6e6fbbb96429d8909fc8c3200b3ac0305b10fed2..cac9f30abcfcd3472de08c68ad512bfe6e682d3f 100644 (file)
@@ -340,7 +340,7 @@ xenStoreOpen(virConnectPtr conn,
 #endif /* ! PROXY */
 
     if (priv->xshandle == NULL) {
-        virXenStoreError(conn, VIR_ERR_NO_XEN, 
+        virXenStoreError(NULL, VIR_ERR_NO_XEN, 
                             _("failed to connect to Xen Store"));
         return (-1);
     }