[PATCH] qemu_agent: Bring back single sync

Michal Privoznik posted 1 patch 1 year, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1850be598d882c548648f416fef0847a0d148333.1667842042.git.mprivozn@redhat.com
src/qemu/qemu_agent.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
[PATCH] qemu_agent: Bring back single sync
Posted by Michal Privoznik 1 year, 5 months ago
Historically, we had no idea whether the qemu-ga running inside
the guest was running or not. Or whether it crashed in the middle
of reading of a command. That's why we issued guest-sync prior
any intended command, to make the agent flush any partially read
JSON and reset its state machine.

But with VSERPORT_CHANGE event we know when the guest agent
(dis-)connects and thus can issue the sync command just once for
each 'connection'. Whether the agent is synced is tracked in
agent->inSync member, which used to be set to true upon
successful sync. But after rework in v8.0.0-rc1~361 that line is
gone, leaving us with using the historic approach basically.

Fixes: cad84fd51eaac5e3bfdf441f9986e1f2639a0828
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_agent.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 0d77a2f90d..94782f2bc9 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -869,16 +869,20 @@ qemuAgentGuestSync(qemuAgent *agent)
         return -1;
 
     /* successfully sync'd */
-    if (rc == 1)
+    if (rc == 1) {
+        agent->inSync = true;
         return 0;
+    }
 
     /* send another sync */
     if ((rc = qemuAgentGuestSyncSend(agent, timeout, false)) < 0)
         return -1;
 
     /* successfully sync'd */
-    if (rc == 1)
+    if (rc == 1) {
+        agent->inSync = true;
         return 0;
+    }
 
     if (agent->running)
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-- 
2.37.4
Re: [PATCH] qemu_agent: Bring back single sync
Posted by Ján Tomko 1 year, 5 months ago
On a Monday in 2022, Michal Privoznik wrote:
>Historically, we had no idea whether the qemu-ga running inside
>the guest was running or not. Or whether it crashed in the middle
>of reading of a command. That's why we issued guest-sync prior
>any intended command, to make the agent flush any partially read
>JSON and reset its state machine.
>
>But with VSERPORT_CHANGE event we know when the guest agent
>(dis-)connects and thus can issue the sync command just once for
>each 'connection'. Whether the agent is synced is tracked in
>agent->inSync member, which used to be set to true upon
>successful sync. But after rework in v8.0.0-rc1~361 that line is
>gone, leaving us with using the historic approach basically.
>
>Fixes: cad84fd51eaac5e3bfdf441f9986e1f2639a0828
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> src/qemu/qemu_agent.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano