[libvirt] [PATCH 1/6] qemu: guest agent: introduce new error code VIR_ERR_AGENT_UNSYNCED

Maxim Nestratov mnestratov at virtuozzo.com
Wed Aug 10 17:44:33 UTC 2016


From: Yuri Pudgorodskiy <yur at virtuozzo.com>

A separate error code will help recognize real failures from
necessity to try again

Signed-off-by: Maxim Nestratov <mnestratov at virtuozzo.com>
---
 include/libvirt/virterror.h | 2 ++
 src/qemu/qemu_agent.c       | 6 +++---
 src/util/virerror.c         | 6 ++++++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 2ec560e..efe83aa 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -315,6 +315,8 @@ typedef enum {
     VIR_ERR_AUTH_UNAVAILABLE = 94,	/* authentication unavailable */
     VIR_ERR_NO_SERVER = 95,             /* Server was not found */
     VIR_ERR_NO_CLIENT = 96,             /* Client was not found */
+    VIR_ERR_AGENT_UNSYNCED = 97,        /* guest agent replies with wrong id
+                                           to guest-sync command */
 } virErrorNumber;
 
 /**
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 0c1cf1c..20b724e 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -966,21 +966,21 @@ qemuAgentGuestSync(qemuAgentPtr mon)
         goto cleanup;
 
     if (!sync_msg.rxObject) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+        virReportError(VIR_ERR_AGENT_UNSYNCED, "%s",
                        _("Missing monitor reply object"));
         goto cleanup;
     }
 
     if (virJSONValueObjectGetNumberUlong(sync_msg.rxObject,
                                          "return", &id_ret) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+        virReportError(VIR_ERR_AGENT_UNSYNCED, "%s",
                        _("Malformed return value"));
         goto cleanup;
     }
 
     VIR_DEBUG("Guest returned ID: %llu", id_ret);
     if (id_ret != id) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
+        virReportError(VIR_ERR_AGENT_UNSYNCED,
                        _("Guest agent returned ID: %llu instead of %llu"),
                        id_ret, id);
         goto cleanup;
diff --git a/src/util/virerror.c b/src/util/virerror.c
index 1177570..2958308 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -1394,6 +1394,12 @@ virErrorMsg(virErrorNumber error, const char *info)
             else
                 errmsg = _("Client not found: %s");
             break;
+        case VIR_ERR_AGENT_UNSYNCED:
+            if (info == NULL)
+                errmsg = _("guest agent replied with wrong id to guest-sync command");
+            else
+                errmsg = _("guest agent replied with wrong id to guest-sync command: %s");
+            break;
     }
     return errmsg;
 }
-- 
1.8.3.1




More information about the libvir-list mailing list