one: Remove virConnectPtr from oneError

This commit is contained in:
Matthias Bolte 2010-04-03 15:39:01 +02:00
parent a6c77af617
commit a4f9af057a
3 changed files with 39 additions and 40 deletions

View File

@ -135,8 +135,7 @@ no_memory:
* @return the OpenNebula ID for the new VM or -1 in case of error * @return the OpenNebula ID for the new VM or -1 in case of error
*/ */
int oneSubmitVM(virConnectPtr conn, int oneSubmitVM(one_driver_t* driver ATTRIBUTE_UNUSED,
one_driver_t* driver ATTRIBUTE_UNUSED,
virDomainObjPtr vm) virDomainObjPtr vm)
{ {
char* templ; char* templ;
@ -146,8 +145,8 @@ int oneSubmitVM(virConnectPtr conn,
return -1; return -1;
if ((oneid = c_oneAllocateTemplate(templ)) < 0) { if ((oneid = c_oneAllocateTemplate(templ)) < 0) {
oneError(conn, NULL, VIR_ERR_OPERATION_FAILED, oneError(VIR_ERR_OPERATION_FAILED, "%s",
"%s", _("Error submitting virtual machine to OpenNebula")); _("Error submitting virtual machine to OpenNebula"));
VIR_FREE(templ); VIR_FREE(templ);
return -1; return -1;
} }

View File

@ -43,12 +43,12 @@ typedef struct one_driver one_driver_t;
virCapsPtr oneCapsInit(void); virCapsPtr oneCapsInit(void);
int oneSubmitVM(virConnectPtr conn ,one_driver_t* driver, virDomainObjPtr vm); int oneSubmitVM(one_driver_t* driver, virDomainObjPtr vm);
char* xmlOneTemplate(virDomainDefPtr def); char* xmlOneTemplate(virDomainDefPtr def);
# define oneError(conn, dom, code, ...) \ # define oneError(code, ...) \
virReportErrorHelper(conn, VIR_FROM_ONE, code, __FILE__, \ virReportErrorHelper(NULL, VIR_FROM_ONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__) __FUNCTION__, __LINE__, __VA_ARGS__)
#endif /* ONE_CONF_H */ #endif /* ONE_CONF_H */

View File

@ -117,7 +117,7 @@ static virDomainPtr oneDomainLookupByID(virConnectPtr conn,
oneDriverUnlock(driver); oneDriverUnlock(driver);
if (!vm) { if (!vm) {
oneError(conn, NULL, VIR_ERR_NO_DOMAIN, NULL); oneError(VIR_ERR_NO_DOMAIN, NULL);
goto return_point; goto return_point;
} }
@ -145,7 +145,7 @@ static virDomainPtr oneDomainLookupByUUID(virConnectPtr conn,
vm = virDomainFindByUUID(&driver->domains, uuid); vm = virDomainFindByUUID(&driver->domains, uuid);
oneDriverUnlock(driver); oneDriverUnlock(driver);
if (!vm) { if (!vm) {
oneError(conn, NULL, VIR_ERR_NO_DOMAIN, NULL); oneError(VIR_ERR_NO_DOMAIN, NULL);
goto return_point; goto return_point;
} }
@ -174,7 +174,7 @@ static virDomainPtr oneDomainLookupByName(virConnectPtr conn,
oneDriverUnlock(driver); oneDriverUnlock(driver);
if (!vm) { if (!vm) {
oneError(conn, NULL, VIR_ERR_NO_DOMAIN, NULL); oneError(VIR_ERR_NO_DOMAIN, NULL);
goto return_point; goto return_point;
} }
@ -279,14 +279,14 @@ static int oneDomainUndefine(virDomainPtr dom)
oneDriverLock(driver); oneDriverLock(driver);
vm =virDomainFindByUUID(&driver->domains, dom->uuid); vm =virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) { if (!vm) {
oneError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, oneError(VIR_ERR_INVALID_DOMAIN, "%s",
"%s", _("no domain with matching uuid")); _("no domain with matching uuid"));
goto return_point; goto return_point;
} }
if (!vm->persistent) { if (!vm->persistent) {
oneError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR, oneError(VIR_ERR_INTERNAL_ERROR, "%s",
"%s", _("cannot undefine transient domain")); _("cannot undefine transient domain"));
goto return_point; goto return_point;
} }
virDomainRemoveInactive(&driver->domains, vm); virDomainRemoveInactive(&driver->domains, vm);
@ -310,14 +310,14 @@ static int oneDomainGetInfo(virDomainPtr dom,
oneDriverUnlock(driver); oneDriverUnlock(driver);
if (!vm) { if (!vm) {
oneError(dom->conn,dom, VIR_ERR_INVALID_DOMAIN, oneError(VIR_ERR_INVALID_DOMAIN, "%s",
"%s", _("no domain with matching uuid")); _("no domain with matching uuid"));
return -1; return -1;
} }
if(gettimeofday(&tv,NULL)<0) { if(gettimeofday(&tv,NULL)<0) {
oneError(dom->conn,dom, VIR_ERR_INTERNAL_ERROR, oneError(VIR_ERR_INTERNAL_ERROR, "%s",
"%s",_("getting time of day")); _("getting time of day"));
virDomainObjUnlock(vm); virDomainObjUnlock(vm);
return -1; return -1;
} }
@ -385,8 +385,8 @@ static char *oneGetOSType(virDomainPtr dom)
vm =virDomainFindByUUID(&driver->domains, dom->uuid); vm =virDomainFindByUUID(&driver->domains, dom->uuid);
oneDriverUnlock(driver); oneDriverUnlock(driver);
if (!vm) { if (!vm) {
oneError(dom->conn,dom, VIR_ERR_INVALID_DOMAIN, oneError(VIR_ERR_INVALID_DOMAIN, "%s",
"%s", _("no domain with matching uuid")); _("no domain with matching uuid"));
goto cleanup; goto cleanup;
} }
@ -412,11 +412,11 @@ static int oneDomainStart(virDomainPtr dom)
vm = virDomainFindByName(&driver->domains, dom->name); vm = virDomainFindByName(&driver->domains, dom->name);
if (!vm) { if (!vm) {
oneError(conn, dom, VIR_ERR_INVALID_DOMAIN, oneError(VIR_ERR_INVALID_DOMAIN,
_("no domain named %s"), dom->name); _("no domain named %s"), dom->name);
goto return_point; goto return_point;
} }
if((oneid = oneSubmitVM(dom->conn,driver,vm)) < 0) { if((oneid = oneSubmitVM(driver, vm)) < 0) {
goto return_point; goto return_point;
} }
vm->pid=oneid; vm->pid=oneid;
@ -449,7 +449,7 @@ oneDomainCreateAndStart(virConnectPtr conn,
vm = virDomainFindByName(&driver->domains, def->name); vm = virDomainFindByName(&driver->domains, def->name);
if (vm) { if (vm) {
oneError(conn,NULL, VIR_ERR_OPERATION_FAILED, oneError(VIR_ERR_OPERATION_FAILED,
_("Already an OpenNebula VM active with the name: '%s' id: %d "), _("Already an OpenNebula VM active with the name: '%s' id: %d "),
def->name,def->id); def->name,def->id);
goto return_point; goto return_point;
@ -460,7 +460,7 @@ oneDomainCreateAndStart(virConnectPtr conn,
virDomainDefFree(def); virDomainDefFree(def);
goto return_point; goto return_point;
} }
if ((oneid = oneSubmitVM(conn, driver, vm)) < 0) { if ((oneid = oneSubmitVM(driver, vm)) < 0) {
virDomainRemoveInactive(&driver->domains, vm); virDomainRemoveInactive(&driver->domains, vm);
vm=NULL; vm=NULL;
goto return_point; goto return_point;
@ -492,14 +492,14 @@ static int oneDomainShutdown(virDomainPtr dom)
oneDriverLock(driver); oneDriverLock(driver);
if (!(vm=virDomainFindByID(&driver->domains, dom->id))) { if (!(vm=virDomainFindByID(&driver->domains, dom->id))) {
oneError(dom->conn,dom, VIR_ERR_INVALID_DOMAIN, oneError(VIR_ERR_INVALID_DOMAIN,
_("no domain with id %d"), dom->id); _("no domain with id %d"), dom->id);
goto return_point; goto return_point;
} }
if (c_oneShutdown(vm->pid)) { if (c_oneShutdown(vm->pid)) {
oneError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, oneError(VIR_ERR_OPERATION_INVALID, "%s",
"%s", _("Wrong state to perform action")); _("Wrong state to perform action"));
goto return_point; goto return_point;
} }
vm->state=VIR_DOMAIN_SHUTDOWN; vm->state=VIR_DOMAIN_SHUTDOWN;
@ -527,15 +527,15 @@ static int oneDomainDestroy(virDomainPtr dom)
oneDriverLock(driver); oneDriverLock(driver);
vm= virDomainFindByID(&driver->domains, dom->id); vm= virDomainFindByID(&driver->domains, dom->id);
if (!vm) { if (!vm) {
oneError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, oneError(VIR_ERR_INVALID_DOMAIN,
_("no domain with id %d"), dom->id); _("no domain with id %d"), dom->id);
goto return_point; goto return_point;
} }
if(c_oneCancel(vm->pid)) { if(c_oneCancel(vm->pid)) {
/* VM not running, delete the instance at ONE DB */ /* VM not running, delete the instance at ONE DB */
if(c_oneFinalize(vm->pid)){ if(c_oneFinalize(vm->pid)){
oneError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, oneError(VIR_ERR_OPERATION_INVALID, "%s",
"%s", _("Wrong state to perform action")); _("Wrong state to perform action"));
goto return_point; goto return_point;
} }
} }
@ -569,14 +569,14 @@ static int oneDomainSuspend(virDomainPtr dom)
ret=0; ret=0;
goto return_point; goto return_point;
} }
oneError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, oneError(VIR_ERR_OPERATION_INVALID, "%s",
"%s", _("Wrong state to perform action")); _("Wrong state to perform action"));
goto return_point; goto return_point;
} }
oneError(dom->conn,dom, VIR_ERR_OPERATION_INVALID, oneError(VIR_ERR_OPERATION_INVALID, "%s",
"%s", _("domain is not running")); _("domain is not running"));
} else { } else {
oneError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, oneError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id); _("no domain with matching id %d"), dom->id);
} }
@ -602,14 +602,14 @@ static int oneDomainResume(virDomainPtr dom)
ret=0; ret=0;
goto return_point; goto return_point;
} }
oneError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, oneError(VIR_ERR_OPERATION_INVALID, "%s",
"%s", _("Wrong state to perform action")); _("Wrong state to perform action"));
goto return_point; goto return_point;
} }
oneError(dom->conn,dom, VIR_ERR_OPERATION_INVALID, oneError(VIR_ERR_OPERATION_INVALID, "%s",
"%s", _("domain is not paused")); _("domain is not paused"));
} else { } else {
oneError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN, oneError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id); _("no domain with matching id %d"), dom->id);
} }