mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Add API to change qemu agent response timeout
Some layered products such as oVirt have requested a way to avoid being blocked by guest agent commands when querying a loaded vm. For example, many guest agent commands are polled periodically to monitor changes, and rather than blocking the calling process, they'd prefer to simply time out when an agent query is taking too long. This patch adds a way for the user to specify a custom agent timeout that is applied to all agent commands. One special case to note here is the 'guest-sync' command. 'guest-sync' is issued internally prior to calling any other command. (For example, when libvirt wants to call 'guest-get-fsinfo', we first call 'guest-sync' and then call 'guest-get-fsinfo'). Previously, the 'guest-sync' command used a 5-second timeout (VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT), whereas the actual command that followed always blocked indefinitely (VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK). As part of this patch, if a custom timeout is specified that is shorter than 5 seconds, this new timeout is also used for 'guest-sync'. If there is no custom timeout or if the custom timeout is longer than 5 seconds, we will continue to use the 5-second timeout. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
committed by
Michal Privoznik
parent
954f36e078
commit
95f5ac9ae5
@@ -13971,6 +13971,52 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* "guest-agent-timeout" command
|
||||
*/
|
||||
static const vshCmdInfo info_guest_agent_timeout[] = {
|
||||
{.name = "help",
|
||||
.data = N_("Set the guest agent timeout")
|
||||
},
|
||||
{.name = "desc",
|
||||
.data = N_("Set the number of seconds to wait for a response from the guest agent.")
|
||||
},
|
||||
{.name = NULL}
|
||||
};
|
||||
|
||||
static const vshCmdOptDef opts_guest_agent_timeout[] = {
|
||||
VIRSH_COMMON_OPT_DOMAIN_FULL(0),
|
||||
{.name = "timeout",
|
||||
.type = VSH_OT_INT,
|
||||
.flags = VSH_OFLAG_REQ_OPT,
|
||||
.help = N_("timeout seconds.")
|
||||
},
|
||||
{.name = NULL}
|
||||
};
|
||||
|
||||
static bool
|
||||
cmdGuestAgentTimeout(vshControl *ctl, const vshCmd *cmd)
|
||||
{
|
||||
virDomainPtr dom = NULL;
|
||||
int timeout;
|
||||
const unsigned int flags = 0;
|
||||
bool ret = false;
|
||||
|
||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||
return false;
|
||||
|
||||
if (vshCommandOptInt(ctl, cmd, "timeout", &timeout) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainAgentSetResponseTimeout(dom, timeout, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = true;
|
||||
cleanup:
|
||||
virshDomainFree(dom);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* "guestinfo" command
|
||||
*/
|
||||
@@ -14492,6 +14538,12 @@ const vshCmdDef domManagementCmds[] = {
|
||||
.info = info_qemu_agent_command,
|
||||
.flags = 0
|
||||
},
|
||||
{.name = "guest-agent-timeout",
|
||||
.handler = cmdGuestAgentTimeout,
|
||||
.opts = opts_guest_agent_timeout,
|
||||
.info = info_guest_agent_timeout,
|
||||
.flags = 0
|
||||
},
|
||||
{.name = "reboot",
|
||||
.handler = cmdReboot,
|
||||
.opts = opts_reboot,
|
||||
|
||||
Reference in New Issue
Block a user