[PATCH] qemu: monitor: Provide more information in generic block job error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The qemuMonitorJSONBlockJob handles a few errors internally. If qemu
returns a different error we would report a rather unhelpful message:

 $ virsh blockpull gluster-job vda --base /dev/null
 error: internal error: Unexpected error

As the actual message from qemu contains a bit more info, let's use it
to report something a little more useful:

 $ virsh blockpull gluster-job vda --base /dev/null
 error: internal error: Unexpected error: (GenericError) 'Base '/dev/null' not found'
---
 src/qemu/qemu_monitor_json.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 9a5b812..ee3ae15 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3678,8 +3678,12 @@ qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
             virReportError(VIR_ERR_OPERATION_INVALID,
                            _("Command '%s' is not found"), cmd_name);
         } else {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("Unexpected error"));
+            virJSONValuePtr error = virJSONValueObjectGet(reply, "error");
+
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("Unexpected error: (%s) '%s'"),
+                           NULLSTR(virJSONValueObjectGetString(error, "class")),
+                           NULLSTR(virJSONValueObjectGetString(error, "desc")));
         }
     }

-- 
1.9.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]