[PATCH 08/48] qemu_agent: Drop @singleSync from _qemuAgent

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

 



Historically, before sending any guest agent command we would
send 'guest-sync' command to make guest agent reset its internal
state and flush any partially read command (json). This was
because there was no event emitted when the agent
(dis-)connected.

But now that we have the event we can execute the sync command
just once - the first time after we've connected. Should agent
disconnect in the middle of reading a command, and then connect
back again we would get the event and disconnect and connect back
again, resulting in the sync command being executed again.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_agent.c        | 7 ++-----
 src/qemu/qemu_agent.h        | 3 +--
 src/qemu/qemu_process.c      | 3 +--
 tests/qemumonitortestutils.c | 3 +--
 4 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 94782f2bc9..d420b2b901 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -90,7 +90,6 @@ struct _qemuAgent {
     GSource *watch;
 
     bool running;
-    bool singleSync;
     bool inSync;
 
     virDomainObj *vm;
@@ -587,8 +586,7 @@ qemuAgent *
 qemuAgentOpen(virDomainObj *vm,
               const virDomainChrSourceDef *config,
               GMainContext *context,
-              qemuAgentCallbacks *cb,
-              bool singleSync)
+              qemuAgentCallbacks *cb)
 {
     qemuAgent *agent;
     g_autoptr(GError) gerr = NULL;
@@ -615,7 +613,6 @@ qemuAgentOpen(virDomainObj *vm,
     }
     agent->vm = virObjectRef(vm);
     agent->cb = cb;
-    agent->singleSync = singleSync;
 
     if (config->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -857,7 +854,7 @@ qemuAgentGuestSync(qemuAgent *agent)
     int timeout = VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT;
     int rc;
 
-    if (agent->singleSync && agent->inSync)
+    if (agent->inSync)
         return 0;
 
     /* if user specified a custom agent timeout that is lower than the
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index c07d8507ba..f98586e8f8 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -38,8 +38,7 @@ struct _qemuAgentCallbacks {
 qemuAgent *qemuAgentOpen(virDomainObj *vm,
                            const virDomainChrSourceDef *config,
                            GMainContext *context,
-                           qemuAgentCallbacks *cb,
-                           bool singleSync);
+                           qemuAgentCallbacks *cb);
 
 void qemuAgentClose(qemuAgent *mon);
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 7d112f5bae..48864a92a5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -228,8 +228,7 @@ qemuConnectAgent(virQEMUDriver *driver, virDomainObj *vm)
     agent = qemuAgentOpen(vm,
                           config->source,
                           virEventThreadGetContext(priv->eventThread),
-                          &agentCallbacks,
-                          true);
+                          &agentCallbacks);
 
     if (!virDomainObjIsActive(vm)) {
         qemuAgentClose(agent);
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 310c19dfde..46791931b0 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -1417,8 +1417,7 @@ qemuMonitorTestNewAgent(virDomainXMLOption *xmlopt)
     if (!(test->agent = qemuAgentOpen(test->vm,
                                       &src,
                                       virEventThreadGetContext(test->eventThread),
-                                      &qemuMonitorTestAgentCallbacks,
-                                      true)))
+                                      &qemuMonitorTestAgentCallbacks)))
         goto error;
 
     virObjectLock(test->agent);
-- 
2.37.4




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

  Powered by Linux