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(a)redhat.com>
---
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