diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 73ebba9f3c..1f7aff7a94 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3512,8 +3512,10 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd, if (virTypedParameterAssign(&(params[nparams++]), param->field, param->type, - val) < 0) + val) < 0) { + vshSaveLibvirtError(); goto cleanup; + } continue; } @@ -3523,8 +3525,10 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd, if (virTypedParameterAssignFromStr(&(params[nparams++]), param->field, param->type, - set_val) < 0) + set_val) < 0) { + vshSaveLibvirtError(); goto cleanup; + } continue; } diff --git a/tools/virsh.c b/tools/virsh.c index dea3f82493..322f7785b9 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -240,6 +240,15 @@ virshErrorHandler(void *unused ATTRIBUTE_UNUSED, virErrorPtr error) virDefaultErrorFunc(error); } +/* Store a libvirt error that is from a helper API that doesn't raise errors + * so it doesn't get overwritten */ +void +vshSaveLibvirtError(void) +{ + virFreeError(last_error); + last_error = virSaveLastError(); +} + /* * Reset libvirt error on graceful fallback paths */ diff --git a/tools/virsh.h b/tools/virsh.h index ba44f42a72..6913ed1298 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -346,6 +346,7 @@ struct _vshCtrlData { extern virErrorPtr last_error; void vshReportError(vshControl *ctl); void vshResetLibvirtError(void); +void vshSaveLibvirtError(void); /* allocation wrappers */ void *_vshMalloc(vshControl *ctl, size_t sz, const char *filename, int line);