[PATCH v2] qemu_agent: Report error class at least

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

 



Currently, qemu GA is not providing 'desc' field for errors like
we are used to from qemu monitor. Therefore, we fall back to this
general 'unknown error' string. However, GA is reporting 'class' which
is not perfect, but much more helpful than generic error string.
Thus we should fall back to class firstly and if even no class
is presented, then we can fall back to that generic string.

Before this patch:
virsh # dompmsuspend --target mem f16
error: Domain f16 could not be suspended
error: internal error unable to execute QEMU command
'guest-suspend-ram': unknown QEMU command error

After this patch:
virsh # dompmsuspend --target mem f16
error: Domain f16 could not be suspended
error: internal error unable to execute QEMU command
'guest-suspend-ram': The command has not been found
---
 src/qemu/qemu_agent.c |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index b759b7f..bc4ceff 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1025,6 +1025,40 @@ cleanup:
     return ret;
 }
 
+static const char *
+qemuAgentStringifyErrorClass(const char *klass)
+{
+    if (STREQ_NULLABLE(klass, "BufferOverrun"))
+        return "Buffer overrun";
+    else if (STREQ_NULLABLE(klass, "CommandDisabled"))
+        return "The command has been disabled for this instance";
+    else if (STREQ_NULLABLE(klass, "CommandNotFound"))
+        return "The command has not been found";
+    else if (STREQ_NULLABLE(klass, "FdNotFound"))
+        return "File descriptor not found";
+    else if (STREQ_NULLABLE(klass, "InvalidParameter"))
+        return "Invalid parameter";
+    else if (STREQ_NULLABLE(klass, "InvalidParameterType"))
+        return "Invalid parameter type";
+    else if (STREQ_NULLABLE(klass, "InvalidParameterValue"))
+        return "Invalid parameter value";
+    else if (STREQ_NULLABLE(klass, "OpenFileFailed"))
+        return "Cannot open file";
+    else if (STREQ_NULLABLE(klass, "QgaCommandFailed"))
+        return "Guest agent command failed";
+    else if (STREQ_NULLABLE(klass, "QMPBadInputObjectMember"))
+        return "Bad QMP input object member";
+    else if (STREQ_NULLABLE(klass, "QMPExtraInputObjectMember"))
+        return "Unexpected extra object member";
+    else if (STREQ_NULLABLE(klass, "UndefinedError"))
+        return "An undefined error has occurred";
+    else if (STREQ_NULLABLE(klass, "Unsupported"))
+        return "this feature or command is not currently supported";
+    else if (klass)
+        return klass;
+    else
+        return "unknown QEMU command error";
+}
 
 /* Ignoring OOM in this method, since we're already reporting
  * a more important error
@@ -1043,9 +1077,8 @@ qemuAgentStringifyError(virJSONValuePtr error)
     if (klass)
         detail = virJSONValueObjectGetString(error, "desc");
 
-
     if (!detail)
-        detail = "unknown QEMU command error";
+        detail = qemuAgentStringifyErrorClass(klass);
 
     return detail;
 }
-- 
1.7.8.5

--
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]