Don't overwrite virRun error messages

virRun gives pretty useful error output, let's not overwrite it unless there
is a good reason. Some places were providing more information about what
the commands were _attempting_ to do, however that's usually less useful from
a debugging POV than what actually happened.
This commit is contained in:
Cole Robinson 2011-03-08 13:46:29 -05:00
parent ae1c5a936c
commit 9189301426
6 changed files with 4 additions and 73 deletions

View File

@ -94,7 +94,6 @@ int vethCreate(char** veth1, char** veth2)
const char *argv[] = { const char *argv[] = {
"ip", "link", "add", NULL, "type", "veth", "peer", "name", NULL, NULL "ip", "link", "add", NULL, "type", "veth", "peer", "name", NULL, NULL
}; };
int cmdResult = 0;
int vethDev = 0; int vethDev = 0;
bool veth1_alloc = false; bool veth1_alloc = false;
@ -122,13 +121,7 @@ int vethCreate(char** veth1, char** veth2)
argv[8] = *veth2; argv[8] = *veth2;
VIR_DEBUG("veth1: %s veth2: %s", *veth1, *veth2); VIR_DEBUG("veth1: %s veth2: %s", *veth1, *veth2);
rc = virRun(argv, &cmdResult); if (virRun(argv, NULL) < 0) {
if (rc != 0 ||
(WIFEXITED(cmdResult) && WEXITSTATUS(cmdResult) != 0)) {
vethError(VIR_ERR_INTERNAL_ERROR,
_("Failed to create veth device pair '%s', '%s': %d"),
*veth1, *veth2, WEXITSTATUS(cmdResult));
if (veth1_alloc) if (veth1_alloc)
VIR_FREE(*veth1); VIR_FREE(*veth1);
VIR_FREE(*veth2); VIR_FREE(*veth2);
@ -233,7 +226,6 @@ int moveInterfaceToNetNs(const char* iface, int pidInNs)
const char *argv[] = { const char *argv[] = {
"ip", "link", "set", iface, "netns", NULL, NULL "ip", "link", "set", iface, "netns", NULL, NULL
}; };
int cmdResult = 0;
if (virAsprintf(&pid, "%d", pidInNs) == -1) { if (virAsprintf(&pid, "%d", pidInNs) == -1) {
virReportOOMError(); virReportOOMError();
@ -241,14 +233,7 @@ int moveInterfaceToNetNs(const char* iface, int pidInNs)
} }
argv[5] = pid; argv[5] = pid;
rc = virRun(argv, &cmdResult); rc = virRun(argv, NULL);
if (rc != 0 ||
(WIFEXITED(cmdResult) && WEXITSTATUS(cmdResult) != 0)) {
vethError(VIR_ERR_INTERNAL_ERROR,
_("Failed to move '%s' into NS(pid=%d) (%d)"),
iface, pidInNs, WEXITSTATUS(cmdResult));
rc = -1;
}
VIR_FREE(pid); VIR_FREE(pid);
return rc; return rc;
@ -267,22 +252,11 @@ int moveInterfaceToNetNs(const char* iface, int pidInNs)
*/ */
int setMacAddr(const char* iface, const char* macaddr) int setMacAddr(const char* iface, const char* macaddr)
{ {
int rc;
const char *argv[] = { const char *argv[] = {
"ip", "link", "set", iface, "address", macaddr, NULL "ip", "link", "set", iface, "address", macaddr, NULL
}; };
int cmdResult = 0;
rc = virRun(argv, &cmdResult); return virRun(argv, NULL);
if (rc != 0 ||
(WIFEXITED(cmdResult) && WEXITSTATUS(cmdResult) != 0)) {
vethError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set '%s' to '%s' (%d)"),
macaddr, iface, WEXITSTATUS(cmdResult));
rc = -1;
}
return rc;
} }
/** /**
@ -298,20 +272,9 @@ int setMacAddr(const char* iface, const char* macaddr)
*/ */
int setInterfaceName(const char* iface, const char* new) int setInterfaceName(const char* iface, const char* new)
{ {
int rc;
const char *argv[] = { const char *argv[] = {
"ip", "link", "set", iface, "name", new, NULL "ip", "link", "set", iface, "name", new, NULL
}; };
int cmdResult = 0;
rc = virRun(argv, &cmdResult); return virRun(argv, NULL);
if (rc != 0 ||
(WIFEXITED(cmdResult) && WEXITSTATUS(cmdResult) != 0)) {
vethError(VIR_ERR_INTERNAL_ERROR,
_("Failed to set '%s' to '%s' (%d)"),
new, iface, WEXITSTATUS(cmdResult));
rc = -1;
}
return rc;
} }

View File

@ -216,8 +216,6 @@ static int openvzSetInitialConfig(virDomainDefPtr vmdef)
} }
if (virRun(prog, NULL) < 0) { if (virRun(prog, NULL) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not exec %s"), VZCTL);
goto cleanup; goto cleanup;
} }
} }
@ -495,8 +493,6 @@ static int openvzDomainSuspend(virDomainPtr dom) {
if (vm->state != VIR_DOMAIN_PAUSED) { if (vm->state != VIR_DOMAIN_PAUSED) {
openvzSetProgramSentinal(prog, vm->def->name); openvzSetProgramSentinal(prog, vm->def->name);
if (virRun(prog, NULL) < 0) { if (virRun(prog, NULL) < 0) {
openvzError(VIR_ERR_OPERATION_FAILED, "%s",
_("Suspend operation failed"));
goto cleanup; goto cleanup;
} }
vm->state = VIR_DOMAIN_PAUSED; vm->state = VIR_DOMAIN_PAUSED;
@ -535,8 +531,6 @@ static int openvzDomainResume(virDomainPtr dom) {
if (vm->state == VIR_DOMAIN_PAUSED) { if (vm->state == VIR_DOMAIN_PAUSED) {
openvzSetProgramSentinal(prog, vm->def->name); openvzSetProgramSentinal(prog, vm->def->name);
if (virRun(prog, NULL) < 0) { if (virRun(prog, NULL) < 0) {
openvzError(VIR_ERR_OPERATION_FAILED, "%s",
_("Resume operation failed"));
goto cleanup; goto cleanup;
} }
vm->state = VIR_DOMAIN_RUNNING; vm->state = VIR_DOMAIN_RUNNING;
@ -775,8 +769,6 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
if (prog[0] != NULL) { if (prog[0] != NULL) {
ADD_ARG_LIT("--save"); ADD_ARG_LIT("--save");
if (virRun(prog, NULL) < 0) { if (virRun(prog, NULL) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not exec %s"), VZCTL);
rc = -1; rc = -1;
goto exit; goto exit;
} }
@ -982,8 +974,6 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
openvzSetProgramSentinal(progstart, vm->def->name); openvzSetProgramSentinal(progstart, vm->def->name);
if (virRun(progstart, NULL) < 0) { if (virRun(progstart, NULL) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not exec %s"), VZCTL);
goto cleanup; goto cleanup;
} }
@ -1039,8 +1029,6 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
openvzSetProgramSentinal(prog, vm->def->name); openvzSetProgramSentinal(prog, vm->def->name);
if (virRun(prog, NULL) < 0) { if (virRun(prog, NULL) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not exec %s"), VZCTL);
goto cleanup; goto cleanup;
} }
@ -1086,8 +1074,6 @@ openvzDomainUndefine(virDomainPtr dom)
openvzSetProgramSentinal(prog, vm->def->name); openvzSetProgramSentinal(prog, vm->def->name);
if (virRun(prog, NULL) < 0) { if (virRun(prog, NULL) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not exec %s"), VZCTL);
goto cleanup; goto cleanup;
} }
@ -1124,8 +1110,6 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart)
openvzSetProgramSentinal(prog, vm->def->name); openvzSetProgramSentinal(prog, vm->def->name);
if (virRun(prog, NULL) < 0) { if (virRun(prog, NULL) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not exec %s"), VZCTL);
goto cleanup; goto cleanup;
} }
ret = 0; ret = 0;
@ -1216,8 +1200,6 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
openvzSetProgramSentinal(prog, vm->def->name); openvzSetProgramSentinal(prog, vm->def->name);
if (virRun(prog, NULL) < 0) { if (virRun(prog, NULL) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not exec %s"), VZCTL);
return -1; return -1;
} }
@ -1551,8 +1533,6 @@ openvzDomainSetMemoryInternal(virDomainObjPtr vm,
openvzSetProgramSentinal(prog, vm->def->name); openvzSetProgramSentinal(prog, vm->def->name);
if (virRun(prog, NULL) < 0) { if (virRun(prog, NULL) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
_("Could not exec %s"), VZCTL);
goto cleanup; goto cleanup;
} }

View File

@ -6056,10 +6056,6 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
qemuimgarg[4] = vm->def->disks[i]->src; qemuimgarg[4] = vm->def->disks[i]->src;
if (virRun(qemuimgarg, NULL) < 0) { if (virRun(qemuimgarg, NULL) < 0) {
virReportSystemError(errno,
_("Failed to run '%s' to create snapshot '%s' from disk '%s'"),
qemuimgarg[0], snap->def->name,
vm->def->disks[i]->src);
goto cleanup; goto cleanup;
} }
} }

View File

@ -534,9 +534,6 @@ static int virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
} }
if (!filecreated) { if (!filecreated) {
if (virRun(cmdargv, NULL) < 0) { if (virRun(cmdargv, NULL) < 0) {
virReportSystemError(errno,
_("Cannot run %s to create %s"),
cmdargv[0], vol->target.path);
return -1; return -1;
} }
if (stat(vol->target.path, &st) < 0) { if (stat(vol->target.path, &st) < 0) {

View File

@ -558,9 +558,6 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED,
pvargv[1] = pool->def->source.devices[i].path; pvargv[1] = pool->def->source.devices[i].path;
if (virRun(pvargv, NULL) < 0) { if (virRun(pvargv, NULL) < 0) {
error = -1; error = -1;
virReportSystemError(errno,
_("cannot remove PV device '%s'"),
pool->def->source.devices[i].path);
break; break;
} }
} }

View File

@ -189,7 +189,6 @@ vmwareStopVM(struct vmware_driver *driver, virDomainObjPtr vm)
vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath); vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath);
if (virRun(cmd, NULL) < 0) { if (virRun(cmd, NULL) < 0) {
vmwareError(VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VMRUN);
return -1; return -1;
} }
@ -222,7 +221,6 @@ vmwareStartVM(struct vmware_driver *driver, virDomainObjPtr vm)
vmwareSetSentinal(cmd, NULL); vmwareSetSentinal(cmd, NULL);
if (virRun(cmd, NULL) < 0) { if (virRun(cmd, NULL) < 0) {
vmwareError(VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VMRUN);
return -1; return -1;
} }