]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Tue Feb 14 15:37:17 EST 2007 Mark McLoughlin <markmc@redhat.com>
authorMark McLoughlin <markmc@redhat.com>
Wed, 14 Feb 2007 15:40:53 +0000 (15:40 +0000)
committerMark McLoughlin <markmc@redhat.com>
Wed, 14 Feb 2007 15:40:53 +0000 (15:40 +0000)
        Note: potential ABI break here, but people should
        only really be using virError structs returned from
        libvirt itself.

        * include/libvirt/virterror.h: add virNetwork
        to virError

        * src/internal.h, src/virterror.c: add network param
        to __virRaiseError()

        * src/conf.c, src/hash.c, src/libvirt.c, src/proxy_internal.c,
        src/qemu_internal.c, src/sexpr.c, src/test.c, src/xen_internal.c,
        src/xend_internal.c, src/xm_internal.c, src/xml.c, src/xmlrpc.c,
        src/xs_internal.c: update.

17 files changed:
ChangeLog
include/libvirt/virterror.h
src/conf.c
src/hash.c
src/internal.h
src/libvirt.c
src/proxy_internal.c
src/qemu_internal.c
src/sexpr.c
src/test.c
src/virterror.c
src/xen_internal.c
src/xend_internal.c
src/xm_internal.c
src/xml.c
src/xmlrpc.c
src/xs_internal.c

index 1446c02a6ce5da0a89c43e7d4a58f99712701146..2a52db41d8982212c93bea620b5b0f7f19cd92da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Tue Feb 14 15:37:17 EST 2007 Mark McLoughlin <markmc@redhat.com>
+
+       Note: potential ABI break here, but people should
+       only really be using virError structs returned from
+       libvirt itself.
+
+       * include/libvirt/virterror.h: add virNetwork
+       to virError
+       
+       * src/internal.h, src/virterror.c: add network param
+       to __virRaiseError()
+       
+       * src/conf.c, src/hash.c, src/libvirt.c, src/proxy_internal.c,
+       src/qemu_internal.c, src/sexpr.c, src/test.c, src/xen_internal.c,
+       src/xend_internal.c, src/xm_internal.c, src/xml.c, src/xmlrpc.c,
+       src/xs_internal.c: update.
+       
 Tue Feb 14 15:33:05 EST 2007 Mark McLoughlin <markmc@redhat.com>
 
        * include/libvirt/libvirt.h.in: add the networks APIs
index 80d43f9cd9bc3c292a91e22fe49d36560265b379..cc0c95fa23996314a75fffdb63124af111576b86 100644 (file)
@@ -72,6 +72,7 @@ struct _virError {
     char       *str3;  /* extra string information */
     int                int1;   /* extra number information */
     int                int2;   /* extra number information */
+    virNetworkPtr net; /* the network if available */
 };
 
 /**
index 714194c08cdad0654a6fbdb26d78f442581c6210..b59daef35d1b3f8e162178c5833088500df602c4 100644 (file)
@@ -95,7 +95,7 @@ virConfError(virConfPtr conf ATTRIBUTE_UNUSED,
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR,
+    __virRaiseError(NULL, NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, line, 0, errmsg, info, line);
 }
 
index 8d7dd73063c5971413250c50ff222a55ecc6556a..2145af0b093ded858b4268de032ad1de2c1c0ba4 100644 (file)
@@ -617,7 +617,7 @@ virHashError(virConnectPtr conn, virErrorNumber error, const char *info)
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(conn, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR,
+    __virRaiseError(conn, NULL, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info);
 }
 
index d30a0a0d3b2c99c859a7cf35307f912f0102bfd1..237dfef47fa1d44a28f473de08160058091ff3be 100644 (file)
@@ -200,6 +200,7 @@ char *virDomainGetVMInfo(virDomainPtr domain,
  ************************************************************************/
 void __virRaiseError(virConnectPtr conn,
                     virDomainPtr dom,
+                    virNetworkPtr net,
                     int domain,
                     int code,
                     virErrorLevel level,
index c93058c6f8a30369504881a12aa55bbcba63f040..c4a82289a33fe9edac44b37153b5a1e3dead7a36 100644 (file)
@@ -107,7 +107,7 @@ virLibConnError(virConnectPtr conn, virErrorNumber error, const char *info)
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(conn, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR,
+    __virRaiseError(conn, NULL, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info);
 }
 
@@ -133,7 +133,7 @@ virLibDomainError(virDomainPtr domain, virErrorNumber error,
     if (error != VIR_ERR_INVALID_DOMAIN) {
         conn = domain->conn;
     }
-    __virRaiseError(conn, domain, VIR_FROM_DOM, error, VIR_ERR_ERROR,
+    __virRaiseError(conn, domain, NULL, VIR_FROM_DOM, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info);
 }
 
@@ -159,8 +159,7 @@ virLibNetworkError(virNetworkPtr network, virErrorNumber error,
     if (error != VIR_ERR_INVALID_NETWORK) {
         conn = network->conn;
     }
-    /* XXX: should be able to pass network pointer here */
-    __virRaiseError(conn, NULL, VIR_FROM_NET, error, VIR_ERR_ERROR,
+    __virRaiseError(conn, NULL, network, VIR_FROM_NET, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info);
 }
 
index 1323b3db2ed294216091e54ce3891e27aab80373..1e6e453cf8f550def8cb373e2e56e8f157bd145f 100644 (file)
@@ -116,7 +116,7 @@ virProxyError(virConnectPtr conn, virErrorNumber error, const char *info)
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(conn, NULL, VIR_FROM_PROXY, error, VIR_ERR_ERROR,
+    __virRaiseError(conn, NULL, NULL, VIR_FROM_PROXY, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info);
 }
 
index c5e226bc8462a702a4f1ee718fb1a69402396eaa..c5fe11303cbb88d6295ea421be8f458991d111b6 100644 (file)
@@ -61,7 +61,7 @@ qemuError(virConnectPtr con,
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(con, dom, VIR_FROM_QEMU, error, VIR_ERR_ERROR,
+    __virRaiseError(con, dom, NULL, VIR_FROM_QEMU, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info, 0);
 }
 
@@ -244,7 +244,7 @@ qemuOpenClientUNIX(virConnectPtr conn, const char *path, int autostart) {
         return (-1);
     }
 
-    conn->handle = fd;
+    conn->qemud_fd = fd;
 
     return (0);
 }
@@ -269,7 +269,7 @@ static int qemuProcessRequest(virConnectPtr conn,
 
     /* Block sending entire outgoing packet */
     while (outLeft) {
-        int got = write(conn->handle, out+outDone, outLeft);
+        int got = write(conn->qemud_fd, out+outDone, outLeft);
         if (got < 0) {
             return -1;
         }
@@ -279,7 +279,7 @@ static int qemuProcessRequest(virConnectPtr conn,
 
     /* Block waiting for header to come back */
     while (inLeft) {
-        int done = read(conn->handle, in+inGot, inLeft);
+        int done = read(conn->qemud_fd, in+inGot, inLeft);
         if (done <= 0) {
             return -1;
         }
@@ -307,7 +307,7 @@ static int qemuProcessRequest(virConnectPtr conn,
     /* Now block reading in body */
     inLeft = reply->header.dataSize;
     while (inLeft) {
-        int done = read(conn->handle, in+inGot, inLeft);
+        int done = read(conn->qemud_fd, in+inGot, inLeft);
         if (done <= 0) {
             return -1;
         }
@@ -389,11 +389,11 @@ static int qemuOpen(virConnectPtr conn,
         return -1;
     }
 
-    conn->handle = -1;
+    conn->qemud_fd = -1;
     qemuOpenConnection(conn, uri, flags & VIR_DRV_OPEN_RO ? 1 : 0);
     xmlFreeURI(uri);
 
-    if (conn->handle < 0) {
+    if (conn->qemud_fd < 0) {
         return -1;
     }
 
@@ -402,9 +402,9 @@ static int qemuOpen(virConnectPtr conn,
 
 
 static int qemuClose  (virConnectPtr conn) {
-    if (conn->handle != -1) {
-        close(conn->handle);
-        conn->handle = -1;
+    if (conn->qemud_fd != -1) {
+        close(conn->qemud_fd);
+        conn->qemud_fd = -1;
     }
     return 0;
 }
index 1eaa02310470b4f0cad9235b1fe4e65edbf43155..12599518cba3024b9b9b6414f0ba3bf05658bf5d 100644 (file)
@@ -38,7 +38,7 @@ virSexprError(virErrorNumber error, const char *info)
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(NULL, NULL, VIR_FROM_SEXPR, error, VIR_ERR_ERROR,
+    __virRaiseError(NULL, NULL, NULL, VIR_FROM_SEXPR, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info);
 }
 
index 6762ec89178638072df34d4ea1250055d21e5f73..4025f99dcf019ced948afb87782cdb7be1928a7e 100644 (file)
@@ -198,7 +198,7 @@ testError(virConnectPtr con,
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(con, dom, VIR_FROM_XEN, error, VIR_ERR_ERROR,
+    __virRaiseError(con, dom, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info, 0);
 }
 
index 23446c1f453b9d597e58ae9d7e1c209615dd523d..8a4ac0352913038f4b1e61cc8d2d5263898565ad 100644 (file)
@@ -17,7 +17,7 @@
 #include "internal.h"
 
 static virError lastErr =       /* the last error */
-{ 0, 0, NULL, VIR_ERR_NONE, NULL, NULL, NULL, NULL, NULL, 0, 0 };
+{ 0, 0, NULL, VIR_ERR_NONE, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL };
 static virErrorFunc virErrorHandler = NULL;     /* global error handlet */
 static void *virUserData = NULL;        /* associated data */
 
@@ -230,7 +230,7 @@ virConnSetErrorFunc(virConnectPtr conn, void *userData,
 void
 virDefaultErrorFunc(virErrorPtr err)
 {
-    const char *lvl = "", *dom = "", *domain = "";
+    const char *lvl = "", *dom = "", *domain = "", *network = "";
     int len;
 
     if ((err == NULL) || (err->code == VIR_ERR_OK))
@@ -277,24 +277,27 @@ virDefaultErrorFunc(virErrorPtr err)
     }
     if ((err->dom != NULL) && (err->code != VIR_ERR_INVALID_DOMAIN)) {
         domain = err->dom->name;
+    } else if ((err->net != NULL) && (err->code != VIR_ERR_INVALID_NETWORK)) {
+        network = err->net->name;
     }
     len = strlen(err->message);
     if ((err->domain == VIR_FROM_XML) && (err->code == VIR_ERR_XML_DETAIL) &&
         (err->int1 != 0))
-        fprintf(stderr, "libvir: %s%s %s: line %d: %s",
-                dom, lvl, domain, err->int1, err->message);
+        fprintf(stderr, "libvir: %s%s %s%s: line %d: %s",
+                dom, lvl, domain, network, err->int1, err->message);
     else if ((len == 0) || (err->message[len - 1] != '\n'))
-        fprintf(stderr, "libvir: %s%s %s: %s\n",
-                dom, lvl, domain, err->message);
+        fprintf(stderr, "libvir: %s%s %s%s: %s\n",
+                dom, lvl, domain, network, err->message);
     else
-        fprintf(stderr, "libvir: %s%s %s: %s",
-                dom, lvl, domain, err->message);
+        fprintf(stderr, "libvir: %s%s %s%s: %s",
+                dom, lvl, domain, network, err->message);
 }
 
 /**
  * __virRaiseError:
  * @conn: the connection to the hypervisor if available
  * @dom: the domain if available
+ * @net: the network if available
  * @domain: the virErrorDomain indicating where it's coming from
  * @code: the virErrorNumber code for the error
  * @level: the virErrorLevel for the error
@@ -310,7 +313,7 @@ virDefaultErrorFunc(virErrorPtr err)
  * immediately if a callback is found and store it for later handling.
  */
 void
-__virRaiseError(virConnectPtr conn, virDomainPtr dom,
+__virRaiseError(virConnectPtr conn, virDomainPtr dom, virNetworkPtr net,
                 int domain, int code, virErrorLevel level,
                 const char *str1, const char *str2, const char *str3,
                 int int1, int int2, const char *msg, ...)
@@ -349,6 +352,7 @@ __virRaiseError(virConnectPtr conn, virDomainPtr dom,
     virResetError(to);
     to->conn = conn;
     to->dom = dom;
+    to->net = net;
     to->domain = domain;
     to->code = code;
     to->message = str;
index cd11bcd5c23d16e3c1e49e72ab910999a9ec16f7..f885c662f042dc50f0ec6294550edd425d974e65 100644 (file)
@@ -476,7 +476,7 @@ virXenError(virErrorNumber error, const char *info, int value)
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
+    __virRaiseError(NULL, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, value, 0, errmsg, info, value);
 }
 
index 71056a9188a8ad8df1341ec9ad8f9b488e5e84a9..23bf12b2975ce719917d275fe26c4e095b935c6b 100644 (file)
@@ -153,7 +153,7 @@ virXendError(virConnectPtr conn, virErrorNumber error, const char *info)
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(conn, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR,
+    __virRaiseError(conn, NULL, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info);
 }
 
@@ -174,7 +174,7 @@ virXendErrorInt(virConnectPtr conn, virErrorNumber error, int val)
         return;
 
     errmsg = __virErrorMsg(error, NULL);
-    __virRaiseError(conn, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR,
+    __virRaiseError(conn, NULL, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR,
                     errmsg, NULL, NULL, val, 0, errmsg, val);
 }
 
index 7ad64b51a1dffd961fa4ac5c4c651b29eefa2738..6f8c5be61d2023c29e78ca4921c94efcccd9b66f 100644 (file)
@@ -116,7 +116,7 @@ xenXMError(virConnectPtr conn, virErrorNumber error, const char *info)
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(conn, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR,
+    __virRaiseError(conn, NULL, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info);
 }
 
index b89a420efc87327895f5f563165b88a0b9f3516c..0c7db5805f4ee4fc33e93f5793331fe715f76747 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -34,7 +34,7 @@ virXMLError(virErrorNumber error, const char *info, int value)
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(NULL, NULL, VIR_FROM_XML, error, VIR_ERR_ERROR,
+    __virRaiseError(NULL, NULL, NULL, VIR_FROM_XML, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, value, 0, errmsg, info, value);
 }
 
index 795dc3639491d962a7edd19f450604f303685913..d58f88714c92ad9e80a3b465417e4f9030534954 100644 (file)
@@ -39,7 +39,7 @@ static void xmlRpcError(virErrorNumber error, const char *info, int value)
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(NULL, NULL, VIR_FROM_RPC, error, VIR_ERR_ERROR,
+    __virRaiseError(NULL, NULL, NULL, VIR_FROM_RPC, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, value, 0, errmsg, info, value);
 }
 
index 6e63a2b8b2706efe4e07bd46507824675bcbe94a..9dca5b29ec4cfef64691161b64a3aaa1e2fe58e7 100644 (file)
@@ -106,7 +106,7 @@ virXenStoreError(virConnectPtr conn, virErrorNumber error, const char *info)
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(conn, NULL, VIR_FROM_XENSTORE, error, VIR_ERR_ERROR,
+    __virRaiseError(conn, NULL, NULL, VIR_FROM_XENSTORE, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info);
 }