mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
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.
This commit is contained in:
parent
44b20d1056
commit
b26376750e
@ -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
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
49
src/test.c
49
src/test.c
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user