Avoid the annoying issue where the public object freeing APIs overwrite
the error set by helper functions, since they don't invoke the callback.
The new helper remembers the error only if no previous error was set.
if (!dom)
return;
+ vshSaveLibvirtHelperError();
virDomainFree(dom); /* sc_prohibit_obj_free_apis_in_virsh */
}
if (!snap)
return;
+ vshSaveLibvirtHelperError();
virDomainSnapshotFree(snap); /* sc_prohibit_obj_free_apis_in_virsh */
}
last_error = virSaveLastError();
}
+
+/* Store libvirt error from helper API but don't overwrite existing errors */
+void
+vshSaveLibvirtHelperError(void)
+{
+ if (last_error)
+ return;
+
+ if (!virGetLastError())
+ return;
+
+ vshSaveLibvirtError();
+}
+
+
/*
* Reset libvirt error on graceful fallback paths
*/
void vshReportError(vshControl *ctl);
void vshResetLibvirtError(void);
void vshSaveLibvirtError(void);
+void vshSaveLibvirtHelperError(void);
/* file handling */
char *vshEditWriteToTempFile(vshControl *ctl, const char *doc);