From nobody Sat Feb 7 18:11:01 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; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1715170417899205.27657482750806; Wed, 8 May 2024 05:13:37 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id BDAA81C42; Wed, 8 May 2024 08:13:36 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id CC3831C3B; Wed, 8 May 2024 08:11:48 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A84331A01; Wed, 8 May 2024 08:11:38 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 EDE4E1A04 for ; Wed, 8 May 2024 08:11:35 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-nAP6PJ4YN_SXNOaQhtVe_g-1; Wed, 08 May 2024 08:11:34 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA7173802266 for ; Wed, 8 May 2024 12:11:33 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 588941000DB9; Wed, 8 May 2024 12:11:33 +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.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: nAP6PJ4YN_SXNOaQhtVe_g-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Subject: [PATCH 1/2] tests: fix hang in virshtest 'read-big-pipe' case Date: Wed, 8 May 2024 13:11:30 +0100 Message-ID: <20240508121131.1214941-2-berrange@redhat.com> In-Reply-To: <20240508121131.1214941-1-berrange@redhat.com> References: <20240508121131.1214941-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: CUIU5KQK3DSP7NKYY4IUKQ42GLZCSOSC X-Message-ID-Hash: CUIU5KQK3DSP7NKYY4IUKQ42GLZCSOSC X-MailFrom: berrange@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 CC: Andrea Bolognani , Peter Krempa 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: 1715170418127100001 The virshtest program testPipeFeeder method is doing this: mkfifo("test.fifo", 0600) ; int fd =3D open("test.fifo", O_RDWR); char buf[...]; memset(buf, 'a', sizeof(buf)); write(fd, buf, sizeof(buf)) =3D=3D sizeof(buf)); close(fd); while the the 'virsh' child process then ends up doing: fd =3D open("test.fifo", O_RDONLY); read(fd, buf, sizeof(buf)) =3D=3D sizeof(buf)); close(fd); The 'virsh' code hangs on open() on at least ppc64 and some other arches. It can be provoked to hang even on x86 by reducing the size of the buffer. It can be prevented from hanging on ppc64 by increasing the size of the buffer. What is happening is a result of differing page sizes, altering the overall pipe capacity size, since pipes on linux default to 16 pages in size and thus have architecture specific capacity when measured in bytes. * On x86, testPipeFeeder opens R+W, tries to write 140kb and write() blocks because the pipe is full. This gives time for virsh to start up, and it can open the pipe for O_RDONLY since testPipeFeeder still has it open for write. Everything works as intended. * On ppc64, testPipeFeeder opens R+W, tries to write 140kb and write() succeeds because the larger 64kb page size resulted in greater buffer capacity for the pipe. It thus quickly closes the pipe, removing the writer, and triggering discard of all the unread data. Now virsh starts up, tries to open the pipe for O_RDONLY and blocks waiting for a new writer to open it, which will never happen. Meson kills it the test after 30 seconds. NB, every now & then, it will not block because virsh starts up quickly enough that testPipeFeeder has not yet closed the write end of the pipe, giving the illusion of correctness. The key flaw here is that it should not have been using O_RDWR in testPipeFeeder. Synchronization is required such that both virsh and testPipeFeeder have their respective ends of the pipe open before any data is sent. This is trivially arranged by using O_WRONLY in testPipeFeeder. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Andrea Bolognani --- tests/virshtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/virshtest.c b/tests/virshtest.c index a1ae481316..7a7797647c 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -145,7 +145,7 @@ testPipeFeeder(void *opaque) g_autofree char *doc =3D g_new0(char, emptyspace + xmlsize + 1); VIR_AUTOCLOSE fd =3D -1; =20 - if ((fd =3D open(pipepath, O_RDWR)) < 0) { + if ((fd =3D open(pipepath, O_WRONLY)) < 0) { fprintf(stderr, "\nfailed to open pipe '%s': %s\n", pipepath, g_st= rerror(errno)); return; } --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org