From nobody Sun Feb 8 15:29:48 2026 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=1743065081; cv=none; d=zohomail.com; s=zohoarc; b=iaysrjCb+UiKeAbYI3QzQXlUbHNyCPuUkPHjP1sKzEZXK7P5nuzBWJzashXbK6yicO0Y9Fl7NI1do+Xsflkf3foeP3jzuHlsKo60gS32q+g4wU42pTo0HI67NCOcfqqgjC/PNGUIwSNB0mr8FbzWS4X3oxni+F/ndstrXIAd2cg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743065081; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id; bh=CVvsIQe2nAGjk84iuF4FF3+X/YlrITOUbh86zJNf74Q=; b=h7StV7N9zuGsxE9/s/9w7rF3Q9DsE7J8+M9qLLlLaAYqwV3IYMGLlcAl6EEs4L91z9PJh63pA9UehTsBkfuNJFEQ6G45ZDt34no4bsb8ArkISOwsiDEKL4qSIeYjK3m1X/IgNaqe8fhQOaECoQEMjdoAb2Dhts504iXrUz/V9bg= 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 1743065081022278.87614685449125; Thu, 27 Mar 2025 01:44:41 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0662F137E; Thu, 27 Mar 2025 04:44:39 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D715C1380; Thu, 27 Mar 2025 04:44:23 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F3AB214DF; Thu, 20 Mar 2025 19:33:11 -0400 (EDT) Received: from frida.bearstech.com (frida.bearstech.com [78.40.125.115]) (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 B5F6314D9 for ; Thu, 20 Mar 2025 19:33:07 -0400 (EDT) Received: from zeroco.bearstech.lan (home.zerodeux.net [82.64.218.119]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: vcaron@bearstech.com) by frida.bearstech.com (Postfix) with ESMTPSA id A70D321D; Fri, 21 Mar 2025 00:27:59 +0100 (CET) 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_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-Greylist: delayed 304 seconds by postgrey-1.37 at lists.libvirt.org; Thu, 20 Mar 2025 19:33:07 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bearstech.com; s=bearstech2024; t=1742513279; bh=CEG8W3Y0Q7kbS5cgeClp+3HkpFazLJbD88+/+TVtYfc=; h=From:To:Cc:Subject:Date:From; b=r1RqG32Bxmq0UDv6AFkDR6djcMcgCQ2YPohR/2CSx/0EBBBr/oTAGo14SJKoy9fdm xV2tCmJ1lGUqmo/JnWGNhon4Zz19S3/2HC7+F+DnnB54o+9XttYJrbXuKxbTpVb92A r+uKa42Z4wwEKtLIsXlRKp6VawUow2RsYA0X6I4lVymoqjWE+FtaSYJ70PYR7zDfiu Vlz1BwxLvtEme69GUQ0qdJ92vNJX7RKo7aaSsh788fGJq+ijdnJx5ElfbQ3CYPSnBc +iZq8oJ6c+Z3DrLhPLyEeiFmn9bUZAqVp7ka8ZFwkwdw95iIbop0AAMbad+zN3rQvD XSrYdug/GrCVA== To: devel@lists.libvirt.org Subject: [PATCH] virsh: make virshPrintJobProgress tty-aware Date: Fri, 21 Mar 2025 00:27:49 +0100 Message-Id: <20250320232749.68728-1-vcaron@bearstech.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 1.0.7 at frida X-Virus-Status: Clean Content-Transfer-Encoding: quoted-printable X-MailFrom: vcaron@bearstech.com X-Mailman-Rule-Hits: nonmember-moderation 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 Message-ID-Hash: 7WVQOJSQYRZFQZGDIRYWFBA6KP65U2MD X-Message-ID-Hash: 7WVQOJSQYRZFQZGDIRYWFBA6KP65U2MD X-Mailman-Approved-At: Thu, 27 Mar 2025 08:44:21 -0400 CC: Vincent Caron 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: Vincent Caron via Devel Reply-To: Vincent Caron X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1743065086347019100 Content-Type: text/plain; charset="utf-8" virshPrintJobProgress pretty-prints a migration progress indicator on stderr presuming it's tied to a tty, which is not always true. In the case without the tty, I still find the progress indication useful (for instance it ends in a timestamped log, which is useful for debug/perf analysis). And most log processings are line-buffered, thus it won't properly work until every progress update ends with a newline. I had a quick glance and did not find any other place in virsh code where a tty was assumed, thus I thought this tty-awareness could be narrowed to this single function. This was originally submited as https://gitlab.com/libvirt/libvirt/-/issues/756 Signed-off-by: Vincent Caron --- tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 1bee969824..577ab57158 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2108,7 +2108,7 @@ virshPrintJobProgress(const char *label, unsigned lon= g long remaining, /* see comments in vshError about why we must flush */ fflush(stdout); /* avoid auto-round-off of double by keeping only 2 decimals */ - fprintf(stderr, "\r%s: [%5.2f %%]", label, (int)(progress*100)/100.0); + fprintf(stderr, isatty(STDERR_FILENO) ? "\r%s: [%5.2f %%]" : "%s: [%5.= 2f %%]\n", label, (int)(progress*100)/100.0); fflush(stderr); } =20 --=20 2.39.5