qemu_agent: Drop @singleSync from _qemuAgent

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@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2022-11-07 13:16:04 +01:00
parent 3cf0a764cd
commit c18e2fd746
4 changed files with 5 additions and 11 deletions

View File

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

View File

@ -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);

View File

@ -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);

View File

@ -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);