mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: Show errors reported by nonAPI functions
Only API calls trigger the error callback, which is required for proper virsh error reporting. Since we use non API functions from util/, make sure we properly report these errors. Fixes lack of error message from 'virsh create idontexit.xml'
This commit is contained in:
@@ -352,8 +352,16 @@ virshErrorHandler(void *unused ATTRIBUTE_UNUSED, virErrorPtr error)
|
|||||||
static void
|
static void
|
||||||
virshReportError(vshControl *ctl)
|
virshReportError(vshControl *ctl)
|
||||||
{
|
{
|
||||||
if (last_error == NULL)
|
if (last_error == NULL) {
|
||||||
return;
|
/* Calling directly into libvirt util functions won't trigger the
|
||||||
|
* error callback (which sets last_error), so check it ourselves.
|
||||||
|
*
|
||||||
|
* If the returned error has CODE_OK, this most likely means that
|
||||||
|
* no error was ever raised, so just ignore */
|
||||||
|
last_error = virSaveLastError();
|
||||||
|
if (!last_error || last_error->code == VIR_ERR_OK)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (last_error->code == VIR_ERR_OK) {
|
if (last_error->code == VIR_ERR_OK) {
|
||||||
vshError(ctl, "%s", _("unknown error"));
|
vshError(ctl, "%s", _("unknown error"));
|
||||||
|
|||||||
Reference in New Issue
Block a user