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=-10.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 0E506C2D0A3 for ; Tue, 3 Nov 2020 16:37:34 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 3739B2072C for ; Tue, 3 Nov 2020 16:37:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="kitY2I9a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3739B2072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4CQb6f0C3czDqdw for ; Wed, 4 Nov 2020 03:37:30 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=shawnmm@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=kitY2I9a; dkim-atps=neutral Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4CQb4p2zTYzDqXR for ; Wed, 4 Nov 2020 03:35:50 +1100 (AEDT) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0A3GVEIh120712 for ; Tue, 3 Nov 2020 11:35:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=to : from : subject : message-id : date : mime-version : content-type : content-transfer-encoding; s=pp1; bh=GUIcclGfVMtXGTDmZkgTBrCrygmeUHAyIG2IJnwDxOk=; b=kitY2I9aKO2gtnJXZKecVKqGhElU0jW0NoavrKF3nZytDsi7OZ+9PnZTHZ4OKodEwnQ+ vybLNkV21LwhTkLo4glslsXu6g6h1JuW6bVZZJvrYndOhetslryT5AMpsxgCtOJMU0lN hbvUOEEB5/OP9hSBuzMc7thWXvbc1tWIHwwVd1B3fuUEd3dZUhJOq5+L6T/sySwb6fkT B8dRxUSpMEvDPLC1KQcX1fy5TcVtnnviwewCTiOjBTeo7NKcn6IvV8AN8edDFOodJkg2 B7oHfscehN6+AHoNyRmI4wyGXMxNg2wgF4HDSvW4/dQcybVh9U4JFT8+NOPV9LiVN9Kw wQ== Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 34k9bwmhws-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Nov 2020 11:35:48 -0500 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0A3GWCnY000687 for ; Tue, 3 Nov 2020 16:35:47 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma02wdc.us.ibm.com with ESMTP id 34h0evy5tv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Nov 2020 16:35:47 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0A3GZk8X14615228 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 3 Nov 2020 16:35:46 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44B0478067 for ; Tue, 3 Nov 2020 16:35:46 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 241DB78063 for ; Tue, 3 Nov 2020 16:35:46 +0000 (GMT) Received: from [9.211.76.180] (unknown [9.211.76.180]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP for ; Tue, 3 Nov 2020 16:35:45 +0000 (GMT) To: openbmc@lists.ozlabs.org From: Shawn McCarney Subject: Easier way to create error logs with FFDC Message-ID: <335508c6-a7be-a161-71fb-b0502418dd5b@linux.vnet.ibm.com> Date: Tue, 3 Nov 2020 10:35:46 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-03_08:2020-11-03, 2020-11-03 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1011 bulkscore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=883 mlxscore=0 priorityscore=1501 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011030108 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Sender: "openbmc" Hi, The D-Bus method CreateWithFFDCFiles can be used to create error log entries with First Failure Data Capture (FFDC) information. See https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Logging/Create.interface.yaml#L32 Using this D-Bus method is a bit tricky because you need to pass in file descriptors to temporary files containing the FFDC data. So you need to create the temporary files with sufficiently unique names, and after the method is complete you need to close the file descriptors and delete the temporary files.  Obviously cleanup needs to happen on both good paths and error/exception paths.  If you have multiple FFDC files, you also need safe move semantics to put the information in a standard collection like vector. I wrote a C++ class named FFDCFile to make calling this D-Bus method simpler.  It handles the problems above and has gtests to test it.  You can see the code here: https://github.com/openbmc/phosphor-power/blob/master/phosphor-regulators/src/ffdc_file.hpp .  It uses TemporaryFile and FileDescriptor utility classes. Would there be interest it making this available in the phosphor-logging repository so it could be used by others? Thanks, Shawn