From nobody Sun Apr 28 18:40:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1595328068; cv=none; d=zohomail.com; s=zohoarc; b=CgsGX5wJ2QIVLUtbZLKqTDR2hFwQ72nfASeWBykw4CyxGPzlsfAwfrlcLgjj/eK3QsW1Sam32KwAFhrCv3zsFW3g56lzWCzdia5C/9C+j7I5QT2xcZKljMQlMxfuBjEpg0XMIMy/7UDJN8wBmrQbaSAWacXPqhsckVK12z+VZEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595328068; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=98WUIxuonxUUctaMMJv3lFKj/bedK+FO04GZa2XyWJk=; b=ZE74ByCgEyQqjDw2sy8Ltlb6XcOkDRNEDlgYUERRdxicqjjYZVCY9+TS367u5K2LvYyKSLRwCYdi5REypwp40Lwu1QfUO0Nob5EooFpkNjegoM6WoDlr9XPCTI4b3Ghtz44WnF6f4m9YLHdSLAWu1G2zjjzv6P8MuSX8mWXSOng= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1595328068721833.0159745360554; Tue, 21 Jul 2020 03:41:08 -0700 (PDT) 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-188-q4Li5fuHNxaN2PQeRBwfYw-1; Tue, 21 Jul 2020 06:41:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D332C1017D60; Tue, 21 Jul 2020 10:40:24 +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 AE9C761177; Tue, 21 Jul 2020 10:40:24 +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 7CEE0A3584; Tue, 21 Jul 2020 10:40:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06LAe5I4018002 for ; Tue, 21 Jul 2020 06:40:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 808C761177; Tue, 21 Jul 2020 10:40:05 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id E019970C37 for ; Tue, 21 Jul 2020 10:40:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595328067; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=98WUIxuonxUUctaMMJv3lFKj/bedK+FO04GZa2XyWJk=; b=b4aT6UJuVy2zOQalrdYrNT0MJNa+BFg6Let9xi6BPVnegd7GkUYYL+zOlVr65ftzHAlGDe m03uBno+6C8qENNjy4kzvbpx9+zrQxxsPI/ft6vudVsUnbv1va2Gg7QDB0Vi+gDFUQwKCI Tz1wV1gwMoWa69dwCOcnZ/242TNuiEg= X-MC-Unique: q4Li5fuHNxaN2PQeRBwfYw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] vircommand: REPRODUCER: Add artificial timeout before exitting daemonization helper Date: Tue, 21 Jul 2020 12:39:55 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Let the intermediate process linger for a moment to reproduce the sporradic failure in 'commandtest'. Reviewed-by: J=C3=A1n Tomko --- src/util/vircommand.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 5ce69ef241..f6da8b5cf1 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -783,6 +783,7 @@ virExec(virCommandPtr cmd) _("Unable to wait for child process")= ); _exit(EXIT_FAILURE); } + g_usleep(100*1000); _exit(EXIT_SUCCESS); } } --=20 2.26.2 From nobody Sun Apr 28 18:40:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1595328060; cv=none; d=zohomail.com; s=zohoarc; b=KFrIFVBhYDpPkBbbcVgm+HkVw8MMZV2O4Aq0AQEPrkCtIhgT8O1U+sBUHMbfaPkV9kT6oROk4uJa6nxIe/j/jyqOIatZkutpUPNDYiNfxHJieaYuMdJrWx+4HixFsJCz4bFkBSMREdCt9ENENNOPLGkhEFLCSleVWzr4ACfUv0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595328060; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dTcN+bb7sz5jXONLplvS+KdOZJ70vg7C705bnQatw00=; b=RAO1u0mVWXNKVNU4BzKWkFxNCTrhELN0ZJz9xQZ3c3DD5JSDTvV6bX04Q1fQnmukDRKWJf4KgfvPPGb5XnurZ0oMKi4nT4BuDwgN/CCt5CG7HALY9tYygm94FdsV1LcPuXDqQJkUAofkMyLM8opxRJ3YeESCxIVYdK49OUqPM1Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1595328060124165.76706252953602; Tue, 21 Jul 2020 03:41:00 -0700 (PDT) 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-470-SoS02K7eNeeRSpxs33U5eg-1; Tue, 21 Jul 2020 06:40:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2CDF0E9729; Tue, 21 Jul 2020 10:40:10 +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 B14A669627; Tue, 21 Jul 2020 10:40:09 +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 CE6DCA3582; Tue, 21 Jul 2020 10:40:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06LAe6q4018017 for ; Tue, 21 Jul 2020 06:40:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id D565D70105; Tue, 21 Jul 2020 10:40:06 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 306CA61177 for ; Tue, 21 Jul 2020 10:40:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595328058; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dTcN+bb7sz5jXONLplvS+KdOZJ70vg7C705bnQatw00=; b=GFPuf78zLOOJbEJRtu+TgnkgBvLD0NCXpcpcDsF0aY0rfKzUI2VpCmbIMIr6uOzMSa7f10 z7ZWSpOv4JsQ/5uK2YrOEXGJTpBfZohpyjD5vgyQnkahRWpAbfHdoLqduvr41zH8XH+0Hu ZHk6GpnCZbYXdgcsfomSfZUaCpeXQVw= X-MC-Unique: SoS02K7eNeeRSpxs33U5eg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] tests: commandtest: Make 'test4' checking daemonization more reliable Date: Tue, 21 Jul 2020 12:39:56 +0200 Message-Id: <279bbd723984d7680c5d819035578d0900f62eda.1595327884.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The 'commandhelper' checks effectively whether the parent process is still around to report whether it was daemonized or not. This creates a unlikely race condition in cases when we do actually daemonize the process as the intermediate process used for the daemonization might not have terminated yet which would report wrong result leading to test failure. For now there's just 'test4' which actually daemonizes the process. Add an argument '--check-daemonize' which asks for retires of the daemonization check in cases where we expect that the commandhelper is going to be daemonized and use it in 'test4' to make the test more reliable. I've observed the test failure sporradically when my box is more loaded e.g. while building two trees at once. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/commanddata/test4.log | 1 + tests/commandhelper.c | 17 ++++++++++++++++- tests/commandtest.c | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/commanddata/test4.log b/tests/commanddata/test4.log index 24a37a7e96..4fd40cc474 100644 --- a/tests/commanddata/test4.log +++ b/tests/commanddata/test4.log @@ -1,3 +1,4 @@ +ARG:--check-daemonize ENV:DISPLAY=3D:0.0 ENV:HOME=3D/home/test ENV:HOSTNAME=3Dtest diff --git a/tests/commandhelper.c b/tests/commandhelper.c index 4266e11902..b366483771 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -72,6 +72,8 @@ int main(int argc, char **argv) { char *buffers[3] =3D {NULL, NULL, NULL}; size_t buflen[3] =3D {0, 0, 0}; char c; + bool daemonize_check =3D false; + size_t daemonize_retries =3D 3; if (!log) return ret; @@ -83,6 +85,8 @@ int main(int argc, char **argv) { sscanf(argv[i], "%u%c", &readfds[numreadfds++], &c) !=3D 1) { printf("Could not parse fd %s\n", argv[i]); goto cleanup; + } else if (STREQ(argv[i], "--check-daemonize")) { + daemonize_check =3D true; } } @@ -126,7 +130,18 @@ int main(int argc, char **argv) { fprintf(log, "FD:%zu\n", i); } - fprintf(log, "DAEMON:%s\n", getpgrp() !=3D getppid() ? "yes" : "no"); + while (true) { + bool daemonized =3D getpgrp() !=3D getppid(); + + if (daemonize_check && !daemonized && daemonize_retries-- > 0) { + usleep(100*1000); + continue; + } + + fprintf(log, "DAEMON:%s\n", daemonized ? "yes" : "no"); + break; + } + if (!(cwd =3D getcwd(NULL, 0))) goto cleanup; if (strlen(cwd) > strlen(".../commanddata") && diff --git a/tests/commandtest.c b/tests/commandtest.c index f0e60ee5fe..9bef825239 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -255,7 +255,8 @@ static int test3(const void *unused G_GNUC_UNUSED) */ static int test4(const void *unused G_GNUC_UNUSED) { - virCommandPtr cmd =3D virCommandNew(abs_builddir "/commandhelper"); + virCommandPtr cmd =3D virCommandNewArgList(abs_builddir "/commandhelpe= r", + "--check-daemonize", NULL); char *pidfile =3D virPidFileBuildPath(abs_builddir, "commandhelper"); pid_t pid; int ret =3D -1; --=20 2.26.2