From nobody Sat Feb 7 05:20:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1729589319462117.59545228124387; Tue, 22 Oct 2024 02:28:39 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6543718D5; Tue, 22 Oct 2024 05:28:38 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E7DEE18A6; Tue, 22 Oct 2024 05:28:08 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9346818B8; Tue, 22 Oct 2024 05:28:04 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 171CD1753 for ; Tue, 22 Oct 2024 05:28:04 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-65-VsRyvCDkPO24jPu9bnAeuA-1; Tue, 22 Oct 2024 05:28:01 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7773C19560A6 for ; Tue, 22 Oct 2024 09:28:00 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.59]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 612F719560A2; Tue, 22 Oct 2024 09:27:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729589283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qUuxzlUPuEqmhA7KbB1Lhg4o4sDStkhc+89Q8N1gyFI=; b=G77ElPR71fawmaVKA3ee8m6fhpStlJLfDtea3GQ7stLxpDJFxleAd5mMe9iqvKnpvvB1e3 Qf1wpOqKQ+6PZRhu6fNmrlY2idqotfnlfK0zVCXLMdlgWar8M4y2Lj6nA6PrmcwD4BWjZg cGuOxRX3ac270tYZZrHtvcg24T5LGuI= X-MC-Unique: VsRyvCDkPO24jPu9bnAeuA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Cc: "Richard W.M. Jones" , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 1/3] util/xml: fix extraction of XML context Date: Tue, 22 Oct 2024 10:27:52 +0100 Message-ID: <20241022092754.1542147-2-berrange@redhat.com> In-Reply-To: <20241022092754.1542147-1-berrange@redhat.com> References: <20241022092754.1542147-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: SWUZWMOGW7B47UHN2S4ICZNTPJO4QZPT X-Message-ID-Hash: SWUZWMOGW7B47UHN2S4ICZNTPJO4QZPT X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1729589321227116600 Content-Type: text/plain; charset="utf-8" Currently given an input of ' Reviewed-by: Peter Krempa --- src/util/virxml.c | 4 ++++ tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 51173303fe..91f736bf39 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1047,6 +1047,10 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNUS= ED, ...) cur =3D ctxt->input->cur; base =3D ctxt->input->base; =20 + /* skip backwards over NUL terminator */ + if ((cur > base) && *cur =3D=3D '\0') + cur--; + /* skip backwards over any end-of-lines */ while ((cur > base) && ((*(cur) =3D=3D '\n') || (*(cur) =3D=3D '\r'))) cur--; diff --git a/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err b/t= ests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err index 35a1801371..a3bacd5d3a 100644 --- a/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err +++ b/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err @@ -1,3 +1,3 @@ ABS_SRCDIR/qemuxmlconfdata/broken-xml-invalid.xml:2: Couldn't find end of = Start Tag dom line 1 -(null) -^ + Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1729589339519332.7046998303606; Tue, 22 Oct 2024 02:28:59 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 85E8118F0; Tue, 22 Oct 2024 05:28:58 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8F47E1947; Tue, 22 Oct 2024 05:28:14 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id ACC1C18D9; Tue, 22 Oct 2024 05:28:09 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id AC3E218C8 for ; Tue, 22 Oct 2024 05:28:04 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-593-Mj7RLo1hOSGSdfnRiolDMA-1; Tue, 22 Oct 2024 05:28:03 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 471A919560B0 for ; Tue, 22 Oct 2024 09:28:02 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.59]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E2D4B19560A2; Tue, 22 Oct 2024 09:28:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729589284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=17jkQ3Fg95ztLCIGw2dhEkLO1xjCjubJNmN6edPa1BI=; b=DdU3Z65NeETGAZ4UIb7L37Rrjd6t+ycLIUrfTgF4PixLV5F8VSLNQBZmbgSQ8PdViaDJLo eQ62efpt34/nT9nXZp9r6rMXfqT0qQKF67EprPyS5tV67/Nti6hUHwOyIwssFdkWa0EmPJ 3fPVtf+BHvJxs9Ss25DYdxwyqA1wWRQ= X-MC-Unique: Mj7RLo1hOSGSdfnRiolDMA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Cc: "Richard W.M. Jones" , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 2/3] util/xml: don't assume libxml2 has the filename of the document Date: Tue, 22 Oct 2024 10:27:53 +0100 Message-ID: <20241022092754.1542147-3-berrange@redhat.com> In-Reply-To: <20241022092754.1542147-1-berrange@redhat.com> References: <20241022092754.1542147-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WRG5ZNU4WABZ6UQC3VGWW72OE5SYGJDS X-Message-ID-Hash: WRG5ZNU4WABZ6UQC3VGWW72OE5SYGJDS X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1729589341327116600 Content-Type: text/plain; charset="utf-8" The libxml2 error handling gets the filename from a libxml2 struct, but it is better to not assume libxml2 knows the filename being parsed, as we might have simply provided it a pre-loaded string. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Krempa --- src/util/virxml.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 91f736bf39..797aa6f6ca 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -46,6 +46,7 @@ /* Internal data to be passed to SAX parser and used by error handler. */ struct virParserData { int domcode; + const char *filename; }; =20 =20 @@ -1022,7 +1023,7 @@ static void catchXMLError(void *ctx, const char *msg G_GNUC_UNUSED, ...) { xmlParserCtxtPtr ctxt =3D (xmlParserCtxtPtr) ctx; - + struct virParserData *private =3D ctxt->_private; const xmlChar *cur, *base; unsigned int n, col; /* GCC warns if signed, because compared w= ith sizeof() */ int domcode =3D VIR_FROM_XML; @@ -1030,6 +1031,10 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNUS= ED, ...) g_autofree char *contextstr =3D NULL; g_autofree char *pointerstr =3D NULL; const xmlError *lastError =3D xmlCtxtGetLastError(ctxt); + const char *filename =3D NULL; + + if (private) + filename =3D private->filename; =20 /* conditions for error printing */ if (!ctxt || @@ -1040,9 +1045,8 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNUSE= D, ...) lastError->message =3D=3D NULL) return; =20 - if (ctxt->_private) - domcode =3D ((struct virParserData *) ctxt->_private)->domcode; - + if (private) + domcode =3D private->domcode; =20 cur =3D ctxt->input->cur; base =3D ctxt->input->base; @@ -1083,10 +1087,10 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNU= SED, ...) =20 pointerstr =3D virBufferContentAndReset(&buf); =20 - if (lastError->file) { + if (filename) { virGenericReportError(domcode, VIR_ERR_XML_DETAIL, _("%1$s:%2$d: %3$s%4$s\n%5$s"), - lastError->file, + filename, lastError->line, lastError->message, contextstr, @@ -1152,6 +1156,7 @@ virXMLParseHelper(int domcode, abort(); =20 private.domcode =3D domcode; + private.filename =3D filename; pctxt->_private =3D &private; pctxt->sax->error =3D catchXMLError; =20 --=20 2.46.0 From nobody Sat Feb 7 05:20:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1729589358332122.3476264891226; Tue, 22 Oct 2024 02:29:18 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 150531724; Tue, 22 Oct 2024 05:29:17 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 632E218F4; Tue, 22 Oct 2024 05:28:20 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1E5F4191F; Tue, 22 Oct 2024 05:28:15 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A11661921 for ; Tue, 22 Oct 2024 05:28:06 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-411-Tyk8vPgaMH6dROB2zdFiEA-1; Tue, 22 Oct 2024 05:28:05 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3A5B419560BE for ; Tue, 22 Oct 2024 09:28:04 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.59]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BD27919560B2; Tue, 22 Oct 2024 09:28:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729589286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1SE9ECZigz+IlRF2Gp03rWe298In7XoFJQybm1mGzSs=; b=dOpqTb6ntkuUv6yhwTxcUicuUhwwhoJjM5/aKb7PLJCoVQORq8HPtciKA9HJ6uWm4m8nAk FQrtzcGH3G80ET5WCk9cfLeQaNnN3cNnifr5SNDQ9f5OSJGTcrD6MhVZvcydFwW2FTXIP7 f7+FKxk7OJkcT1H8mpLKlQENu4MSy9g= X-MC-Unique: Tyk8vPgaMH6dROB2zdFiEA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Cc: "Richard W.M. Jones" , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 3/3] util/xml: open XML files before calling libxml2 Date: Tue, 22 Oct 2024 10:27:54 +0100 Message-ID: <20241022092754.1542147-4-berrange@redhat.com> In-Reply-To: <20241022092754.1542147-1-berrange@redhat.com> References: <20241022092754.1542147-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: K6QPK75NEMQQT6S2IL2KFQ6DTB3RQAPC X-Message-ID-Hash: K6QPK75NEMQQT6S2IL2KFQ6DTB3RQAPC X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1729589359426116600 Content-Type: text/plain; charset="utf-8" Libxml2 has awful error reporting behaviour when reading files. When we fail to load a file from the test driver we see: $ virsh -c test:///wibble.xml I/O warning : failed to load external entity "/wibble.xml" error: failed to connect to the hypervisor error: XML error: failed to parse xml document '/wibble.xml' where the I/O warning line is something printed by libxml2 itself, which also lacks any useful detail. Switching to our own file reading code we can massively improve things: $ ./build/tools/virsh -c test:///wibble.xml error: failed to connect to the hypervisor error: Failed to open file '/wibble.xml': No such file or directory Using 10 MB as an upper limit on XML file size ought to be sufficient for any XML files libvirt is reading. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Richard W.M. Jones --- src/util/virxml.c | 8 +++++--- tests/qemuxmlconfdata/nonexistent-file.x86_64-latest.err | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 797aa6f6ca..deed258bb0 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1142,6 +1142,7 @@ virXMLParseHelper(int domcode, xmlNodePtr rootnode; const char *docname; int parseFlags =3D XML_PARSE_NONET | XML_PARSE_NOWARNING; + g_autofree char *xmlStrPtr =3D NULL; =20 if (filename) docname =3D filename; @@ -1165,10 +1166,11 @@ virXMLParseHelper(int domcode, } =20 if (filename) { - xml =3D xmlCtxtReadFile(pctxt, filename, NULL, parseFlags); - } else { - xml =3D xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL, parseFla= gs); + if (virFileReadAll(filename, 1024*1024*10, &xmlStrPtr) < 0) + return NULL; + xmlStr =3D xmlStrPtr; } + xml =3D xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL, parseFlags); =20 if (!xml) { if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) { diff --git a/tests/qemuxmlconfdata/nonexistent-file.x86_64-latest.err b/tes= ts/qemuxmlconfdata/nonexistent-file.x86_64-latest.err index 0ddf1ea510..2aedf3eded 100644 --- a/tests/qemuxmlconfdata/nonexistent-file.x86_64-latest.err +++ b/tests/qemuxmlconfdata/nonexistent-file.x86_64-latest.err @@ -1 +1 @@ -XML error: failed to parse xml document 'ABS_SRCDIR/qemuxmlconfdata/nonexi= stent-file.xml' +Failed to open file 'ABS_SRCDIR/qemuxmlconfdata/nonexistent-file.xml': No = such file or directory --=20 2.46.0