Libvirt's helper API's when called directly don't raise the error so
that virsh remembers it. Subsequent calls to libvirt API's might reset
the error.
In case of schedinfo virDomainFree() in the cleanup section resets the
error when virTypedParameterAssignFromStr() fails.
This patch adds function vshSaveLibvirtError() that can be called after
calling libvirt helper APIs to ensure the error is remembered.
if (virTypedParameterAssign(&(params[nparams++]),
param->field,
param->type,
- val) < 0)
+ val) < 0) {
+ vshSaveLibvirtError();
goto cleanup;
+ }
continue;
}
if (virTypedParameterAssignFromStr(&(params[nparams++]),
param->field,
param->type,
- set_val) < 0)
+ set_val) < 0) {
+ vshSaveLibvirtError();
goto cleanup;
+ }
continue;
}
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
*/
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);