/**
* qemuAgentGuestSync:
* @agent: agent object
+ * @seconds: qemu agent command timeout value
*
* Send guest-sync with unique ID
* and wait for reply. If we get one, check if
* -1 otherwise
*/
static int
-qemuAgentGuestSync(qemuAgent *agent)
+qemuAgentGuestSync(qemuAgent *agent,
+ int seconds)
{
- int timeout = VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT;
+ int timeout = QEMU_AGENT_WAIT_TIME;
int rc;
if (agent->inSync)
/* if user specified a custom agent timeout that is lower than the
* default timeout, use the shorter timeout instead */
- if ((agent->timeout >= 0) && (agent->timeout < QEMU_AGENT_WAIT_TIME))
+ if ((agent->timeout >= 0) && (agent->timeout < timeout))
timeout = agent->timeout;
+ /* If user specified a timeout parameter smaller than both default
+ * value and agent->timeout in qga APIs(such as qemu-agent-command),
+ * use the parameter timeout value */
+ if ((seconds >= 0) && (seconds < timeout))
+ timeout = seconds;
+
if ((rc = qemuAgentGuestSyncSend(agent, timeout, true)) < 0)
return -1;
goto cleanup;
}
- if (qemuAgentGuestSync(agent) < 0)
+ if (qemuAgentGuestSync(agent, seconds) < 0)
goto cleanup;
if (!(cmdstr = virJSONValueToString(cmd, false)))