From nobody Fri Dec 19 18:46:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1742486727; cv=none; d=zohomail.com; s=zohoarc; b=T9m4mJMNVs0JHm6y1+BMdXHb6ZIXC3jXZJ4kq0BPXVbV2PCw/dKAKREKvv6cYCW4fvb7+veJyHT7e751sf88f/kG1P4CbWQcTCgu/ozFLL+jDlc8l5ZQeryT2gWygjon+jtJ8ZeloIIXxeosVKWaM3gDud50FqhVDhZ7VC7rGCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742486727; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=wvAzSZV2le5dIXlauZyXx230lieoMX9aw6xyA3SfMWw=; b=P6gqcLhTLFMoBawT8tkVnM/iQO2iX9gCVnGL4oZ9a9uTOXo5of+dTfLl/pZIK0ja4N3XghCPMMRaRSg9yzNJFjTy8loC8YInapQ7YpYi1XrmVlwHmxBmAUkGJmH5aYgrHOhA+nCAJBaD2fsFJ8wOxC3XgJaby7gWdflMaDDYEbQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 174248672724046.6265563290026; Thu, 20 Mar 2025 09:05:27 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id AB7781604; Thu, 20 Mar 2025 12:05:26 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 296901781; Thu, 20 Mar 2025 12:04:40 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0841B127E; Thu, 20 Mar 2025 12:04:14 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 80C831274 for ; Thu, 20 Mar 2025 12:04:13 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-504-MrFLNgu5PfWWWzhbz4_xMA-1; Thu, 20 Mar 2025 12:04:11 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2F184196D2E2 for ; Thu, 20 Mar 2025 16:04:11 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5F7B819373C4 for ; Thu, 20 Mar 2025 16:04:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742486653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wvudvRGh2KlUEARWPUtWvcQ3jLubZ3yCXlJucCnvoRY=; b=gt4uF+QBhcpK3nySf2oB9yxzNHXNTMfzDaa1cItAxkqzAB0dX2Jl+WYd5hc0C4IRH/CNCJ cLBH4MaJhDJ0aoqQwPK6xGFgX5hl3JCNwV+l3J/EXWYGhKQrukh9PFNB1O1j+C3Pn2h6sr vVwadH8oAHALFHFVzwrvBO0Z2FsqaJI= X-MC-Unique: MrFLNgu5PfWWWzhbz4_xMA-1 X-Mimecast-MFC-AGG-ID: MrFLNgu5PfWWWzhbz4_xMA_1742486651 To: devel@lists.libvirt.org Subject: [PATCH 2/8] qemu: agent: Differentiate timeouts when syncing from command timeout Date: Thu, 20 Mar 2025 17:03:59 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: eYO23S7YT33rGaNzP_WqMw9OrfY3VjXnhzikOufiPDk_1742486651 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WT2HR454NIBIBYB6F55BQCI3PCC2C4FY X-Message-ID-Hash: WT2HR454NIBIBYB6F55BQCI3PCC2C4FY X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: <> List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1742486728702019000 Content-Type: text/plain; charset="utf-8" From: Peter Krempa As the guest agent code uses timeouts it is possible that we stop waiting before the guest agent replies. If this happens while syncing everything is okay because we didn't send any state-changing command. In case when the timeout happens after a real command was transmitted it's unknown if the guest-agent processed it or not. Use the new special error code VIR_ERR_AGENT_COMMAND_TIMEOUT for cases when we sent non-sync commands, so that the management applications or users have possibility to react to this situation. Signed-off-by: Peter Krempa --- src/qemu/qemu_agent.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 6f5aab5bf2..879c3a8f41 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -707,6 +707,7 @@ void qemuAgentClose(qemuAgent *agent) * @msg: Message * @seconds: number of seconds to wait for the result, it can be either * -2, -1, 0 or positive. + * @report_sync: On timeout; report synchronization error instead of the n= ormal error * * Send @msg to agent @agent. If @seconds is equal to * VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK(-2), this function will block forev= er @@ -720,9 +721,11 @@ void qemuAgentClose(qemuAgent *agent) * -2 on timeout, * -1 otherwise */ -static int qemuAgentSend(qemuAgent *agent, - qemuAgentMessage *msg, - int seconds) +static int +qemuAgentSend(qemuAgent *agent, + qemuAgentMessage *msg, + int seconds, + bool report_sync) { int ret =3D -1; unsigned long long then =3D 0; @@ -751,8 +754,15 @@ static int qemuAgentSend(qemuAgent *agent, if ((then && virCondWaitUntil(&agent->notify, &agent->parent.lock,= then) < 0) || (!then && virCondWait(&agent->notify, &agent->parent.lock) < 0= )) { if (errno =3D=3D ETIMEDOUT) { - virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s", - _("Guest agent not available for now")); + if (report_sync) { + virReportError(VIR_ERR_AGENT_UNRESPONSIVE, + _("guest agent didn't respond to synchr= onization within '%1$d' seconds"), + seconds); + } else { + virReportError(VIR_ERR_AGENT_COMMAND_TIMEOUT, + _("guest agent didn't respond to comman= d within '%1$d' seconds"), + seconds); + } ret =3D -2; } else { virReportSystemError(errno, "%s", @@ -817,7 +827,7 @@ qemuAgentGuestSyncSend(qemuAgent *agent, VIR_DEBUG("Sending guest-sync command with ID: %llu", id); - rc =3D qemuAgentSend(agent, &sync_msg, timeout); + rc =3D qemuAgentSend(agent, &sync_msg, timeout, true); rxObj =3D g_steal_pointer(&sync_msg.rxObject); VIR_DEBUG("qemuAgentSend returned: %d", rc); @@ -1040,7 +1050,7 @@ qemuAgentCommandFull(qemuAgent *agent, VIR_DEBUG("Send command '%s' for write, seconds =3D %d", cmdstr, secon= ds); - ret =3D qemuAgentSend(agent, &msg, seconds); + ret =3D qemuAgentSend(agent, &msg, seconds, false); VIR_DEBUG("Receive command reply ret=3D%d rxObject=3D%p", ret, msg.rxObject); --=20 2.48.1