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; GSource *watch;
bool running; bool running;
bool singleSync;
bool inSync; bool inSync;
virDomainObj *vm; virDomainObj *vm;
@ -587,8 +586,7 @@ qemuAgent *
qemuAgentOpen(virDomainObj *vm, qemuAgentOpen(virDomainObj *vm,
const virDomainChrSourceDef *config, const virDomainChrSourceDef *config,
GMainContext *context, GMainContext *context,
qemuAgentCallbacks *cb, qemuAgentCallbacks *cb)
bool singleSync)
{ {
qemuAgent *agent; qemuAgent *agent;
g_autoptr(GError) gerr = NULL; g_autoptr(GError) gerr = NULL;
@ -615,7 +613,6 @@ qemuAgentOpen(virDomainObj *vm,
} }
agent->vm = virObjectRef(vm); agent->vm = virObjectRef(vm);
agent->cb = cb; agent->cb = cb;
agent->singleSync = singleSync;
if (config->type != VIR_DOMAIN_CHR_TYPE_UNIX) { if (config->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
@ -857,7 +854,7 @@ qemuAgentGuestSync(qemuAgent *agent)
int timeout = VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT; int timeout = VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT;
int rc; int rc;
if (agent->singleSync && agent->inSync) if (agent->inSync)
return 0; return 0;
/* if user specified a custom agent timeout that is lower than the /* if user specified a custom agent timeout that is lower than the

View File

@ -38,8 +38,7 @@ struct _qemuAgentCallbacks {
qemuAgent *qemuAgentOpen(virDomainObj *vm, qemuAgent *qemuAgentOpen(virDomainObj *vm,
const virDomainChrSourceDef *config, const virDomainChrSourceDef *config,
GMainContext *context, GMainContext *context,
qemuAgentCallbacks *cb, qemuAgentCallbacks *cb);
bool singleSync);
void qemuAgentClose(qemuAgent *mon); void qemuAgentClose(qemuAgent *mon);

View File

@ -228,8 +228,7 @@ qemuConnectAgent(virQEMUDriver *driver, virDomainObj *vm)
agent = qemuAgentOpen(vm, agent = qemuAgentOpen(vm,
config->source, config->source,
virEventThreadGetContext(priv->eventThread), virEventThreadGetContext(priv->eventThread),
&agentCallbacks, &agentCallbacks);
true);
if (!virDomainObjIsActive(vm)) { if (!virDomainObjIsActive(vm)) {
qemuAgentClose(agent); qemuAgentClose(agent);

View File

@ -1417,8 +1417,7 @@ qemuMonitorTestNewAgent(virDomainXMLOption *xmlopt)
if (!(test->agent = qemuAgentOpen(test->vm, if (!(test->agent = qemuAgentOpen(test->vm,
&src, &src,
virEventThreadGetContext(test->eventThread), virEventThreadGetContext(test->eventThread),
&qemuMonitorTestAgentCallbacks, &qemuMonitorTestAgentCallbacks)))
true)))
goto error; goto error;
virObjectLock(test->agent); virObjectLock(test->agent);