From nobody Fri Mar 29 13:47:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1573074816; cv=none; d=zoho.com; s=zohoarc; b=KBOcl7zZ6GXBsayHWlM5uALccGOvZKtqvs708RT1SPEGWOIXgddaW+ZzboTB1XDLfxYT4gVfHN7Nd7WPKxGSaiGSjp04XgJ7sCLtetR1ujBG39IsmWhAop2DtH4Spo1hWnmoR1n6A8o+mmJ5wWN2Q6o0GC2VoK2V/HTkQkCLNJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573074816; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=dLt9vER3ca+5y/W0QNJen4CXtzadPRih2VfqYN5BZiM=; b=DklL5Hsk3tOP4PP/pLZs/W6Ft+saL5wHTqfkBBnumMpKPTmmRJQoV8BsLgh/cJold8lG4wQqPu6uMtw+FQo1tiuYlGywU5KgWdeHt+q7N5wOoN5Cf3UwSRaaJ9I2Jyq/w2fLhb5HRVXzeQ0DE/gNzRRw+oBNldyb8vAVpfr/eOk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 157307481636439.63264180629699; Wed, 6 Nov 2019 13:13:36 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-380-yxF0uhGTNnattyTTBucmcw-1; Wed, 06 Nov 2019 16:13:32 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D4CE38017DD; Wed, 6 Nov 2019 21:13:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A5FF6608B3; Wed, 6 Nov 2019 21:13:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 27E244BB65; Wed, 6 Nov 2019 21:13:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xA6LDPaG032137 for ; Wed, 6 Nov 2019 16:13:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8114B1A8D8; Wed, 6 Nov 2019 21:13:25 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-118-70.phx2.redhat.com [10.3.118.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E282B1A7E2; Wed, 6 Nov 2019 21:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573074815; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dLt9vER3ca+5y/W0QNJen4CXtzadPRih2VfqYN5BZiM=; b=Yxkn7kItryzlUQXrfcS50eRVynDCmdO4siJcthVKIwxnRAiCRxUt14/qqaipAMwITm4oph yxQPtx2fDGHROtkKn/ymFf3t7iFrKow3n6xA7hZ1sJSbQ/Xp2gjIbYZroWy2rSFieAmnr2 DdfJFAxo3srT3E0rkpWlOL2BYenWaII= From: Jonathon Jongsma To: libvir-list@redhat.com Date: Wed, 6 Nov 2019 15:13:21 -0600 Message-Id: <20191106211321.27697-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, tgolembi@redhat.com, pkrempa@redhat.com Subject: [libvirt] [PATCH v2] Add API to change qemu agent response timeout X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: yxF0uhGTNnattyTTBucmcw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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. See https://bugzilla.redhat.com/show_bug.cgi?id=3D1705426 for additional de= tails. Signed-off-by: Jonathon Jongsma --- I've addressed most of the previous review comments from Peter, Daniel, and Michal but I'm unsure yet whether there's concensus on this feature. Here's= a v2 for your consideration. I admit that the proposed API is not perfect. It would probably be more ele= gant if each agent command instead had its own 'timeout' argument so that the ca= ller could specify the timeout for each invocation. But that is not the case, and introducing duplicate API for each agent command (with an additional timeout argument) would clutter the public API. In addition, we still have the issue Michal mentioned elsewhere in the thread where some commands like shutdown = may or may not use the agent, so a timeout argument could be confusing. So: is this a viable approach, or should I rethink it? Changes in v2: - Make this an official public API rather than putting it in libvirt-qemu. - Don't use the qemuDomainObjEnterAgent()/ExitAgent() API, which expects you to acquire an agent job. Instead, introduce qemuDomainObjSetAgentResponseTimeout() which simply locks the agent while setting the variable. - rename the function slightly for better descriptiveness:=20 virDomainQemuAgentSetTimeout() -> virDomainAgentSetResponseTimeout() - added 'flags' argument for future-proofing. include/libvirt/libvirt-domain.h | 9 ++++ include/libvirt/libvirt-qemu.h | 8 +-- src/driver-hypervisor.h | 6 +++ src/libvirt-domain.c | 45 +++++++++++++++++ src/libvirt_public.syms | 1 + src/qemu/qemu_agent.c | 84 ++++++++++++++++++++------------ src/qemu/qemu_agent.h | 4 ++ src/qemu/qemu_domain.c | 15 ++++++ src/qemu/qemu_domain.h | 5 ++ src/qemu/qemu_driver.c | 22 +++++++++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 18 ++++++- src/remote_protocol-structs | 9 ++++ 13 files changed, 190 insertions(+), 37 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 22277b0a84..83f6c1b835 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4916,4 +4916,13 @@ int virDomainGetGuestInfo(virDomainPtr domain, int *nparams, unsigned int flags); =20 +typedef enum { + VIR_DOMAIN_AGENT_COMMAND_BLOCK =3D -2, + VIR_DOMAIN_AGENT_COMMAND_DEFAULT =3D -1, + VIR_DOMAIN_AGENT_COMMAND_NOWAIT =3D 0, +} virDomainAgentCommandTimeoutValues; +int virDomainAgentSetResponseTimeout(virDomainPtr domain, + int timeout, + unsigned int flags); + #endif /* LIBVIRT_DOMAIN_H */ diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h index 891617443f..4a541167ad 100644 --- a/include/libvirt/libvirt-qemu.h +++ b/include/libvirt/libvirt-qemu.h @@ -43,10 +43,10 @@ virDomainPtr virDomainQemuAttach(virConnectPtr domain, unsigned int flags); =20 typedef enum { - VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN =3D -2, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK =3D -2, - VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT =3D -1, - VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT =3D 0, + VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN =3D VIR_DOMAIN_AGENT_COMMAND_BLOCK, + VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK =3D VIR_DOMAIN_AGENT_COMMAND_BLOCK, + VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT =3D VIR_DOMAIN_AGENT_COMMAND_DEF= AULT, + VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT =3D VIR_DOMAIN_AGENT_COMMAND_NOWA= IT, VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN =3D 60, } virDomainQemuAgentCommandTimeoutValues; =20 diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 015b2cd01c..4afd8f6ec5 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1372,6 +1372,11 @@ typedef int int *nparams, unsigned int flags); =20 +typedef int +(*virDrvDomainAgentSetResponseTimeout)(virDomainPtr domain, + int timeout, + unsigned int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; =20 @@ -1632,4 +1637,5 @@ struct _virHypervisorDriver { virDrvDomainCheckpointGetParent domainCheckpointGetParent; virDrvDomainCheckpointDelete domainCheckpointDelete; virDrvDomainGetGuestInfo domainGetGuestInfo; + virDrvDomainAgentSetResponseTimeout domainAgentSetResponseTimeout; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index dcab179e6e..b4e1b18164 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12497,3 +12497,48 @@ int virDomainGetLaunchSecurityInfo(virDomainPtr do= main, virDispatchError(domain->conn); return -1; } + +/** + * virDomainAgentSetResponseTimeout: + * @domain: a domain object + * @timeout: timeout in seconds + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Set how long to wait for a response from qemu agent commands. By defaul= t, + * agent commands block forever waiting for a response. + * + * @timeout must be -2, -1, 0 or positive. + * VIR_DOMAIN_AGENT_COMMAND_BLOCK(-2): meaning to block forever waiting fo= r a + * result. + * VIR_DOMAIN_AGENT_COMMAND_DEFAULT(-1): use default timeout value. + * VIR_DOMAIN_AGENT_COMMAND_NOWAIT(0): does not wait. + * positive value: wait for @timeout seconds + * + * Returns 0 on success, -1 on failure + */ +int +virDomainAgentSetResponseTimeout(virDomainPtr domain, + int timeout, + unsigned int flags) +{ + virConnectPtr conn; + VIR_DOMAIN_DEBUG(domain, "timeout=3D%i, flags=3D0x%x", + timeout, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + if (conn->driver->domainAgentSetResponseTimeout) { + if (conn->driver->domainAgentSetResponseTimeout(domain, timeout, f= lags) < 0) + goto error; + return 0; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 40655fbbf5..74d5e0b4b9 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -859,6 +859,7 @@ LIBVIRT_5.7.0 { =20 LIBVIRT_5.8.0 { virConnectSetIdentity; + virDomainAgentSetResponseTimeout; } LIBVIRT_5.7.0; =20 # .... define new API here using predicted next version number .... diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 4b914e6d3b..c2f9a025ba 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -127,6 +127,7 @@ struct _qemuAgent { * but fire up an event on qemu monitor instead. * Take that as indication of successful completion */ qemuAgentEvent await_event; + int timeout; }; =20 static virClassPtr qemuAgentClass; @@ -695,6 +696,8 @@ qemuAgentOpen(virDomainObjPtr vm, if (!(mon =3D virObjectLockableNew(qemuAgentClass))) return NULL; =20 + /* agent commands block by default, user can choose different behavior= */ + mon->timeout =3D VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK; mon->fd =3D -1; if (virCondInit(&mon->notify) < 0) { virReportSystemError(errno, "%s", @@ -907,6 +910,12 @@ qemuAgentGuestSync(qemuAgentPtr mon) int send_ret; unsigned long long id; qemuAgentMessage sync_msg; + int timeout =3D VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT; + + /* if user specified a custom agent timeout that is lower than the + * default timeout, use the shorter timeout instead */ + if ((mon->timeout >=3D 0) && (mon->timeout < timeout)) + timeout =3D mon->timeout; =20 memset(&sync_msg, 0, sizeof(sync_msg)); /* set only on first sync */ @@ -927,8 +936,7 @@ qemuAgentGuestSync(qemuAgentPtr mon) =20 VIR_DEBUG("Sending guest-sync command with ID: %llu", id); =20 - send_ret =3D qemuAgentSend(mon, &sync_msg, - VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT); + send_ret =3D qemuAgentSend(mon, &sync_msg, timeout); =20 VIR_DEBUG("qemuAgentSend returned: %d", send_ret); =20 @@ -1304,8 +1312,7 @@ int qemuAgentFSFreeze(qemuAgentPtr mon, const char **= mountpoints, if (!cmd) goto cleanup; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) goto cleanup; =20 if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) { @@ -1342,8 +1349,7 @@ int qemuAgentFSThaw(qemuAgentPtr mon) if (!cmd) return -1; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) goto cleanup; =20 if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) { @@ -1380,8 +1386,7 @@ qemuAgentSuspend(qemuAgentPtr mon, return -1; =20 mon->await_event =3D QEMU_AGENT_EVENT_SUSPEND; - ret =3D qemuAgentCommand(mon, cmd, &reply, false, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK); + ret =3D qemuAgentCommand(mon, cmd, &reply, false, mon->timeout); =20 virJSONValueFree(cmd); virJSONValueFree(reply); @@ -1437,8 +1442,7 @@ qemuAgentFSTrim(qemuAgentPtr mon, if (!cmd) return ret; =20 - ret =3D qemuAgentCommand(mon, cmd, &reply, false, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK); + ret =3D qemuAgentCommand(mon, cmd, &reply, false, mon->timeout); =20 virJSONValueFree(cmd); virJSONValueFree(reply); @@ -1459,8 +1463,7 @@ qemuAgentGetVCPUs(qemuAgentPtr mon, if (!(cmd =3D qemuAgentMakeCommand("guest-get-vcpus", NULL))) return -1; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) goto cleanup; =20 if (!(data =3D virJSONValueObjectGetArray(reply, "return"))) { @@ -1575,8 +1578,7 @@ qemuAgentSetVCPUsCommand(qemuAgentPtr mon, NULL))) goto cleanup; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) goto cleanup; =20 /* All negative values are invalid. Return of 0 is bogus since we woul= dn't @@ -1731,8 +1733,7 @@ qemuAgentGetHostname(qemuAgentPtr mon, if (!cmd) return ret; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) { + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) { if (qemuAgentErrorCommandUnsupported(reply)) ret =3D -2; goto cleanup; @@ -1776,8 +1777,7 @@ qemuAgentGetTime(qemuAgentPtr mon, if (!cmd) return ret; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) goto cleanup; =20 if (virJSONValueObjectGetNumberUlong(reply, "return", &json_time) < 0)= { @@ -1842,8 +1842,7 @@ qemuAgentSetTime(qemuAgentPtr mon, if (!cmd) return ret; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) goto cleanup; =20 ret =3D 0; @@ -2046,8 +2045,7 @@ qemuAgentGetFSInfoInternal(qemuAgentPtr mon, if (!cmd) return ret; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) { + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) { if (qemuAgentErrorCommandUnsupported(reply)) ret =3D -2; goto cleanup; @@ -2336,8 +2334,7 @@ qemuAgentGetInterfaces(qemuAgentPtr mon, if (!(cmd =3D qemuAgentMakeCommand("guest-network-get-interfaces", NUL= L))) goto cleanup; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) goto cleanup; =20 if (!(ret_array =3D virJSONValueObjectGet(reply, "return"))) { @@ -2514,8 +2511,7 @@ qemuAgentSetUserPassword(qemuAgentPtr mon, NULL))) goto cleanup; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) goto cleanup; =20 ret =3D 0; @@ -2546,8 +2542,7 @@ qemuAgentGetUsers(qemuAgentPtr mon, if (!(cmd =3D qemuAgentMakeCommand("guest-get-users", NULL))) return -1; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) { + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) { if (qemuAgentErrorCommandUnsupported(reply)) return -2; return -1; @@ -2636,8 +2631,7 @@ qemuAgentGetOSInfo(qemuAgentPtr mon, if (!(cmd =3D qemuAgentMakeCommand("guest-get-osinfo", NULL))) return -1; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) { + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) { if (qemuAgentErrorCommandUnsupported(reply)) return -2; return -1; @@ -2692,8 +2686,7 @@ qemuAgentGetTimezone(qemuAgentPtr mon, if (!(cmd =3D qemuAgentMakeCommand("guest-get-timezone", NULL))) return -1; =20 - if (qemuAgentCommand(mon, cmd, &reply, true, - VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) { + if (qemuAgentCommand(mon, cmd, &reply, true, mon->timeout) < 0) { if (qemuAgentErrorCommandUnsupported(reply)) return -2; return -1; @@ -2722,3 +2715,30 @@ qemuAgentGetTimezone(qemuAgentPtr mon, =20 return 0; } + +/* qemuAgentSetResponseTimeout: + * mon: agent monitor + * timeout: number of seconds to wait for agent response + * flags: currently unused. Must pass 0 + * + * the agent object must be locked prior to calling this function + * + * Returns: 0 on success + * -1 otherwise + */ +int +qemuAgentSetResponseTimeout(qemuAgentPtr mon, + int timeout, + unsigned int flags G_GNUC_UNUSED) +{ + if (timeout < VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN) { + virReportError(VIR_ERR_INVALID_ARG, + _("guest agent timeout '%d' is " + "less than the minimum '%d'"), + timeout, VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN); + return -1; + } + + mon->timeout =3D timeout; + return 0; +} diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 78e648992a..88ead4762a 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -140,3 +140,7 @@ int qemuAgentGetTimezone(qemuAgentPtr mon, virTypedParameterPtr *params, int *nparams, int *maxparams); + +int qemuAgentSetResponseTimeout(qemuAgentPtr mon, + int timeout, + unsigned int flags); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 667cc89072..40d0401e79 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -15564,3 +15564,18 @@ qemuDomainSupportsCheckpointsBlockjobs(virDomainOb= jPtr vm) =20 return 0; } + +int qemuDomainObjSetAgentResponseTimeout(virDomainObjPtr vm, + int timeout, + unsigned int flags) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuAgentPtr agent =3D priv->agent; + int ret; + + virObjectLock(agent); + ret =3D qemuAgentSetResponseTimeout(agent, timeout, flags); + virObjectUnlock(agent); + + return ret; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index b23912ee98..34af55ef45 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1225,3 +1225,8 @@ qemuDomainValidateActualNetDef(const virDomainNetDef = *net, int qemuDomainSupportsCheckpointsBlockjobs(virDomainObjPtr vm) G_GNUC_WARN_UNUSED_RESULT; + +int +qemuDomainObjSetAgentResponseTimeout(virDomainObjPtr vm, + int seconds, + unsigned int flags); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d17c18705b..68f7b65d81 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22654,6 +22654,27 @@ qemuDomainGetGuestInfo(virDomainPtr dom, return ret; } =20 +static int +qemuDomainAgentSetResponseTimeout(virDomainPtr dom, + int timeout, + unsigned int flags) +{ + virDomainObjPtr vm =3D NULL; + int ret =3D -1; + + if (!(vm =3D qemuDomainObjFromDomain(dom))) + goto cleanup; + + if (virDomainAgentSetResponseTimeoutEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + ret =3D qemuDomainObjSetAgentResponseTimeout(vm, timeout, flags); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectURIProbe =3D qemuConnectURIProbe, @@ -22890,6 +22911,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainCheckpointGetParent =3D qemuDomainCheckpointGetParent, /* 5.6.0= */ .domainCheckpointDelete =3D qemuDomainCheckpointDelete, /* 5.6.0 */ .domainGetGuestInfo =3D qemuDomainGetGuestInfo, /* 5.7.0 */ + .domainAgentSetResponseTimeout =3D qemuDomainAgentSetResponseTimeout, = /* 5.8.0 */ }; =20 =20 diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 83477243fc..77edf0b4c4 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8710,6 +8710,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainCheckpointGetParent =3D remoteDomainCheckpointGetParent, /* 5.6= .0 */ .domainCheckpointDelete =3D remoteDomainCheckpointDelete, /* 5.6.0 */ .domainGetGuestInfo =3D remoteDomainGetGuestInfo, /* 5.7.0 */ + .domainAgentSetResponseTimeout =3D remoteDomainAgentSetResponseTimeout= , /* 5.8.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index f4e3392212..23e42d17b1 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3744,6 +3744,16 @@ struct remote_connect_set_identity_args { unsigned int flags; }; =20 +struct remote_domain_agent_set_response_timeout_args { + remote_nonnull_domain dom; + int timeout; + unsigned int flags; +}; + +struct remote_domain_agent_set_response_timeout_ret { + int result; +}; + /*----- Protocol. -----*/ =20 /* Define the program number, protocol version and procedure numbers here.= */ @@ -6617,5 +6627,11 @@ enum remote_procedure { * @generate: client * @acl: connect:write */ - REMOTE_PROC_CONNECT_SET_IDENTITY =3D 419 + REMOTE_PROC_CONNECT_SET_IDENTITY =3D 419, + + /** + * @generate: both + * @acl: domain:write + */ + REMOTE_PROC_DOMAIN_AGENT_SET_RESPONSE_TIMEOUT =3D 420 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 51606e7473..9ad7a857e0 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3114,6 +3114,14 @@ struct remote_connect_set_identity_args { } params; u_int flags; }; +struct remote_domain_agent_set_response_timeout_args { + remote_nonnull_domain dom; + int timeout; + u_int flags; +}; +struct remote_domain_agent_set_response_timeout_ret { + int result; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3534,4 +3542,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_CHECKPOINT_DELETE =3D 417, REMOTE_PROC_DOMAIN_GET_GUEST_INFO =3D 418, REMOTE_PROC_CONNECT_SET_IDENTITY =3D 419, + REMOTE_PROC_DOMAIN_AGENT_SET_RESPONSE_TIMEOUT =3D 420, }; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list