From patchwork Thu Sep 23 14:45:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raphael Norwitz X-Patchwork-Id: 12513105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8D6FC433F5 for ; Thu, 23 Sep 2021 14:47:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2F813606A5 for ; Thu, 23 Sep 2021 14:47:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2F813606A5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nutanix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:39168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTQ0h-00025X-7v for qemu-devel@archiver.kernel.org; Thu, 23 Sep 2021 10:47:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTPyr-0001Ki-Dd for qemu-devel@nongnu.org; Thu, 23 Sep 2021 10:45:46 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:18760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTPyn-0006DF-QA for qemu-devel@nongnu.org; Thu, 23 Sep 2021 10:45:44 -0400 Received: from pps.filterd (m0127840.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18NE52sw002096; Thu, 23 Sep 2021 07:45:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=proofpoint20171006; bh=qP/e8os3SWnpSnTKE9F7ira9foXW3jvEmtEaWBG/UfQ=; b=PbaCAsfbijQA+cyRQbjdwNZw450vsR/b/lYQkriqAvTzIleVUqfYTKzxYg1NJWMnfE9q 2Zv2FVJY2KY7XK0mAqB8Yj7eZEMwiCfWugNynbfLkRBGmO919BbvGt3VJLtn7CTf5hJQ Y3ERGBzG1BPh+/6zGIsYyAxyec05A0wdqg8vxf9qd2FAoxDeAjnKshEz6DVc9Rq9NE/d MNNeagBdNc26zldC9A5XLOGXK0nEi9NIC4qlPtka4Khedl2GWzPe17tBCXmWzjAbf5Y+ OKbOg5kGy+6QKPYCVOCq7uioux1acwWGA7QxxfaMOOErXVU/Pc12MxjrOvCc1wBgZN0n Gg== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by mx0a-002c1b01.pphosted.com with ESMTP id 3b8arksu1t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Sep 2021 07:45:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NLJSncksmYlVScpPZT6EYZcq47zYeBOaU0WJsISFwemPHscsGSbM0xm5hbvqq9fxb7sYxN2XS9QSFRduLxzmAf2Cn5Tx1BgVAgu9apQDRzKmB5B3DSUNnhD34QO9gx0zwiCeHgdcvGT0w5g84yKC+6FjU9gtPva6prOOIG1CzBAl20lFseMJqW+iDpD+bQe1+rlCNVWR1jx6Uz+JsR7poNCCuD67J+900gGOwfyWTb0swi0zh45zw/ieGgNDNsYbjPkQqYjVO0PgMdZo3zOuGCYxLL9zA0/AkIwoPvPx+WbdYsZrC/1L56vyhf3yKAboh4M9N5R9NBBoGFKiodOWng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=qP/e8os3SWnpSnTKE9F7ira9foXW3jvEmtEaWBG/UfQ=; b=g1HqWf2WHgc3X+R2n7xkus2M3lg12jQWMpSHLOW3w+po3GfI9NJZj0IfQ0bn7BXXRH852r0Hkqbbn1M0HM8fgchMVi1zwO5v9SmXq1PpNk65DFyicscYpboGC1lzaPCsuGvo42kIEQeWisrSIpYkBSB9Cxn6J+bkSh7fd5gAADmJVoARcMRxZlSJt9v2n25f9aFugUIJYYQnY+UKQMXGxDvvW8WBxIHErAJ9PWcq6NwbZVXXWug+RBojthAs8OiIcxudpBCL0lWLFn3xDp6PGLvDPWI6yoOBhjf8U9cKNbpCliHcIfDtF0QEWdKZNBgGIC59s/24s3wXikjJJAxU6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from SN6PR02MB4543.namprd02.prod.outlook.com (2603:10b6:805:b1::24) by SN4PR0201MB3583.namprd02.prod.outlook.com (2603:10b6:803:45::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Thu, 23 Sep 2021 14:45:30 +0000 Received: from SN6PR02MB4543.namprd02.prod.outlook.com ([fe80::992f:b2c5:6a7c:3cfd]) by SN6PR02MB4543.namprd02.prod.outlook.com ([fe80::992f:b2c5:6a7c:3cfd%3]) with mapi id 15.20.4544.015; Thu, 23 Sep 2021 14:45:30 +0000 From: Raphael Norwitz To: "mst@redhat.com" , "peter.maydell@linaro.org" , "eblake@redhat.com" Subject: [PATCH v3] Prevent vhost-user-blk-test hang Thread-Topic: [PATCH v3] Prevent vhost-user-blk-test hang Thread-Index: AQHXsImndLAOcgO8DEuf/MI2vsXIgA== Date: Thu, 23 Sep 2021 14:45:30 +0000 Message-ID: <20210923144520.21873-1-raphael.norwitz@nutanix.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.20.1 authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=nutanix.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ceaf0fc6-d009-429d-9fd9-08d97ea0ca47 x-ms-traffictypediagnostic: SN4PR0201MB3583: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-proofpoint-crosstenant: true x-ms-oob-tlc-oobclassifiers: OLM:773; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xrTSUp7hrnLOAnVzV6aNvRcrCh3ipFlSt6PCSjOYTRabH0Cj3bedGdvYmqQTAx6vivxNtYmMJKqv+dHpb3xJojGu7v/rNmwoJA/MKaVlcZEcfRfPo8/IEiyHjhJ5zBA2QqC1pL7T+uVbJwwhDfnaUwZs5W5xR6R9LJkFDlp/LTtG3+ZE0TnZSUs3lOHwSELn4XeJhCEay+HkK5QzrCKoeGckUrvSKAPIQBAlm0V8b8nHQQ1uRDa/vHGkyDbNFljxg9PKQm+dba+1rukm8dklBZfoyh+yw8fQdqM8WRiNjxFeDXtF3RT0B0n02DX3oVjySv9lVJwAji410TVxuigQEXuEc6Kxdqb4uTdPf49Qmvl0yXIMvOj6RbaFkjJn3+vWOXcDsH/zsfA//CtHD/bC0SKmYZ6sa1GZmKFFeCO9IZm9Bu61pFqsKxbBvoVS4lP688kLIc9S/iQ5cotCvKAdmrWbfqS1o8g8PTXYId8hd3bd6HdUGRf+rCpZhPWbbS93VSucEqJ8ZKURg8Se9vRY80ekSuEArpJvJbtlfWDzBeh1Hshc/F6qi3P/u5uhJCBqHowJbCBhN4frudsO1QngrRKpOxM7Rv0zcMHN9ZWbj/txi57XM8I3FHcgE9B681gBlliFKvAARZ6ElrejK9qabk8GMNAzb5u/rYWdlWAcPamFjcFxQJtSx07fhw+ixpke2oFmcGk9Ux2LzTbNvsdZpup/ycU4g2H+0k2yUynFOtfAP3dxqPQN3Tyym6D1K8ik6YCGa6L1UUjPBIVWZ+h/9SqfqrOmKaaJ6/4dOMg6pN4= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR02MB4543.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(107886003)(44832011)(1076003)(6486002)(71200400001)(86362001)(4326008)(36756003)(6512007)(76116006)(91956017)(66446008)(66556008)(66476007)(26005)(966005)(8676002)(186003)(2616005)(6506007)(110136005)(316002)(38100700002)(54906003)(38070700005)(122000001)(83380400001)(5660300002)(66946007)(8936002)(508600001)(2906002)(64756008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?QVsz/vipjpJBGXL1IkK8rVB?= =?iso-8859-1?q?ZgjNGYR+wuknluXBgF+Cj/jWTDFhG/P4jAxsrph+JfvSp9SEiuHyHGtoNtBO?= =?iso-8859-1?q?W4y9DmIR0qXlnB4kME288rOJ/UHtVDagJuGQ8UvCiP0RFGTe9wr74sGEKUi5?= =?iso-8859-1?q?L8NS/XQN+9+gz5cLegzZUNMl9Kst5koSeFr3dE1ZnhyBQqZLauw84vl6dcwy?= =?iso-8859-1?q?oIHxtZBq33xJRP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SPwZZ50+zo2qJJgfe3bwHui?= =?iso-8859-1?q?VzjN+TqOS9R2flFqnSsNFIVmxUqlNbKGISKq38hDQX8Am9/av8Z50WeM0eu0?= =?iso-8859-1?q?oMTkp5jeYPA1NCnAHSSuZEnX9F3i8jPRTCVS/oT2XNS9iq5mTousOFwTrUb/?= =?iso-8859-1?q?60NDgo0RI+CgpsTFtAl3zvLTST/6E8w0OeS3eyc56PWgLU8DRgpfiU4MnZc0?= =?iso-8859-1?q?YppxELrbwRDpY9jRENZqIf1kHTS++ZDi4Owm/0MOMNNEAPO+3WeMecF5d5ym?= =?iso-8859-1?q?H?= MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR02MB4543.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ceaf0fc6-d009-429d-9fd9-08d97ea0ca47 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Sep 2021 14:45:30.1755 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: cCc9Dv1b8WjgIF+6svujoA7y0hmPp5AZ9rGZMXQ3zSXc1kdb3/TCAoIjHI2KXJaFTtquWqsgqZKQJP+zdPcOZdITZ9VbLsQiX3Wwy6rlIf4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0201MB3583 X-Proofpoint-GUID: KuJGhAeA03nI8DtvQEhTnQ4UqD9H4E6u X-Proofpoint-ORIG-GUID: KuJGhAeA03nI8DtvQEhTnQ4UqD9H4E6u X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-23_04,2021-09-23_01,2020-04-07_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.151.68; envelope-from=raphael.norwitz@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.473, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "qemu-devel@nongnu.org" , Raphael Norwitz , "stefanha@redhat.com" , "pbonzini@redhat.com" , "mreitz@redhat.com" , "sgarzare@redhat.com" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In the vhost-user-blk-test, as of now there is nothing stoping vhost-user-blk in QEMU writing to the socket right after forking off the storage daemon before it has a chance to come up properly, leaving the test hanging forever. This intermittently hanging test has caused QEMU automation failures reported multiple times on the mailing list [1]. This change makes the storage-daemon notify the vhost-user-blk-test that it is fully initialized and ready to handle client connections by creating a pidfile on initialiation. This ensures that the storage-daemon backend won't miss vhost-user messages and thereby resolves the hang. [1] https://lore.kernel.org/qemu-devel/CAFEAcA8kYpz9LiPNxnWJAPSjc=nv532bEdyfynaBeMeohqBp3A@mail.gmail.com/ Signed-off-by: Raphael Norwitz --- tests/qtest/vhost-user-blk-test.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk-test.c index 6f108a1b62..0e26266522 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -24,6 +24,7 @@ #define TEST_IMAGE_SIZE (64 * 1024 * 1024) #define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000) #define PCI_SLOT_HP 0x06 +#define PIDFILE_RETRIES 5 typedef struct { pid_t pid; @@ -885,7 +886,8 @@ static void start_vhost_user_blk(GString *cmd_line, int vus_instances, int num_queues) { const char *vhost_user_blk_bin = qtest_qemu_storage_daemon_binary(); - int i; + int i, retries; + char *daemon_pidfile_path; gchar *img_path; GString *storage_daemon_command = g_string_new(NULL); QemuStorageDaemonState *qsd; @@ -898,6 +900,9 @@ static void start_vhost_user_blk(GString *cmd_line, int vus_instances, " -object memory-backend-memfd,id=mem,size=256M,share=on " " -M memory-backend=mem -m 256M "); + daemon_pidfile_path = g_strdup_printf("/tmp/daemon-%d", getpid()); + g_assert_cmpint((uintptr_t) daemon_pidfile_path, !=, (uintptr_t) NULL); + for (i = 0; i < vus_instances; i++) { int fd; char *sock_path = create_listen_socket(&fd); @@ -914,6 +919,9 @@ static void start_vhost_user_blk(GString *cmd_line, int vus_instances, i + 1, sock_path); } + g_string_append_printf(storage_daemon_command, "--pidfile %s ", + daemon_pidfile_path); + g_test_message("starting vhost-user backend: %s", storage_daemon_command->str); pid_t pid = fork(); @@ -930,7 +938,24 @@ static void start_vhost_user_blk(GString *cmd_line, int vus_instances, execlp("/bin/sh", "sh", "-c", storage_daemon_command->str, NULL); exit(1); } + + /* + * Ensure the storage-daemon has come up properly before allowing the + * test to proceed. + */ + retries = 0; + while (access(daemon_pidfile_path, F_OK) != 0) { + g_assert_cmpint(retries, <, PIDFILE_RETRIES); + + retries++; + g_usleep(1000); + } + g_string_free(storage_daemon_command, true); + if (access(daemon_pidfile_path, F_OK) == 0) { + unlink(daemon_pidfile_path); + } + free(daemon_pidfile_path); qsd = g_new(QemuStorageDaemonState, 1); qsd->pid = pid;