From nobody Sun Apr 28 16:37:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558427621; cv=none; d=zoho.com; s=zohoarc; b=MXOkNe6DnKKFvD4vAuyCPS5S/Ml6Kqk7rE3H5R9Scbusekci7vMwbNraxhbrOi4R9xzLQdVgYQgYb4WSMa6Q6/tRWnvfeTRkudN/X5VqdOYrWH/pktgW0z2UlLmeCB3G2izofM7awHcNTCD9V2TQHuBAdqvLsnpIkPC2L2Jo67M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558427621; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=BarvO8bjAl8+sDlOm6HW1P+S6C052w4c7X7VvHEnSag=; b=HVodtJm24AnzMB1y/aJOvPlwpiF9GOVcbcDJYHIWYYpAqI/vynUZiEIN8YJ1Dacz8PB5kcCvRUdGBqLDOZU+Wo8A4hq5zFfuNCaUmWufYr1G0kZPhp/k3iFfVkVP6fuOinuc+PqtcY2GfYTCCCcO0+y5o9bBecvIYlTI80IqfS0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558427621852371.43483736005635; Tue, 21 May 2019 01:33:41 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id B4C145945B; Tue, 21 May 2019 08:33:31 +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 E1C6960FBE; Tue, 21 May 2019 08:33:25 +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 BB4C21806B0F; Tue, 21 May 2019 08:33:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4L8XILW007316 for ; Tue, 21 May 2019 04:33:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 663A319936; Tue, 21 May 2019 08:33:18 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E98626198 for ; Tue, 21 May 2019 08:33:16 +0000 (UTC) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50119.outbound.protection.outlook.com [40.107.5.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81A89308220B for ; Tue, 21 May 2019 08:33:08 +0000 (UTC) Received: from HE1PR0501MB2329.eurprd05.prod.outlook.com (10.168.33.22) by HE1PR0501MB2569.eurprd05.prod.outlook.com (10.168.124.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1900.18; Tue, 21 May 2019 08:33:05 +0000 Received: from HE1PR0501MB2329.eurprd05.prod.outlook.com ([fe80::1d61:7655:226e:3648]) by HE1PR0501MB2329.eurprd05.prod.outlook.com ([fe80::1d61:7655:226e:3648%8]) with mapi id 15.20.1922.013; Tue, 21 May 2019 08:33:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dataductus.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+tVuWUHI9AHZPo4XJ3tSMC40wk7FL04Kqpo1+loz9hU=; b=EHMAuOCSb5Fj4x/thJurf1FEiYXpy3vKufbpRyDvxRxdS1d+T+/XDvWIIRV2PBV4iN6kG0bUO1X/RfzHp0k4XgQGjnrtB3vsxpNzrHlFbmSrB6OgjBFkKMZzHj1R3ecDDpZmfbpfp1yGLwztgVGl2zZDOiA+q7reI6XCzfKoFIQ= From: Johannes Holmberg To: "libvir-list@redhat.com" Thread-Topic: [PATCHv2] virt-xml-validate: Allow input to be read from stdin Thread-Index: AQHVD6/PFSmXLT5rSkuIIo6CGDL6Kg== Date: Tue, 21 May 2019 08:33:05 +0000 Message-ID: <20190521083216.22488-1-johannes.holmberg@dataductus.se> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR01CA0109.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::14) To HE1PR0501MB2329.eurprd05.prod.outlook.com (2603:10a6:3:25::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=johannes.holmberg@dataductus.se; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [173.38.220.57] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: eecf637b-e753-45e2-5137-08d6ddc6f1e5 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:HE1PR0501MB2569; x-ms-traffictypediagnostic: HE1PR0501MB2569: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:321; x-forefront-prvs: 0044C17179 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(396003)(366004)(376002)(346002)(39850400004)(189003)(199004)(36756003)(66476007)(66946007)(8936002)(8676002)(66556008)(64756008)(66446008)(73956011)(86362001)(6916009)(50226002)(5660300002)(81166006)(81156014)(66066001)(2906002)(386003)(6506007)(486006)(68736007)(26005)(2616005)(478600001)(476003)(44832011)(6436002)(5640700003)(3846002)(6116002)(6486002)(2501003)(186003)(102836004)(15650500001)(14454004)(53936002)(4326008)(52116002)(71200400001)(71190400001)(99286004)(7736002)(305945005)(1076003)(316002)(6512007)(256004)(14444005)(25786009)(107886003)(2351001)(74482002); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0501MB2569; H:HE1PR0501MB2329.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; received-spf: None (protection.outlook.com: dataductus.se does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: AbBwOTxI0zbWRMw/MDnjyYc5u/6+v9nIOmdl9igOy+n3VZTRluRqgf2XELq0SBd6ioTuD+BJBgHwfPACJ0a5aM/TTqHJcEpVD8SYLutHZ9N/nCkuHx9f5JpVDgBH90Nr30EzBEUh9BtP97DaEPcSE2SMg3122PXPFCzXj3/yDh6Y4FMMWw+T69j99LqAIIJmDzXl5g0A9JBJ+T/kMD/ujuGElBQqW91rKV8q7l/Nd2dBK1vsU6/OaB68oPPn7uuM2t5za0PoltVBUNwGczDD3rJxUWj+u+94q9TY/DvWkoj5NVDSt3YQnD+JDqLWAitF7K0dibdsgD+Odtjq8LR4uG1e65sjgFVbp1lNmtqeK+EyBa+jUPmg1UehZiDPixbHDLehrUTJeHGcDhsConqZ0acH4jqqu+BblU6Tu7dfyoQ= MIME-Version: 1.0 X-OriginatorOrg: dataductus.se X-MS-Exchange-CrossTenant-Network-Message-Id: eecf637b-e753-45e2-5137-08d6ddc6f1e5 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2019 08:33:05.4127 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f84f6fe6-b0e4-4db1-b7d6-b7c280fb507f X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2569 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 21 May 2019 08:33:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 21 May 2019 08:33:09 +0000 (UTC) for IP:'40.107.5.119' DOMAIN:'mail-eopbgr50119.outbound.protection.outlook.com' HELO:'EUR03-VE1-obe.outbound.protection.outlook.com' FROM:'johannes.holmberg@dataductus.se' RCPT:'' X-RedHat-Spam-Score: 0.543 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NEUTRAL) 40.107.5.119 mail-eopbgr50119.outbound.protection.outlook.com 40.107.5.119 mail-eopbgr50119.outbound.protection.outlook.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MIME-Autoconverted: from base64 to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id x4L8XILW007316 X-loop: libvir-list@redhat.com Cc: Johannes Holmberg Subject: [libvirt] [PATCHv2] virt-xml-validate: Allow input to be read from stdin 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 21 May 2019 08:33:40 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Johannes Holmberg Reviewed-by: Martin Kletzander --- Changes from v1: - Quotes around $TMPFILE everywhere. - Explicit -n checks in if statements - Fixed one instance of incorrect indentation - Signed-off-by line in commit message =20 tools/virt-xml-validate.in | 46 ++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/tools/virt-xml-validate.in b/tools/virt-xml-validate.in index 64aeaaaa33..5cb7dcd276 100644 --- a/tools/virt-xml-validate.in +++ b/tools/virt-xml-validate.in @@ -16,7 +16,17 @@ =20 set -e =20 -case $1 in +TMPFILE=3D + +cleanup() { + if [ -n "$TMPFILE" ]; then + rm -f "$TMPFILE" + fi +} + +trap cleanup EXIT + +case "$1" in -h | --h | --he | --hel | --help) cat <&2 exit 1 ;; esac @@ -42,18 +52,27 @@ esac XMLFILE=3D"$1" TYPE=3D"$2" =20 -if [ -z "$XMLFILE" ]; then - echo "syntax: $0 XMLFILE [TYPE]" >&2 - exit 1 -fi +if [ "$XMLFILE" =3D "-" ]; then + TMPFILE=3D`mktemp --tmpdir virt-xml.XXXX` + cat > "$TMPFILE" +else + if [ -z "$XMLFILE" ]; then + echo "syntax: $0 XMLFILE [TYPE]" >&2 + exit 1 + fi =20 -if [ ! -f "$XMLFILE" ]; then - echo "$0: document $XMLFILE does not exist" >&2 - exit 2 + if [ ! -f "$XMLFILE" ]; then + echo "$0: document $XMLFILE does not exist" >&2 + exit 2 + fi fi =20 if [ -z "$TYPE" ]; then - ROOT=3D`xmllint --stream --debug "$XMLFILE" 2>/dev/null | grep "^0 1 " |= awk '{ print $3 }'` + if [ -n "$TMPFILE" ]; then + ROOT=3D`xmllint --stream --debug - < "$TMPFILE" 2>/dev/null | grep "^0= 1 " | awk '{ print $3 }'` + else + ROOT=3D`xmllint --stream --debug "$XMLFILE" 2>/dev/null | grep "^0 1 "= | awk '{ print $3 }'` + fi case "$ROOT" in *domainsnapshot*) # Must come first, since *domain* is a substring TYPE=3D"domainsnapshot" @@ -101,6 +120,9 @@ if [ ! -f "$SCHEMA" ]; then exit 4 fi =20 -xmllint --noout --relaxng "$SCHEMA" "$XMLFILE" - +if [ -n "$TMPFILE" ]; then + xmllint --noout --relaxng "$SCHEMA" - < "$TMPFILE" +else + xmllint --noout --relaxng "$SCHEMA" "$XMLFILE" +fi exit --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list