+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
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;
/**
*
* 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)
*
* 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)
*
* 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)
*
* 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)
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;
}
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;
}
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;
}
}
if (idx < 0) {
+ testError (conn, NULL, VIR_ERR_NO_DOMAIN, NULL);
return(NULL);
}
{
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) {
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,
{
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) {
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,
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);
}