From nobody Wed Nov 27 02:41:17 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=1558353472; cv=none; d=zoho.com; s=zohoarc; b=XmSftI/pIuK/4Zt7ly5Zt6NM9frvXb8JOd32oiuAW5eWQsNkQ6HsjZLNZ7GQ4jB5nZEVgOalEpUFP/v5WWXCycwDFFdLsot5fqv7W5BvaEVsLNtuX/IiLOP64THtnIJX2o/T87u47oQM2tbe0d5cA1xrzbgQQDLspZt2aS6QNy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558353472; 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=OmXY73DHOTDOEpkvJzXl28ueSoHb+G8jBYBba0jAoBo=; b=DpMH7R9G1B3bVQlugNg7fSKs9vogwoWqI3JPlRqbRmrZnaj2/qRvUjM8oIHPBZEIZmA7yiz3oRX2D2KV3BjfyKiEuCdXdiT8+igVo7p1sRdGjNDt8sRzF7QVQsuNwXvnA3mzl6F3bjnz+8JfKf0tXUns4BKgUWdzjnV3qB/AEMA= 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 1558353471660523.6399528903872; Mon, 20 May 2019 04:57:51 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3117FC050DEC; Mon, 20 May 2019 11:57:47 +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 356215C226; Mon, 20 May 2019 11:57:46 +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 B81201806B14; Mon, 20 May 2019 11:57:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4KBvhD3023067 for ; Mon, 20 May 2019 07:57:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id EA9135C2E1; Mon, 20 May 2019 11:57:43 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E103118B41; Mon, 20 May 2019 11:57:41 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140133.outbound.protection.outlook.com [40.107.14.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D20E85545; Mon, 20 May 2019 11:57:16 +0000 (UTC) Received: from HE1PR0501MB2329.eurprd05.prod.outlook.com (10.168.33.22) by HE1PR0501MB2411.eurprd05.prod.outlook.com (10.168.124.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1900.17; Mon, 20 May 2019 11:57:13 +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.1900.020; Mon, 20 May 2019 11:57:13 +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=FCWluM3/kjb1FQCjDzxN+ylR81aYyYk66F5h/ExXGsw=; b=d9+tnTfANQkW5mn/ucmIP0ITzrlHHI0SfLoQ/d0wMbE0dZiJGzj7hvGGnGd82sRIciKp8RWFSB7xoWVQytqIJCtsRms0g4sg2v05TZD9aOkKb7qFII2xM0SHhmvEepA0UjbTa3xRVDkL3Nsl+ef5/Kuy6Y/HPOuBRpO8UNwnvuY= From: Johannes Holmberg To: "libvir-list@redhat.com" Thread-Topic: [PATCH] virt-xml-validate: Allow input to be read from stdin Thread-Index: AQHVDwMpqmiTXzHG+Ue9+gK+ApCsrQ== Date: Mon, 20 May 2019 11:57:13 +0000 Message-ID: <20190520115406.4116-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: AM6P192CA0034.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:83::47) 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.56] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 271ed8ab-1e14-4a3f-8df7-08d6dd1a4ba1 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:HE1PR0501MB2411; x-ms-traffictypediagnostic: HE1PR0501MB2411: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 004395A01C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(346002)(39840400004)(366004)(136003)(396003)(199004)(189003)(52314003)(2616005)(54906003)(6506007)(386003)(476003)(44832011)(26005)(68736007)(66066001)(7736002)(305945005)(71190400001)(71200400001)(316002)(486006)(186003)(74482002)(478600001)(2351001)(73956011)(66556008)(102836004)(66946007)(86362001)(14454004)(64756008)(66446008)(450100002)(66476007)(5640700003)(6436002)(6486002)(2501003)(99286004)(256004)(14444005)(6916009)(15650500001)(2906002)(36756003)(3846002)(6116002)(1076003)(8676002)(6512007)(52116002)(25786009)(5660300002)(81156014)(8936002)(50226002)(107886003)(81166006)(53936002)(4326008); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0501MB2411; H:HE1PR0501MB2329.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX: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: vxa3tpz0YzRGN0NeLpMABwA1iQNmR4qVkEc2nVazd0RdB8KDdAhFHneJO/+K2BgMI8iUMQ2aX3dGXYVBWOVBvQRcqA+jU9oDkB3XZdBOD9gRdItOnxEC8kg7ll7bxsO4ED8BLXAjbllgtfzAlh5bNcAzzZz/Xi3aJIle300Ybykan1gFCxSVQzQj/jFfn37GBDtGVsMZbtRQXk2W0SBjQIjtr18lGi5VOY6binON6E+HImljh+208Gr8gXxcMULU79VG0mtG5hGGHYST/lG9Q5yVC40osVayP+ZTSm+I2DfLP6VFBp6mxypyIiiEO+yeqYxYcHh3Y+Us6Ld5RX3BM/bcOnBHOoCHTN+Cus9GHm3q/hDhP/xxwN4piWIu6uf/daj5IUBp/8cDLqanG0btkfgz/VAO9iaKcr3nMiJfJvY= MIME-Version: 1.0 X-OriginatorOrg: dataductus.se X-MS-Exchange-CrossTenant-Network-Message-Id: 271ed8ab-1e14-4a3f-8df7-08d6dd1a4ba1 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 May 2019 11:57:13.2305 (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: HE1PR0501MB2411 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.28]); Mon, 20 May 2019 11:57:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 20 May 2019 11:57:23 +0000 (UTC) for IP:'40.107.14.133' DOMAIN:'mail-eopbgr140133.outbound.protection.outlook.com' HELO:'EUR01-VE1-obe.outbound.protection.outlook.com' FROM:'johannes.holmberg@dataductus.se' RCPT:'' X-RedHat-Spam-Score: 0.841 (DKIM_INVALID, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL) 40.107.14.133 mail-eopbgr140133.outbound.protection.outlook.com 40.107.14.133 mail-eopbgr140133.outbound.protection.outlook.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MIME-Autoconverted: from base64 to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id x4KBvhD3023067 X-loop: libvir-list@redhat.com Cc: "mkletzan@redhat.com" , Johannes Holmberg Subject: [libvirt] [PATCH] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 20 May 2019 11:57:47 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" --- Hello, This is an updated version of a patch I submitted on 2015-06-10. I got some feedback on it but then moved on to a different project and forgot about it. Anyway, I've updated the patch according to the feedback so if you are still interested, here it is! :) /Johannes tools/virt-xml-validate.in | 44 ++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/tools/virt-xml-validate.in b/tools/virt-xml-validate.in index 64aeaaaa33..2d2afb74ec 100644 --- a/tools/virt-xml-validate.in +++ b/tools/virt-xml-validate.in @@ -16,6 +16,16 @@ =20 set -e =20 +TMPFILE=3D + +cleanup() { + if [ $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 [ $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 [ $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