From nobody Sun May 12 09:11:54 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1708526863588285.26531283945894; Wed, 21 Feb 2024 06:47:43 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4A1A0178A; Wed, 21 Feb 2024 09:47:42 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7EF9619AD; Wed, 21 Feb 2024 09:46:19 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 824B6181E; Wed, 21 Feb 2024 09:46:11 -0500 (EST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 0A5B91992 for ; Wed, 21 Feb 2024 09:46:10 -0500 (EST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1dc1ff58fe4so13911975ad.1 for ; Wed, 21 Feb 2024 06:46:09 -0800 (PST) Received: from localhost.localdomain ([111.192.193.42]) by smtp.gmail.com with ESMTPSA id lk15-20020a17090308cf00b001db40c0ed23sm8110588plb.62.2024.02.21.06.46.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 06:46:07 -0800 (PST) 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=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708526768; x=1709131568; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5UgQBVIp62KcT2gjPxtXuVmnLp2URaB25RZPM15yaNs=; b=EjUtr3iRXllp6mU+3X5FKdiqfVIS3cK4Jv1aS4UMAPT7r65nx0BFZfdPX6VlPdQUIm v78yQjTrvJL3YKLiZ8LfLl5pZowKvzXrCkObWw2xD1Yw1+ffP3hp/KMhagMt3gnzPMuV aH63qNy+hAxTZ0vYxIE5i1E0o8K6mMBg1ECmOVmqSU2IDiKpy1xLzAWUVMosJoVix+GD 2+LTbF+ub7bi7WqZtqC6fc0wta5UWf94QgYY6QIpqaOfTXYNWfkyRmL5KT5g4cmuCtDR eukpcZBRbeI+OBFLzH5FV3e+z3TeVJc5OmndvYAN5E+0FsFpsHdIE368r9roin+3XK0u nxYw== X-Gm-Message-State: AOJu0YwieDI5GtTeoy+qBKl+YhE+VcdLi2q+nHhMvi5vzs//GJJv3z6b G9oXn0r307akT2z1zPS9xKIE9jTv8QvFGHt4qbHzeo+OjK7ffK/Zu+VaWNhYv/VUoUUch3lLGD+ +CrVqkA== X-Google-Smtp-Source: AGHT+IFHOjphwi2UdQKJdYWUM9psjF1ByZmKi20odf+YGlFpa0iCMxSE2L0ISdJxCv76EPEzOvQoQg== X-Received: by 2002:a17:902:7803:b0:1db:35b5:7e37 with SMTP id p3-20020a170902780300b001db35b57e37mr16360264pll.50.1708526768129; Wed, 21 Feb 2024 06:46:08 -0800 (PST) From: ray To: devel@lists.libvirt.org Subject: [PATCH] qemu: Fix guest-sync response time in qga command Date: Wed, 21 Feb 2024 06:45:36 -0800 Message-ID: <20240221144551.15324-1-honglei.wang@smartx.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Message-ID-Hash: WXU2WD3FL4P5V427D7EHUDSHWGAT5F56 X-Message-ID-Hash: WXU2WD3FL4P5V427D7EHUDSHWGAT5F56 X-MailFrom: honglei.wang@smartx.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 CC: ray 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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1708526864594100001 The current implementation sets the guest-sync timeout to the smaller value between the default value (QEMU_AGENT_WAIT_TIME) and agent->timeout, without considering the timeout passed via the qga command. This patch enhances the guest-sync timeout logic to use the minimum value among the default value, agent->timeout, and the timeout passed via the qga command. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/590 Signed-off-by: ray Reviewed-by: Michal Privoznik --- src/qemu/qemu_agent.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index f9bcf38dfb..47d735dfa3 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -835,6 +835,7 @@ qemuAgentGuestSyncSend(qemuAgent *agent, /** * 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 @@ -844,9 +845,9 @@ qemuAgentGuestSyncSend(qemuAgent *agent, * -1 otherwise */ static int -qemuAgentGuestSync(qemuAgent *agent) +qemuAgentGuestSync(qemuAgent *agent, int seconds) { - int timeout =3D VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT; + int timeout =3D QEMU_AGENT_WAIT_TIME; int rc; =20 if (agent->inSync) @@ -854,9 +855,15 @@ qemuAgentGuestSync(qemuAgent *agent) =20 /* if user specified a custom agent timeout that is lower than the * default timeout, use the shorter timeout instead */ - if ((agent->timeout >=3D 0) && (agent->timeout < QEMU_AGENT_WAIT_TIME)) + if ((agent->timeout >=3D 0) && (agent->timeout < timeout)) timeout =3D agent->timeout; =20 + /* 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 >=3D 0) && (seconds < timeout)) + timeout =3D seconds; + if ((rc =3D qemuAgentGuestSyncSend(agent, timeout, true)) < 0) return -1; =20 @@ -1022,7 +1029,7 @@ qemuAgentCommandFull(qemuAgent *agent, goto cleanup; } =20 - if (qemuAgentGuestSync(agent) < 0) + if (qemuAgentGuestSync(agent, seconds) < 0) goto cleanup; =20 if (!(cmdstr =3D virJSONValueToString(cmd, false))) --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org