mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
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:
parent
ae1c5a936c
commit
9189301426
@ -94,7 +94,6 @@ int vethCreate(char** veth1, char** veth2)
|
||||
const char *argv[] = {
|
||||
"ip", "link", "add", NULL, "type", "veth", "peer", "name", NULL, NULL
|
||||
};
|
||||
int cmdResult = 0;
|
||||
int vethDev = 0;
|
||||
bool veth1_alloc = false;
|
||||
|
||||
@ -122,13 +121,7 @@ int vethCreate(char** veth1, char** veth2)
|
||||
argv[8] = *veth2;
|
||||
|
||||
VIR_DEBUG("veth1: %s veth2: %s", *veth1, *veth2);
|
||||
rc = virRun(argv, &cmdResult);
|
||||
|
||||
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 (virRun(argv, NULL) < 0) {
|
||||
if (veth1_alloc)
|
||||
VIR_FREE(*veth1);
|
||||
VIR_FREE(*veth2);
|
||||
@ -233,7 +226,6 @@ int moveInterfaceToNetNs(const char* iface, int pidInNs)
|
||||
const char *argv[] = {
|
||||
"ip", "link", "set", iface, "netns", NULL, NULL
|
||||
};
|
||||
int cmdResult = 0;
|
||||
|
||||
if (virAsprintf(&pid, "%d", pidInNs) == -1) {
|
||||
virReportOOMError();
|
||||
@ -241,14 +233,7 @@ int moveInterfaceToNetNs(const char* iface, int pidInNs)
|
||||
}
|
||||
|
||||
argv[5] = pid;
|
||||
rc = virRun(argv, &cmdResult);
|
||||
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;
|
||||
}
|
||||
rc = virRun(argv, NULL);
|
||||
|
||||
VIR_FREE(pid);
|
||||
return rc;
|
||||
@ -267,22 +252,11 @@ int moveInterfaceToNetNs(const char* iface, int pidInNs)
|
||||
*/
|
||||
int setMacAddr(const char* iface, const char* macaddr)
|
||||
{
|
||||
int rc;
|
||||
const char *argv[] = {
|
||||
"ip", "link", "set", iface, "address", macaddr, NULL
|
||||
};
|
||||
int cmdResult = 0;
|
||||
|
||||
rc = virRun(argv, &cmdResult);
|
||||
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;
|
||||
return virRun(argv, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,20 +272,9 @@ int setMacAddr(const char* iface, const char* macaddr)
|
||||
*/
|
||||
int setInterfaceName(const char* iface, const char* new)
|
||||
{
|
||||
int rc;
|
||||
const char *argv[] = {
|
||||
"ip", "link", "set", iface, "name", new, NULL
|
||||
};
|
||||
int cmdResult = 0;
|
||||
|
||||
rc = virRun(argv, &cmdResult);
|
||||
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;
|
||||
return virRun(argv, NULL);
|
||||
}
|
||||
|
@ -216,8 +216,6 @@ static int openvzSetInitialConfig(virDomainDefPtr vmdef)
|
||||
}
|
||||
|
||||
if (virRun(prog, NULL) < 0) {
|
||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not exec %s"), VZCTL);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
@ -495,8 +493,6 @@ static int openvzDomainSuspend(virDomainPtr dom) {
|
||||
if (vm->state != VIR_DOMAIN_PAUSED) {
|
||||
openvzSetProgramSentinal(prog, vm->def->name);
|
||||
if (virRun(prog, NULL) < 0) {
|
||||
openvzError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||
_("Suspend operation failed"));
|
||||
goto cleanup;
|
||||
}
|
||||
vm->state = VIR_DOMAIN_PAUSED;
|
||||
@ -535,8 +531,6 @@ static int openvzDomainResume(virDomainPtr dom) {
|
||||
if (vm->state == VIR_DOMAIN_PAUSED) {
|
||||
openvzSetProgramSentinal(prog, vm->def->name);
|
||||
if (virRun(prog, NULL) < 0) {
|
||||
openvzError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||
_("Resume operation failed"));
|
||||
goto cleanup;
|
||||
}
|
||||
vm->state = VIR_DOMAIN_RUNNING;
|
||||
@ -775,8 +769,6 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
||||
if (prog[0] != NULL) {
|
||||
ADD_ARG_LIT("--save");
|
||||
if (virRun(prog, NULL) < 0) {
|
||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not exec %s"), VZCTL);
|
||||
rc = -1;
|
||||
goto exit;
|
||||
}
|
||||
@ -982,8 +974,6 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
openvzSetProgramSentinal(progstart, vm->def->name);
|
||||
|
||||
if (virRun(progstart, NULL) < 0) {
|
||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not exec %s"), VZCTL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -1039,8 +1029,6 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
|
||||
|
||||
openvzSetProgramSentinal(prog, vm->def->name);
|
||||
if (virRun(prog, NULL) < 0) {
|
||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not exec %s"), VZCTL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -1086,8 +1074,6 @@ openvzDomainUndefine(virDomainPtr dom)
|
||||
|
||||
openvzSetProgramSentinal(prog, vm->def->name);
|
||||
if (virRun(prog, NULL) < 0) {
|
||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not exec %s"), VZCTL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -1124,8 +1110,6 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart)
|
||||
|
||||
openvzSetProgramSentinal(prog, vm->def->name);
|
||||
if (virRun(prog, NULL) < 0) {
|
||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not exec %s"), VZCTL);
|
||||
goto cleanup;
|
||||
}
|
||||
ret = 0;
|
||||
@ -1216,8 +1200,6 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
|
||||
|
||||
openvzSetProgramSentinal(prog, vm->def->name);
|
||||
if (virRun(prog, NULL) < 0) {
|
||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not exec %s"), VZCTL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1551,8 +1533,6 @@ openvzDomainSetMemoryInternal(virDomainObjPtr vm,
|
||||
|
||||
openvzSetProgramSentinal(prog, vm->def->name);
|
||||
if (virRun(prog, NULL) < 0) {
|
||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not exec %s"), VZCTL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -6056,10 +6056,6 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
qemuimgarg[4] = vm->def->disks[i]->src;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -534,9 +534,6 @@ static int virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
|
||||
}
|
||||
if (!filecreated) {
|
||||
if (virRun(cmdargv, NULL) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("Cannot run %s to create %s"),
|
||||
cmdargv[0], vol->target.path);
|
||||
return -1;
|
||||
}
|
||||
if (stat(vol->target.path, &st) < 0) {
|
||||
|
@ -558,9 +558,6 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
pvargv[1] = pool->def->source.devices[i].path;
|
||||
if (virRun(pvargv, NULL) < 0) {
|
||||
error = -1;
|
||||
virReportSystemError(errno,
|
||||
_("cannot remove PV device '%s'"),
|
||||
pool->def->source.devices[i].path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,6 @@ vmwareStopVM(struct vmware_driver *driver, virDomainObjPtr vm)
|
||||
vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath);
|
||||
|
||||
if (virRun(cmd, NULL) < 0) {
|
||||
vmwareError(VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VMRUN);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -222,7 +221,6 @@ vmwareStartVM(struct vmware_driver *driver, virDomainObjPtr vm)
|
||||
vmwareSetSentinal(cmd, NULL);
|
||||
|
||||
if (virRun(cmd, NULL) < 0) {
|
||||
vmwareError(VIR_ERR_INTERNAL_ERROR, _("Could not exec %s"), VMRUN);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user