[PATCH 2/5] qemu: agent: ignore garbage while waiting for sync reply

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

 



After sync is sent we can receive garbare and this is not error.
Consider next regular case:

1. libvirtd sends sync
2. qga sends partial sync reply and die
3. libvirtd sends sync
4. qga sends sync reply
5. libvirtd receives garbage
  (half of first reply and second reply together)

We should handle this situation as it is recoverable.
Next sync can succeed. Let's report reply is NULL,
it will be converted to the VIR_ERR_AGENT_UNSYNCED
which signals client to retry.
---
 src/qemu/qemu_agent.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 88bcb4c..8e447d6 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -81,6 +81,8 @@ struct _qemuAgentMessage {
      * fatal error occurred on the monitor channel
      */
     bool finished;
+    /* true for sync command */
+    bool sync;
 };
 
 
@@ -311,8 +313,16 @@ qemuAgentIOProcessLine(qemuAgentPtr mon,
 
     VIR_DEBUG("Line [%s]", line);
 
-    if (!(obj = virJSONValueFromString(line)))
+    if (!(obj = virJSONValueFromString(line))) {
+        /* receiving garbage on sync is regular situation */
+        if (msg && msg->sync) {
+            VIR_DEBUG("Received garbage on sync");
+            msg->finished = 1;
+            return 0;
+        }
+
         goto cleanup;
+    }
 
     if (obj->type != VIR_JSON_TYPE_OBJECT) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -939,6 +949,7 @@ qemuAgentGuestSync(qemuAgentPtr mon)
         return -1;
 
     sync_msg.txLength = strlen(sync_msg.txBuffer);
+    sync_msg.sync = true;
 
     VIR_DEBUG("Sending guest-sync command with ID: %llu", id);
 
-- 
1.8.3.1

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