From nobody Wed May 8 02:56:16 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=1591628809; cv=none; d=zohomail.com; s=zohoarc; b=XtepOgJU0PCCnOB0Sk2kcHYPt085mCtfkLaPJx+pD86cdSEsu2pxTvADA0Edce/rG5liF56r5bqj9uJmhyRBK9OpL/pWgzcusbnY6K3h2cNFrT60J3IuwylAX0HlfiYPs/l/2HIjh1/g76AnMcfcwTxgsYz12Ti78q6KJ7y6QPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591628809; 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=G0+m7Ys5uoKrL97UpPP3emGftcU+m4LMHHlBCz3C31I=; b=MBzGwL+9Qisc5FcISRFeMgb/wX6JccueS/jKVl9uhJgNz1WLHUMeQOPvqFZ0gyV16nptIK1pdMntqgTzGa6YBDdJDs+wd+Pgk3XreXnBeEJGNqKGz+rkVDOyICyVdsC8dj1briGuIrayqeBInpwKFb4vIchrCHB5O7cWYmqgWXw= 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 1591628809308987.5636205164604; Mon, 8 Jun 2020 08:06:49 -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-330-fv9EMG4LN9iRM7lWp1tXbA-1; Mon, 08 Jun 2020 11:06:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41BA4835B44; Mon, 8 Jun 2020 15:06:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 231C35C1C5; Mon, 8 Jun 2020 15:06:35 +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 E8A1C1809557; Mon, 8 Jun 2020 15:06:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 058F6Qul004814 for ; Mon, 8 Jun 2020 11:06:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54B1310013D4; Mon, 8 Jun 2020 15:06:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8BAB10013C1 for ; Mon, 8 Jun 2020 15:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591628808; 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=G0+m7Ys5uoKrL97UpPP3emGftcU+m4LMHHlBCz3C31I=; b=B1jhM6S7dMUYF1jp4lPLJTEZGPtdM9+3t6Zs33v3lOBp6DyMcleEGSpKl+a9+x+rdcs69Y zPhMYZW31gR+LppF3pFBoGw4bM0vhyxYrzUu9WspSWAOqNZob7Aop/965onj5/u3DGTisb RC5zyvJmnlyQPqMPLiqpXF1ZD43L6ns= X-MC-Unique: fv9EMG4LN9iRM7lWp1tXbA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 1/7] virSysinfoReadDMI: Use more g_auto*() Date: Mon, 8 Jun 2020 17:06:15 +0200 Message-Id: <5dda83a06f9060b7028f482a10b38e07cc0533b7.1591628594.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.16 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" Virtually every variable defined in the function can be freed automatically when going out of scope. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virsysinfo.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 41f4d1cff9..296a2e2cc1 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -1119,10 +1119,10 @@ virSysinfoParseX86Memory(const char *base, virSysin= foDefPtr ret) virSysinfoDefPtr virSysinfoReadDMI(void) { - char *path; - virSysinfoDefPtr ret =3D NULL; - char *outbuf =3D NULL; - virCommandPtr cmd; + g_autofree char *path =3D NULL; + g_auto(virSysinfoDefPtr) ret =3D NULL; + g_autofree char *outbuf =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; =20 path =3D virFindFileInPath(SYSINFO_SMBIOS_DECODER); if (path =3D=3D NULL) { @@ -1133,48 +1133,38 @@ virSysinfoReadDMI(void) } =20 cmd =3D virCommandNewArgList(path, "-q", "-t", "0,1,2,3,4,17", NULL); - VIR_FREE(path); virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return NULL; =20 if (VIR_ALLOC(ret) < 0) - goto error; + return NULL; =20 ret->type =3D VIR_SYSINFO_SMBIOS; =20 if (virSysinfoParseBIOS(outbuf, &ret->bios) < 0) - goto error; + return NULL; =20 if (virSysinfoParseX86System(outbuf, &ret->system) < 0) - goto error; + return NULL; =20 if (virSysinfoParseX86BaseBoard(outbuf, &ret->baseBoard, &ret->nbaseBo= ard) < 0) - goto error; + return NULL; =20 if (virSysinfoParseX86Chassis(outbuf, &ret->chassis) < 0) - goto error; + return NULL; =20 ret->nprocessor =3D 0; ret->processor =3D NULL; if (virSysinfoParseX86Processor(outbuf, ret) < 0) - goto error; + return NULL; =20 ret->nmemory =3D 0; ret->memory =3D NULL; if (virSysinfoParseX86Memory(outbuf, ret) < 0) - goto error; + return NULL; =20 - cleanup: - VIR_FREE(outbuf); - virCommandFree(cmd); - - return ret; - - error: - virSysinfoDefFree(ret); - ret =3D NULL; - goto cleanup; + return g_steal_pointer(&ret); } =20 =20 --=20 2.26.2 From nobody Wed May 8 02:56:16 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=1591628810; cv=none; d=zohomail.com; s=zohoarc; b=cjl/wuoyUJT7gXdDNGVdXq8qyrjPld4TqD/Ny802OD+pjtM0MAm8MWNaYiV+8t9JUb7hGSaUOJC+05o3cPZubJH/PMfl7MhOXQPFp0QSKlYi3azRnEtvLSQ/AaFkSnDyBrw0W2+VXodFaTVNSfK0+TQt94pf4Z/103ibLLgGLxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591628810; 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=lM+2BM7mx8IjN7XvnBUNKL0nAg4txPUZnP/O8d8yqMA=; b=cSTSMFl+IEOrlOSlsa5dVI9odenpbStuYUhyKgAlmDlfI2sijo2QuUQpBkh/zHdHCf2Jfn1QifHZQPXxbUZ/A57NwnCkpgUtfnkn0Sb+O01wggpeTCIWsn0ZrsS5EHOStU6Ln/0Te3wIG61jjMHVvjVW4ETKq6Dhs+Xfs+cMO78= 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 1591628810663593.8622210964603; Mon, 8 Jun 2020 08:06:50 -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-214-A7F2iSE0PciA3y8baUpiLA-1; Mon, 08 Jun 2020 11:06:34 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8542E18A072C; Mon, 8 Jun 2020 15:06:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64B5D2B4D3; Mon, 8 Jun 2020 15:06:29 +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 D5C361809547; Mon, 8 Jun 2020 15:06:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 058F6RiU004829 for ; Mon, 8 Jun 2020 11:06:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 34AE510013D4; Mon, 8 Jun 2020 15:06:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8A4A10013C1 for ; Mon, 8 Jun 2020 15:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591628809; 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=lM+2BM7mx8IjN7XvnBUNKL0nAg4txPUZnP/O8d8yqMA=; b=QAL3Qiedz5bq4E1r2o8ygVQlIUZD2HHq2DDX+e9HHmXQpKZ2slZbwWsoS7dLQvAsKIiryy RWxfWUXdA92iZ9l1I0PIlFOon9moEFvtRbTxSfWsdrDEoCrddLBEqGDGMzLyZ1uHzEVMCq oe7UR9beGWWyhu0DccBMH7D9HdmX5PQ= X-MC-Unique: A7F2iSE0PciA3y8baUpiLA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 2/7] virSysinfoReadDMI: Drop needless virFindFileInPath() Date: Mon, 8 Jun 2020 17:06:16 +0200 Message-Id: <7999154c6f34f51eab5ecae58c28e0ab4c0d4c49.1591628594.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.23 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" When trying to decode DMI table, just before constructing virCommand() the decoder is looked for in PATH using virFindFileInPath(). Well, this is not necessary because virCommandRun() will do this too (in virExec()). Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virsysinfo.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 296a2e2cc1..0f1210ab37 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -1119,20 +1119,12 @@ virSysinfoParseX86Memory(const char *base, virSysin= foDefPtr ret) virSysinfoDefPtr virSysinfoReadDMI(void) { - g_autofree char *path =3D NULL; g_auto(virSysinfoDefPtr) ret =3D NULL; g_autofree char *outbuf =3D NULL; g_autoptr(virCommand) cmd =3D NULL; =20 - path =3D virFindFileInPath(SYSINFO_SMBIOS_DECODER); - if (path =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to find path for %s binary"), - SYSINFO_SMBIOS_DECODER); - return NULL; - } - - cmd =3D virCommandNewArgList(path, "-q", "-t", "0,1,2,3,4,17", NULL); + cmd =3D virCommandNewArgList(SYSINFO_SMBIOS_DECODER, + "-q", "-t", "0,1,2,3,4,17", NULL); virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, NULL) < 0) return NULL; --=20 2.26.2 From nobody Wed May 8 02:56:16 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=1591628825; cv=none; d=zohomail.com; s=zohoarc; b=Upn0t8xdZD9YurcSVjPiYy2+TzQMvfvanXVb1qmF13PPdmfhRO2VTxsEV3Bp+cxcbhHKI2CQG927JZlJUcHs+HBjRr98nH9f+UCxX11ohNow6xlGnmNB9w0H175dXK0BdrEEhE2fQF2d7bsK3hOVpex6J9NaGyBBY0vmWvyoYd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591628825; 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=Px57Bu/MgJEI6dTHZQtPtdmJhndQwCK4ORuOwTYwJM0=; b=I2/AVWZXRrCKmk+ybCNCiEk9rDmK2nM+3A1El2OBQakgzTVnA//ZxsARgcPq5+O5TrzXiVDvrwRg50Hr/x5lIEn4O/UfXb2ZgRh6Mgc+MOPlPR+GZek8NRESFXccTrhiWYzchkPW1eOcgg4uR0eyzjPWaIbPSrCt9+3bMAk9iWE= 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 1591628825338772.269723788065; Mon, 8 Jun 2020 08:07:05 -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-391-8HNR1fu6M2OxOX0Y11Jk-w-1; Mon, 08 Jun 2020 11:06:41 -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 306C518A0724; Mon, 8 Jun 2020 15:06:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1320E79598; Mon, 8 Jun 2020 15:06:36 +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 D787E1809563; Mon, 8 Jun 2020 15:06:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 058F6S1q004836 for ; Mon, 8 Jun 2020 11:06:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1449410013D4; Mon, 8 Jun 2020 15:06:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87DF810013C1 for ; Mon, 8 Jun 2020 15:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591628823; 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=Px57Bu/MgJEI6dTHZQtPtdmJhndQwCK4ORuOwTYwJM0=; b=ZE6XjrBSvZgMMg/34a8jo/32xi0sswt5z8moFNaBEjKlLKNgcnGYJeBbkXRe+Gf4WF2EqB kjYQp9TcfLeg3LJwd4JF1OJR9NubuPiZ8MihcA37tSfrV70SsK5u1rGsYgmRf+qMQ7LKxM nDbhCxrD3x2SOrLjwJ36jSZHGQe9F3k= X-MC-Unique: 8HNR1fu6M2OxOX0Y11Jk-w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 3/7] testSysinfo: Use more g_auto*() Date: Mon, 8 Jun 2020 17:06:17 +0200 Message-Id: <862d74e07847f9a9d63cf72b539ea0adcdd7777d.1591628594.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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" Some variables defined in the function can be freed automatically when going out of scope. This renders @result variable and cleanup label needless. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/sysinfotest.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c index a8a0d0869e..4807c5b1ba 100644 --- a/tests/sysinfotest.c +++ b/tests/sysinfotest.c @@ -47,34 +47,24 @@ struct testSysinfoData { static int testSysinfo(const void *data) { - int result =3D -1; const char *sysfsActualData; - virSysinfoDefPtr ret =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virSysinfoDefPtr) ret =3D NULL; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const struct testSysinfoData *testdata =3D data; =20 virSysinfoSetup(testdata->decoder, testdata->sysinfo, testdata->cpuinf= o); =20 if (!testdata->expected || !(ret =3D testdata->func())) - goto cleanup; + return -1; =20 if (virSysinfoFormat(&buf, ret) < 0) - goto cleanup; + return -1; =20 if (!(sysfsActualData =3D virBufferCurrentContent(&buf))) - goto cleanup; + return -1; =20 - if (virTestCompareToFile(sysfsActualData, testdata->expected) < 0) - goto cleanup; - - result =3D 0; - - cleanup: - virSysinfoDefFree(ret); - virBufferFreeAndReset(&buf); - - return result; + return virTestCompareToFile(sysfsActualData, testdata->expected); } =20 static int --=20 2.26.2 From nobody Wed May 8 02:56:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 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=1591628812; cv=none; d=zohomail.com; s=zohoarc; b=nI5Fi6W/P+TcNfsU821Hg61DOrfwwcvAPFpqEv+l0takMf8+5+63SpFOsqrut24vpTy3dHb6ZzCE2+n+EqXoOO2t663IdutygWfjf7Q5IAsH1fAk4JtCP34F9QNADXHhHazOLHMB0p/6Q4BcQnGausaLo9w3L3i/vN9xw053jdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591628812; 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=fLBFWmBvBKFhtJUIT8AkIayprCrLIIMmltXa3YADNLY=; b=la3/OQvlIyIy6VYzWxsnLR58mY1+qinw86hd/KX3cQDL8NOgXW+5xHsMgPSnLsGRUCVq7L+QZWUnspeg642yOGQf1tYpbaPEFRJ2YDlmBzEnVvf+eenTYReEs48eGU2hp3liH2ymDZ0KLCmsIqYCkFvqJl8buFxmo939OeBtLso= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1591628812457816.9957216300749; Mon, 8 Jun 2020 08:06:52 -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-235-5qRRnpqZNt65UT5CCdHlPA-1; Mon, 08 Jun 2020 11:06:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F00F8018A5; Mon, 8 Jun 2020 15:06:38 +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 5E101891E6; Mon, 8 Jun 2020 15:06:38 +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 2E1DAADABD; Mon, 8 Jun 2020 15:06:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 058F6SCW004846 for ; Mon, 8 Jun 2020 11:06:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id E7F8A10013D4; Mon, 8 Jun 2020 15:06:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67E2710013C1 for ; Mon, 8 Jun 2020 15:06:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591628811; 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=fLBFWmBvBKFhtJUIT8AkIayprCrLIIMmltXa3YADNLY=; b=Sh2liN96s29+q9Uud4yTR4qRs6NJKbAeFeyYxxqh5OWfUzrvjFl0DN8CZi8RXqTR2Q9dkW R+DiIDtWeBCglIjl3DTse5NcE+PeUH6rX8oHqyK+vlXcUi3czpf1bLPWfyB3HpwKbsDYoC nZiXRn6+8hf2sai1zo6M3FnhT2bLTaQ= X-MC-Unique: 5qRRnpqZNt65UT5CCdHlPA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 4/7] sysinfotest: Dissolve sysinfotest_run() in testSysinfo() Date: Mon, 8 Jun 2020 17:06:18 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.13 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" There is no real need to have two separate functions. They can be merged together which not only saves couple of lines, but prepares the structure of the code for future expansion. See next commits. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/sysinfotest.c | 70 ++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 48 deletions(-) diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c index 4807c5b1ba..558dd60294 100644 --- a/tests/sysinfotest.c +++ b/tests/sysinfotest.c @@ -37,25 +37,33 @@ #define VIR_FROM_THIS VIR_FROM_NONE =20 struct testSysinfoData { + const char *name; /* test name, also base name for result files */ virSysinfoDefPtr (*func)(void); /* sysinfo gathering function */ - char *decoder; /* name of dmi decoder binary/script */ - char *sysinfo; /* name of /proc/sysinfo substitute file */ - char *cpuinfo; /* name of /proc/cpuinfo substitute file */ - char *expected; /* (required) file containing output of virSysinfoForm= at */ + const char *decoder; /* name of dmi decoder binary/script */ }; =20 static int testSysinfo(const void *data) { + const struct testSysinfoData *testdata =3D data; const char *sysfsActualData; g_auto(virSysinfoDefPtr) ret =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - const struct testSysinfoData *testdata =3D data; + g_autofree char *sysinfo =3D NULL; + g_autofree char *cpuinfo =3D NULL; + g_autofree char *expected =3D NULL; + g_autofree char *decoder =3D NULL; =20 - virSysinfoSetup(testdata->decoder, testdata->sysinfo, testdata->cpuinf= o); + sysinfo =3D g_strdup_printf("%s/sysinfodata/%ssysinfo.data", abs_srcdi= r, testdata->name); + cpuinfo =3D g_strdup_printf("%s/sysinfodata/%scpuinfo.data", abs_srcdi= r, testdata->name); + expected =3D g_strdup_printf("%s/sysinfodata/%ssysinfo.expect", abs_sr= cdir, testdata->name); =20 - if (!testdata->expected || - !(ret =3D testdata->func())) + if (testdata->decoder) + decoder =3D g_strdup_printf("%s/%s", abs_srcdir, testdata->decoder= ); + + virSysinfoSetup(decoder, sysinfo, cpuinfo); + + if (!(ret =3D testdata->func())) return -1; =20 if (virSysinfoFormat(&buf, ret) < 0) @@ -64,50 +72,16 @@ testSysinfo(const void *data) if (!(sysfsActualData =3D virBufferCurrentContent(&buf))) return -1; =20 - return virTestCompareToFile(sysfsActualData, testdata->expected); + return virTestCompareToFile(sysfsActualData, expected); } =20 -static int -sysinfotest_run(const char *test, - virSysinfoDefPtr (*func)(void), - const char *decoder, - const char *sysinfo, - const char *cpuinfo, - const char *expected) -{ - struct testSysinfoData testdata =3D { 0 }; - int ret =3D EXIT_FAILURE; - - testdata.func =3D func; - - if (decoder) - testdata.decoder =3D g_strdup_printf("%s/%s", abs_srcdir, decoder); - if (sysinfo) - testdata.sysinfo =3D g_strdup_printf("%s/%s", abs_srcdir, sysinfo); - if (cpuinfo) - testdata.cpuinfo =3D g_strdup_printf("%s/%s", abs_srcdir, cpuinfo); - if (expected) - testdata.expected =3D g_strdup_printf("%s/%s", abs_srcdir, expecte= d); - - if (virTestRun(test, testSysinfo, &testdata) < 0) - goto error; - - ret =3D EXIT_SUCCESS; - - error: - VIR_FREE(testdata.decoder); - VIR_FREE(testdata.sysinfo); - VIR_FREE(testdata.cpuinfo); - VIR_FREE(testdata.expected); - return ret; -} =20 #define TEST_FULL(name, func, decoder) \ - if (sysinfotest_run(name " sysinfo", func, decoder, \ - "/sysinfodata/" name "sysinfo.data", \ - "/sysinfodata/" name "cpuinfo.data", \ - "/sysinfodata/" name "sysinfo.expect") !=3D EXIT_S= UCCESS) \ - ret =3D EXIT_FAILURE + do { \ + struct testSysinfoData data =3D { name, func, decoder }; \ + if (virTestRun(name " sysinfo", testSysinfo, &data) < 0) \ + ret =3D EXIT_FAILURE; \ + } while (0) =20 =20 #define TEST(name, func) \ --=20 2.26.2 From nobody Wed May 8 02:56:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1591629005; cv=none; d=zohomail.com; s=zohoarc; b=gmYlV8YFL+GnDbv8+Uw6aR2ugeIaXbrJdjZqeRqExexbaZawmRHHY/uMUZFV7PUSWErXS1nc7CKQ/IEcFJd0ubavGWD53dEWXJ2T+HOguAvgcdm/VWNknTIQ8Brs0FKQzXKp2qHYOnIqaGLcDLlFB0bp1RA/A8j+ExJbFHCINxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591629005; 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=A5Vr1N+Hq5BHFsHt+ceaFOiXsLhtrw9VUFrqwgo79kg=; b=FnqyOlY4uuMknKWzk+XYkl+OSaprHmHmrdXR75ipC+Lb2Tk+qsRJMzO+3vbYsuAeMywx7qulyBGq4bbAWNi1CET/MwNB9Xwy2LGuwKn5eIaHHB+NR+WM8TRGpGZlAG/xnv6DAK5+SH/ydiDWG5W0SMPV/kKkz/u371DUE46lC7k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1591629005154730.6760737364277; Mon, 8 Jun 2020 08:10:05 -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-351-8FZcuKaUOvGDZXXhy2kcqQ-1; Mon, 08 Jun 2020 11:10:01 -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 E3644108BD0E; Mon, 8 Jun 2020 15:09:55 +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 A045C61169; Mon, 8 Jun 2020 15:09:55 +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 27D94ADABD; Mon, 8 Jun 2020 15:09:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 058F6T5s004851 for ; Mon, 8 Jun 2020 11:06:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id C875A10013D4; Mon, 8 Jun 2020 15:06:29 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47E8810013C1 for ; Mon, 8 Jun 2020 15:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591629003; 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=A5Vr1N+Hq5BHFsHt+ceaFOiXsLhtrw9VUFrqwgo79kg=; b=NAUdy01v7JANClBjGLw3qn9X7PddZEvTEg+73IjT9IXWZoE0o8mB6Zv8RcHeVE7H92flb+ FvB8jRXns/Tug5t6qUzNYd6zolyfET6NUPqFW7bgAgeFDZeC+Et0dqsfAx7AuxArcWe6Jl fYUlwFxQRChhp+Vxxle3qamB0ndMJsM= X-MC-Unique: 8FZcuKaUOvGDZXXhy2kcqQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 5/7] sysinfotest: Move from custom dmidecode scripts to virCommandSetDryRun() Date: Mon, 8 Jun 2020 17:06:19 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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" Problem with custom dmidecode scripts is that they are hard to modify, especially if we will want them to act differently based on passed arguments. So far, we have two scripts which do no more than 'cat $sysinfo' where $sysinfo is saved dmidecode output. The virCommandSetDryRun() can be used to trick virSysinfoReadDMI() thinking it executed real dmidecode. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virsysinfo.c | 3 +- .../sysinfodata/aarch64-gigabytedmidecode.sh | 3 -- tests/sysinfodata/x86dmidecode.sh | 3 -- tests/sysinfotest.c | 51 +++++++++++++------ 4 files changed, 38 insertions(+), 22 deletions(-) delete mode 100755 tests/sysinfodata/aarch64-gigabytedmidecode.sh delete mode 100755 tests/sysinfodata/x86dmidecode.sh diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 0f1210ab37..0bf80c339b 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -60,7 +60,8 @@ virSysinfoSetup(const char *dmidecode, const char *sysinfo, const char *cpuinfo) { - sysinfoDmidecode =3D dmidecode; + if (dmidecode) + sysinfoDmidecode =3D dmidecode; sysinfoSysinfo =3D sysinfo; sysinfoCpuinfo =3D cpuinfo; } diff --git a/tests/sysinfodata/aarch64-gigabytedmidecode.sh b/tests/sysinfo= data/aarch64-gigabytedmidecode.sh deleted file mode 100755 index 202918103c..0000000000 --- a/tests/sysinfodata/aarch64-gigabytedmidecode.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -DATAFILE=3D`dirname $0`/aarch64-gigabytesysinfo.data -cat $DATAFILE diff --git a/tests/sysinfodata/x86dmidecode.sh b/tests/sysinfodata/x86dmide= code.sh deleted file mode 100755 index 28aed61459..0000000000 --- a/tests/sysinfodata/x86dmidecode.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -DATAFILE=3D`dirname $0`/x86sysinfo.data -cat $DATAFILE diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c index 558dd60294..f080569730 100644 --- a/tests/sysinfotest.c +++ b/tests/sysinfotest.c @@ -34,14 +34,39 @@ #define LIBVIRT_VIRSYSINFOPRIV_H_ALLOW #include "virsysinfopriv.h" =20 +#define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW +#include "vircommandpriv.h" + #define VIR_FROM_THIS VIR_FROM_NONE =20 struct testSysinfoData { const char *name; /* test name, also base name for result files */ virSysinfoDefPtr (*func)(void); /* sysinfo gathering function */ - const char *decoder; /* name of dmi decoder binary/script */ }; =20 + +static void +testDMIDecodeDryRun(const char *const*args G_GNUC_UNUSED, + const char *const*env G_GNUC_UNUSED, + const char *input G_GNUC_UNUSED, + char **output, + char **error, + int *status, + void *opaque) +{ + const char *sysinfo =3D opaque; + + if (virFileReadAll(sysinfo, 10 * 1024 * 1024, output) < 0) { + *error =3D g_strdup(virGetLastErrorMessage()); + *status =3D EXIT_FAILURE; + return; + } + + *error =3D g_strdup(""); + *status =3D 0; +} + + static int testSysinfo(const void *data) { @@ -52,18 +77,19 @@ testSysinfo(const void *data) g_autofree char *sysinfo =3D NULL; g_autofree char *cpuinfo =3D NULL; g_autofree char *expected =3D NULL; - g_autofree char *decoder =3D NULL; =20 sysinfo =3D g_strdup_printf("%s/sysinfodata/%ssysinfo.data", abs_srcdi= r, testdata->name); cpuinfo =3D g_strdup_printf("%s/sysinfodata/%scpuinfo.data", abs_srcdi= r, testdata->name); expected =3D g_strdup_printf("%s/sysinfodata/%ssysinfo.expect", abs_sr= cdir, testdata->name); =20 - if (testdata->decoder) - decoder =3D g_strdup_printf("%s/%s", abs_srcdir, testdata->decoder= ); + virCommandSetDryRun(NULL, testDMIDecodeDryRun, sysinfo); =20 - virSysinfoSetup(decoder, sysinfo, cpuinfo); + virSysinfoSetup(NULL, sysinfo, cpuinfo); =20 - if (!(ret =3D testdata->func())) + ret =3D testdata->func(); + virCommandSetDryRun(NULL, NULL, NULL); + + if (!ret) return -1; =20 if (virSysinfoFormat(&buf, ret) < 0) @@ -76,17 +102,13 @@ testSysinfo(const void *data) } =20 =20 -#define TEST_FULL(name, func, decoder) \ +#define TEST(name, func) \ do { \ - struct testSysinfoData data =3D { name, func, decoder }; \ + struct testSysinfoData data =3D { name, func }; \ if (virTestRun(name " sysinfo", testSysinfo, &data) < 0) \ ret =3D EXIT_FAILURE; \ } while (0) =20 - -#define TEST(name, func) \ - TEST_FULL(name, func, NULL) - static int mymain(void) { @@ -95,13 +117,12 @@ mymain(void) TEST("s390", virSysinfoReadS390); TEST("s390-freq", virSysinfoReadS390); TEST("ppc", virSysinfoReadPPC); - TEST_FULL("x86", virSysinfoReadDMI, "/sysinfodata/x86dmidecode.sh"); + TEST("x86", virSysinfoReadDMI); TEST("arm", virSysinfoReadARM); TEST("arm-rpi2", virSysinfoReadARM); TEST("aarch64", virSysinfoReadARM); TEST("aarch64-moonshot", virSysinfoReadARM); - TEST_FULL("aarch64-gigabyte", virSysinfoReadARM, - "/sysinfodata/aarch64-gigabytedmidecode.sh"); + TEST("aarch64-gigabyte", virSysinfoReadARM); =20 return ret; } --=20 2.26.2 From nobody Wed May 8 02:56:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1591629064; cv=none; d=zohomail.com; s=zohoarc; b=gzG7CFaYxbwZ/Otnh+WShfmy5BLUeCSpMdX3Ajy9TaDTnDu/+YaMO4MZupOaxswuuQ1uYAs4jo0Mf33BLOv8K+4FMae+4Mq/Pjj33s3cxaHZlO6D172qJgs6x14BKEHbpGJBh3Xya24CSmxLIli1OuKZB2c9o/a6CcMd40/O9nM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591629064; 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=UNvoHBlszDAok8xM995lFMXlpAaClR8JRlqpI6X5wCE=; b=XIXRUPk3/436htF0AqOVlxwo8HT5kqcWUL+MPQ8zCh8dW78dD7xVM+6XwyOEkBVZnF4vcnSaxxR7cuupTlnBK/tuzwoU/XMo4AVGiAkIPYSHo6n52cdb7I5rb4uFg8t0XTC9PjlCHimxYte1hIDRE67lnJG8i8tCmR0iRJxPj30= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1591629064964299.2820767698313; Mon, 8 Jun 2020 08:11:04 -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-314-2uIq1-99M-KPCBRth2o0sQ-1; Mon, 08 Jun 2020 11:10:08 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A3018018A7; Mon, 8 Jun 2020 15:09:59 +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 5CFFF648C9; Mon, 8 Jun 2020 15:09:59 +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 30C3EB348A; Mon, 8 Jun 2020 15:09:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 058F6UfN004856 for ; Mon, 8 Jun 2020 11:06:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id A8B1210013D4; Mon, 8 Jun 2020 15:06:30 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2890710013C1 for ; Mon, 8 Jun 2020 15:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591629063; 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=UNvoHBlszDAok8xM995lFMXlpAaClR8JRlqpI6X5wCE=; b=hVu0x3qfpMwtAGB1xBvf2+szZNZTwnyxFf+yUo2AQutgKHjxEC+Vb0PsJTH81Z3IZfJ+zb tBJu5sQ7RCQc1iLRzI2CLHFkKxcrKl0qG9etYu1EFRHF3oOK7hlwgyLwRhLt2PrzQOqtvd 8ppcMDm6VkgfMx0lTgg98SBgSxA+hk8= X-MC-Unique: 2uIq1-99M-KPCBRth2o0sQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 6/7] virsysinfo: Drop global @sysinfoDmidecode Date: Mon, 8 Jun 2020 17:06:20 +0200 Message-Id: <113487746cc507e0f50190f6add1a273dbc16108.1591628594.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.13 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" Since nobody sets custom dmidecode path anymore, we can drop all code that exists only because of that. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virsysinfo.c | 10 ++-------- src/util/virsysinfopriv.h | 3 +-- tests/sysinfotest.c | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 0bf80c339b..a26c27e83e 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -45,23 +45,18 @@ VIR_ENUM_IMPL(virSysinfo, "smbios", ); =20 -static const char *sysinfoDmidecode =3D DMIDECODE; static const char *sysinfoSysinfo =3D "/proc/sysinfo"; static const char *sysinfoCpuinfo =3D "/proc/cpuinfo"; =20 -#define SYSINFO_SMBIOS_DECODER sysinfoDmidecode #define SYSINFO sysinfoSysinfo #define CPUINFO sysinfoCpuinfo #define CPUINFO_FILE_LEN (1024*1024) /* 1MB limit for /proc/cpuinfo fil= e */ =20 =20 void -virSysinfoSetup(const char *dmidecode, - const char *sysinfo, +virSysinfoSetup(const char *sysinfo, const char *cpuinfo) { - if (dmidecode) - sysinfoDmidecode =3D dmidecode; sysinfoSysinfo =3D sysinfo; sysinfoCpuinfo =3D cpuinfo; } @@ -1124,8 +1119,7 @@ virSysinfoReadDMI(void) g_autofree char *outbuf =3D NULL; g_autoptr(virCommand) cmd =3D NULL; =20 - cmd =3D virCommandNewArgList(SYSINFO_SMBIOS_DECODER, - "-q", "-t", "0,1,2,3,4,17", NULL); + cmd =3D virCommandNewArgList(DMIDECODE, "-q", "-t", "0,1,2,3,4,17", NU= LL); virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, NULL) < 0) return NULL; diff --git a/src/util/virsysinfopriv.h b/src/util/virsysinfopriv.h index cdcb021309..d6c558a32d 100644 --- a/src/util/virsysinfopriv.h +++ b/src/util/virsysinfopriv.h @@ -24,8 +24,7 @@ #pragma once =20 void -virSysinfoSetup(const char *dmidecode, - const char *sysinfo, +virSysinfoSetup(const char *sysinfo, const char *cpuinfo); =20 virSysinfoDefPtr diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c index f080569730..10d24b823a 100644 --- a/tests/sysinfotest.c +++ b/tests/sysinfotest.c @@ -84,7 +84,7 @@ testSysinfo(const void *data) =20 virCommandSetDryRun(NULL, testDMIDecodeDryRun, sysinfo); =20 - virSysinfoSetup(NULL, sysinfo, cpuinfo); + virSysinfoSetup(sysinfo, cpuinfo); =20 ret =3D testdata->func(); virCommandSetDryRun(NULL, NULL, NULL); --=20 2.26.2 From nobody Wed May 8 02:56:16 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=1591629067; cv=none; d=zohomail.com; s=zohoarc; b=Ix48JWEemX0iDIeH/lT/L1w3MxckymSoh2XINgxjYAXP70QvQlqUnf8XJU4DGsog71Uh4/b48zT3vV9Q3ZpFNlZnwv3TneSgjC9kvKIEEC3mCO67zV472DtMMOSRchwLj1YYkChr5GFdG1oxCSXfWq2EoJjCPhPJCR6Z6d5lwQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591629067; 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=QVR/+EbPynxV6PCGCohP3+Lq40jxQrT2klmLIW6f9RU=; b=L76+wD1cibnohovyVAGwtwFHwV5J7Mba1Tdk/KO0g96iyIpgKBy/INkvamcrbJqA9mDR7oftqfOfuL2ByBUnY7cEJipNb4SIQJ4DVN1SH3qsiZg85oLolSDTeX/DYR7FYh68TyUu9R8Hr4k3sV9U34XrfK3ldQYQiTFZT+HXZ40= 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 159162906736578.22796254194168; Mon, 8 Jun 2020 08:11:07 -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-330-lpUjo-rSO0WlFEB2Df4GOA-1; Mon, 08 Jun 2020 11:10:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19285107B7C5; Mon, 8 Jun 2020 15:10:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC42E5D9E5; Mon, 8 Jun 2020 15:10:01 +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 B0EB21809547; Mon, 8 Jun 2020 15:10:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 058F6VUm004872 for ; Mon, 8 Jun 2020 11:06:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8933E10013D4; Mon, 8 Jun 2020 15:06:31 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08C4210013C1 for ; Mon, 8 Jun 2020 15:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591629066; 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=QVR/+EbPynxV6PCGCohP3+Lq40jxQrT2klmLIW6f9RU=; b=fZDBCpFGEfqRvll3Pi7FmStsuabD/YPsvmPBMXcEkkPy/csRzOtElISKqVjKiwAyFzt1Qj eYoht+MnXZnsC0ERJhRG77PG5XojkgwyFjPPJwSqT/3Ki0vMiTrzj1V4iE8dNiuSkOXPYu MxI7YAS9fvu11WS+7iXbHtFZW2NKTJY= X-MC-Unique: lpUjo-rSO0WlFEB2Df4GOA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 7/7] virsysinfo: Parse OEM strings Date: Mon, 8 Jun 2020 17:06:21 +0200 Message-Id: <602e77dacc9018844d1e88510f2c6bc5bd764db8.1591628594.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.14 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" Setting OEM strings for a domain was introduced in v4.1.0-rc1~315. However, any application that wanted to use them (e.g. to point to an URL where a config file is stored) had to 'dmidecode -u --oem-string N' (where N is index of the string). Well, we can expose them under our XML and if the domain is running Libvirt inside it can be obtained using virConnectGetSysinfo() API. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virsysinfo.c | 102 +++++++++++++++++++++++++++- tests/sysinfodata/x86sysinfo.data | 6 ++ tests/sysinfodata/x86sysinfo.expect | 8 +++ tests/sysinfotest.c | 27 ++++++-- 4 files changed, 138 insertions(+), 5 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index a26c27e83e..09e32df6a9 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -915,6 +915,103 @@ virSysinfoParseX86Chassis(const char *base, } =20 =20 +static int +virSysinfoDMIDecodeOEMString(size_t i, + char **str) +{ + g_autofree char *err =3D NULL; + g_autoptr(virCommand) cmd =3D virCommandNewArgList(DMIDECODE, "--dump", + "--oem-string", NULL); + virCommandAddArgFormat(cmd, "%zu", i); + virCommandSetOutputBuffer(cmd, str); + virCommandSetErrorBuffer(cmd, &err); + + if (virCommandRun(cmd, NULL) < 0) + return -1; + + /* Unfortunately, dmidecode returns 0 even if OEM String index is out + * of bounds, but it prints an error message in that case. Check stderr + * and return success/failure accordingly. */ + + if (err && *err !=3D '\0') + return -1; + + return 0; +} + + +static int +virSysinfoParseOEMStrings(const char *base, + virSysinfoOEMStringsDefPtr *stringsRet) +{ + virSysinfoOEMStringsDefPtr strings =3D NULL; + size_t i =3D 1; + int ret =3D -1; + const char *cur; + + if (!(cur =3D strstr(base, "OEM Strings"))) + return 0; + + if (VIR_ALLOC(strings) < 0) + return -1; + + while ((cur =3D strstr(cur, "String "))) { + char *eol; + + cur +=3D 7; + + if (!(eol =3D strchr(cur, '\n'))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Malformed output of dmidecode")); + goto cleanup; + } + + while (g_ascii_isdigit(*cur)) + cur++; + + if (*cur !=3D ':') { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Malformed output of dmidecode")); + goto cleanup; + } + + cur +=3D 2; + + virSkipSpacesBackwards(cur, &eol); + if (!eol) + continue; + + if (VIR_EXPAND_N(strings->values, strings->nvalues, 1) < 0) + goto cleanup; + + /* If OEM String contains newline, dmidecode escapes it as a dot. + * If this is the case then run dmidecode again to get raw string. + * Unfortunately, we can't dinstinguish betwen dot an new line at + * this level. */ + if (memchr(cur, '.', eol - cur)) { + char *str; + + if (virSysinfoDMIDecodeOEMString(i, &str) < 0) + goto cleanup; + + strings->values[strings->nvalues - 1] =3D g_steal_pointer(&str= ); + } else { + strings->values[strings->nvalues - 1] =3D g_strndup(cur, eol -= cur); + } + + i++; + cur =3D eol; + } + + *stringsRet =3D g_steal_pointer(&strings); + ret =3D 0; + + cleanup: + virSysinfoOEMStringsDefFree(strings); + return ret; +} + + static int virSysinfoParseX86Processor(const char *base, virSysinfoDefPtr ret) { @@ -1119,7 +1216,7 @@ virSysinfoReadDMI(void) g_autofree char *outbuf =3D NULL; g_autoptr(virCommand) cmd =3D NULL; =20 - cmd =3D virCommandNewArgList(DMIDECODE, "-q", "-t", "0,1,2,3,4,17", NU= LL); + cmd =3D virCommandNewArgList(DMIDECODE, "-q", "-t", "0,1,2,3,4,11,17",= NULL); virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, NULL) < 0) return NULL; @@ -1141,6 +1238,9 @@ virSysinfoReadDMI(void) if (virSysinfoParseX86Chassis(outbuf, &ret->chassis) < 0) return NULL; =20 + if (virSysinfoParseOEMStrings(outbuf, &ret->oemStrings) < 0) + return NULL; + ret->nprocessor =3D 0; ret->processor =3D NULL; if (virSysinfoParseX86Processor(outbuf, ret) < 0) diff --git a/tests/sysinfodata/x86sysinfo.data b/tests/sysinfodata/x86sysin= fo.data index 426261041d..3f0b654e4b 100644 --- a/tests/sysinfodata/x86sysinfo.data +++ b/tests/sysinfodata/x86sysinfo.data @@ -81,3 +81,9 @@ Memory Device Serial Number: 29057112 Asset Tag: 0839 Part Number: IMSH2GS13A1F1C-10F + +OEM Strings + String 1: Hello + String 2: World + String 3: Ha ha ha try parsing\n. String 3: this correctly. = String 4:then + String 4: This is, more tricky value=3Descaped diff --git a/tests/sysinfodata/x86sysinfo.expect b/tests/sysinfodata/x86sys= info.expect index fcdd790cbd..05add8f031 100644 --- a/tests/sysinfodata/x86sysinfo.expect +++ b/tests/sysinfodata/x86sysinfo.expect @@ -50,4 +50,12 @@ 29057112 IMSH2GS13A1F1C-10F + + Hello + World + Ha ha ha try parsing\n + String 3: this correctly + String 4:then + This is, more tricky value=3Descaped + diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c index 10d24b823a..3b418955d0 100644 --- a/tests/sysinfotest.c +++ b/tests/sysinfotest.c @@ -56,10 +56,29 @@ testDMIDecodeDryRun(const char *const*args G_GNUC_UNUSE= D, { const char *sysinfo =3D opaque; =20 - if (virFileReadAll(sysinfo, 10 * 1024 * 1024, output) < 0) { - *error =3D g_strdup(virGetLastErrorMessage()); - *status =3D EXIT_FAILURE; - return; + if (STREQ_NULLABLE(args[1], "--dump") && + STREQ_NULLABLE(args[2], "--oem-string")) { + if (!args[3]) { + *error =3D g_strdup("dmidecode: option '--oem-string' requires= an argument"); + *status =3D EXIT_FAILURE; + return; + } + + if (STREQ(args[3], "3")) { + *output =3D g_strdup("Ha ha ha try parsing\\n\n" + " String 3: this correctly\n" + " String 4:then"); + } else { + *error =3D g_strdup_printf("No OEM string number %s", args[3]); + *status =3D EXIT_FAILURE; + return; + } + } else { + if (virFileReadAll(sysinfo, 10 * 1024 * 1024, output) < 0) { + *error =3D g_strdup(virGetLastErrorMessage()); + *status =3D EXIT_FAILURE; + return; + } } =20 *error =3D g_strdup(""); --=20 2.26.2