]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fri Jul 6 15:54:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
authorRichard W.M. Jones <rjones@redhat.com>
Fri, 6 Jul 2007 14:56:15 +0000 (14:56 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Fri, 6 Jul 2007 14:56:15 +0000 (14:56 +0000)
* include/libvirt/virterror.h, src/virterror.c, src/libvirt.c:
  Add VIR_ERR_NO_DOMAIN and VIR_ERR_NO_NETWORK errors, which
  indicate that there is no domain/network from vir*Lookup* functions.
* src/qemu_driver.c: Use VIR_ERR_NO_DOMAIN in lookup functions.
* src/test.c: Use VIR_ERR_NO_DOMAIN in lookup functions.

ChangeLog
include/libvirt/virterror.h
src/libvirt.c
src/qemu_driver.c
src/test.c
src/virterror.c

index 2f2581c9a2ea837d4b421e1fcbd9dc399608d000..d83b5d45a31bf03cf14c11beb080476779e02fb7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Jul  6 15:54:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
+
+       * include/libvirt/virterror.h, src/virterror.c, src/libvirt.c:
+         Add VIR_ERR_NO_DOMAIN and VIR_ERR_NO_NETWORK errors, which
+         indicate that there is no domain/network from vir*Lookup* functions.
+       * src/qemu_driver.c: Use VIR_ERR_NO_DOMAIN in lookup functions.
+       * src/test.c: Use VIR_ERR_NO_DOMAIN in lookup functions.
+
 Thu Jul  5 18:02:28 CEST 2007 Daniel Veillard <veillard@redhat.com>
 
        * src/xend_internal.c: fix typo in function comment
index 26331268f18a16216c020c6f98960e373b4fa6fa..817a4ec2016be4c11a60c13eb924cc0187d691c1 100644 (file)
@@ -125,6 +125,8 @@ typedef enum {
     VIR_ERR_RPC, /* some sort of RPC error */
     VIR_ERR_GNUTLS_ERROR, /* error from a GNUTLS call */
     VIR_WAR_NO_NETWORK, /* failed to start network */
+    VIR_ERR_NO_DOMAIN, /* domain not found or unexpectedly disappeared */
+    VIR_ERR_NO_NETWORK, /* network not found */
 } virErrorNumber;
 
 /**
index 0ffbf0ad958f9dda0c11146dc7ae898a7f635381..163ed82026db8882796de3b337e3f9153c1727aa 100644 (file)
@@ -752,7 +752,8 @@ virDomainCreateLinux(virConnectPtr conn, const char *xmlDesc,
  *
  * Try to find a domain based on the hypervisor ID number
  *
- * Returns a new domain object or NULL in case of failure
+ * Returns a new domain object or NULL in case of failure.  If the
+ * domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
  */
 virDomainPtr
 virDomainLookupByID(virConnectPtr conn, int id)
@@ -780,7 +781,8 @@ virDomainLookupByID(virConnectPtr conn, int id)
  *
  * Try to lookup a domain on the given hypervisor based on its UUID.
  *
- * Returns a new domain object or NULL in case of failure
+ * Returns a new domain object or NULL in case of failure.  If the
+ * domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
  */
 virDomainPtr
 virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
@@ -808,7 +810,8 @@ virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
  *
  * Try to lookup a domain on the given hypervisor based on its UUID.
  *
- * Returns a new domain object or NULL in case of failure
+ * Returns a new domain object or NULL in case of failure.  If the
+ * domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
  */
 virDomainPtr
 virDomainLookupByUUIDString(virConnectPtr conn, const char *uuidstr)
@@ -857,7 +860,8 @@ virDomainLookupByUUIDString(virConnectPtr conn, const char *uuidstr)
  *
  * Try to lookup a domain on the given hypervisor based on its name.
  *
- * Returns a new domain object or NULL in case of failure
+ * Returns a new domain object or NULL in case of failure.  If the
+ * domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
  */
 virDomainPtr
 virDomainLookupByName(virConnectPtr conn, const char *name)
index e93cd3a9a238bb1ea0cd0946627789c81651cede..6b0bcd23f706628f446135245f81a508ef87cb94 100644 (file)
@@ -1749,7 +1749,7 @@ static virDomainPtr qemudDomainLookupByID(virConnectPtr conn,
     virDomainPtr dom;
 
     if (!vm) {
-        qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "no domain with matching id");
+        qemudReportError(conn, NULL, NULL, VIR_ERR_NO_DOMAIN, NULL);
         return NULL;
     }
 
@@ -1769,7 +1769,7 @@ static virDomainPtr qemudDomainLookupByUUID(virConnectPtr conn,
     virDomainPtr dom;
 
     if (!vm) {
-        qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "no domain with matching uuid");
+        qemudReportError(conn, NULL, NULL, VIR_ERR_NO_DOMAIN, NULL);
         return NULL;
     }
 
@@ -1789,7 +1789,7 @@ static virDomainPtr qemudDomainLookupByName(virConnectPtr conn,
     virDomainPtr dom;
 
     if (!vm) {
-        qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "no domain with matching name");
+        qemudReportError(conn, NULL, NULL, VIR_ERR_NO_DOMAIN, NULL);
         return NULL;
     }
 
index 6e5723b7b3fb8dd18493b12a3972eb20a3ef7d05..be6d2f1b81a1a1a9f3a44a43f806599a43df2061 100644 (file)
@@ -983,6 +983,7 @@ virDomainPtr testLookupDomainByID(virConnectPtr conn,
     }
 
     if (idx < 0) {
+        testError (conn, NULL, VIR_ERR_NO_DOMAIN, NULL);
         return(NULL);
     }
 
@@ -1000,8 +1001,9 @@ virDomainPtr testLookupDomainByUUID(virConnectPtr conn,
 {
     testPrivatePtr priv = (testPrivatePtr) conn->privateData;
     testCon *con = &node->connections[priv->handle];
-    virDomainPtr dom = NULL;
+    virDomainPtr dom;
     int i, idx = -1;
+
     for (i = 0 ; i < MAX_DOMAINS ; i++) {
         if (con->domains[i].active &&
             memcmp(uuid, con->domains[i].uuid, VIR_UUID_BUFLEN) == 0) {
@@ -1009,15 +1011,20 @@ virDomainPtr testLookupDomainByUUID(virConnectPtr conn,
             break;
         }
     }
-    if (idx >= 0) {
-        dom = virGetDomain(conn, con->domains[idx].name, con->domains[idx].uuid);
-        if (dom == NULL) {
-            testError(conn, NULL, VIR_ERR_NO_MEMORY, _("allocating domain"));
-            return(NULL);
-        }
-        dom->id = con->domains[idx].id;
+
+    if (idx < 0) {
+        testError (conn, NULL, VIR_ERR_NO_DOMAIN, NULL);
+        return NULL;
     }
-    return (dom);
+
+    dom = virGetDomain(conn, con->domains[idx].name, con->domains[idx].uuid);
+    if (dom == NULL) {
+        testError(conn, NULL, VIR_ERR_NO_MEMORY, _("allocating domain"));
+        return NULL;
+    }
+    dom->id = con->domains[idx].id;
+
+    return dom;
 }
 
 virDomainPtr testLookupDomainByName(virConnectPtr conn,
@@ -1025,8 +1032,9 @@ virDomainPtr testLookupDomainByName(virConnectPtr conn,
 {
     testPrivatePtr priv = (testPrivatePtr) conn->privateData;
     testCon *con = &node->connections[priv->handle];
-    virDomainPtr dom = NULL;
+    virDomainPtr dom;
     int i, idx = -1;
+
     for (i = 0 ; i < MAX_DOMAINS ; i++) {
         if (con->domains[i].active &&
             strcmp(name, con->domains[i].name) == 0) {
@@ -1034,15 +1042,20 @@ virDomainPtr testLookupDomainByName(virConnectPtr conn,
             break;
         }
     }
-    if (idx >= 0) {
-        dom = virGetDomain(conn, con->domains[idx].name, con->domains[idx].uuid);
-        if (dom == NULL) {
-            testError(conn, NULL, VIR_ERR_NO_MEMORY, _("allocating domain"));
-            return(NULL);
-        }
-        dom->id = con->domains[idx].id;
+
+    if (idx < 0) {
+        testError (conn, NULL, VIR_ERR_NO_DOMAIN, NULL);
+        return NULL;
     }
-    return (dom);
+
+    dom = virGetDomain(conn, con->domains[idx].name, con->domains[idx].uuid);
+    if (dom == NULL) {
+        testError(conn, NULL, VIR_ERR_NO_MEMORY, _("allocating domain"));
+        return NULL;
+    }
+    dom->id = con->domains[idx].id;
+
+    return dom;
 }
 
 int testListDomains (virConnectPtr conn,
index d22b2d7844ce8783aecb98960083c764a934436a..8a0ef792a97b852d1371e216779006880589471f 100644 (file)
@@ -634,6 +634,18 @@ __virErrorMsg(virErrorNumber error, const char *info)
            else
                errmsg = _("Failed to find the network: %s");
            break;
+       case VIR_ERR_NO_DOMAIN:
+           if (info == NULL)
+               errmsg = _("Domain not found");
+           else
+               errmsg = _("Domain not found: %s");
+           break;
+       case VIR_ERR_NO_NETWORK:
+           if (info == NULL)
+               errmsg = _("Network not found");
+           else
+               errmsg = _("Network not found: %s");
+           break;
     }
     return (errmsg);
 }