From nobody Fri Dec 19 17:53:13 2025 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 1740113469107318.65451850175737; Thu, 20 Feb 2025 20:51:09 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 09FCA3F0; Thu, 20 Feb 2025 23:51:07 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 49BCE22BE; Thu, 20 Feb 2025 23:49:56 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3B7222230; Thu, 20 Feb 2025 23:49:51 -0500 (EST) 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 5052E1E09 for ; Thu, 20 Feb 2025 23:49:50 -0500 (EST) Received: from mx-prod-mc-03.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-mx8VBZw-P8ifz9jNuozovQ-1; Thu, 20 Feb 2025 23:49:47 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0A4A019373D8 for ; Fri, 21 Feb 2025 04:49:47 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.88.20]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 915431955F0F for ; Fri, 21 Feb 2025 04:49:46 +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=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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=1740113389; h=from:from: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; bh=gUV9lcRezTEy5aVl3JJvH4hr7youIKj+UWrbNEIb/7g=; b=bHSNU1+wg+yF/HQqcNISi1pGKPEz0kLDSPl9Mnfn/Ez9YOUiBRi2w/ZlHpcedZu1TwsPht Siv93cd9Lz3D9jExebCFbSvQXac/hxdcpbonILbQrOocbhBXeu9Txyl+CcBnN5umslpyyE gb0py+sFnhjG2wCXUsPxgKpGAQzCU4E= X-MC-Unique: mx8VBZw-P8ifz9jNuozovQ-1 X-Mimecast-MFC-AGG-ID: mx8VBZw-P8ifz9jNuozovQ_1740113387 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 2/2] schema: fix errors when validating subelements Date: Thu, 20 Feb 2025 23:49:44 -0500 Message-ID: <20250221044944.126503-3-laine@redhat.com> In-Reply-To: <20250221044944.126503-1-laine@redhat.com> References: <20250221044944.126503-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: LrYom6_7z3iCg2LfwzHWCpiIl_jnpsekB7PYPZkHTVE_1740113387 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3BXEDSDKZ3Q7CHSCEWIMQXJZ6Z4XAICY X-Message-ID-Hash: 3BXEDSDKZ3Q7CHSCEWIMQXJZ6Z4XAICY X-MailFrom: laine@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: 1740113471276019100 Content-Type: text/plain; charset="utf-8"; x-default="true" I first noticed a problem when I added a element at an unusual (but still correct) place in the domain XML, and validation failed. Then I tried adding that element in several different places and it failed in many, but not all of them. (NB: from here on, I will use '' for the names of attributes in the domain XML, <> for elements in the domain XML, and "" for the names of grammar rule definitions in the RNG file, and "<>" for the names of elements in the RNG file's own XML. Confused yet? If so, please tell me a better way - everything I know about RNG I've picked up informally by looking at examples in already existing RNG files) Starting from the top level of the grammar for ("domaincontents" in domaincommon.rng), I noticed that 1) the "" for the 'id' attribute of is defined inside an "" down in the definition of "ids" (which is referenced from "domaincontents") (I'm not familiar with the nomenclature - does that make it a "sub-grammer", "child-grammar", ???) 2) although the definition of "ids", had all of its ""s/""s inside an "", "domaincontents" already had the reference to "ids" inside an "", so there were nested ""s. It's not clear to me how an "" or "" inside another "" is supposed to behave, but they both seemed a bit suspicious. I tried all of the below modifications: 1) moving the grammar for the 'id' attribute out of the "" but still inside "ids" 2) moving the grammer for the 'id' attribute directly into "domaincontents" (and outside of its "interleave" 3) removing the "" that was inside "ids" 4) (2) + (3) 5) move the entire grammar rule "ids" up directly in place of in "domaincontents". 6) (5), but with the grammar for the 'id' attribute moved outside of the "" (6) was the only change that allowed all of the following (using modifications to the subelements of in net-vhostuser-passt.xml as example): a) a element in between *any* two existing elements b) moving in between any two elements c) oddly, in addition to the problem with putting in odd places, I also found that the original RNG did not allow the element to be placed in between and , but once I'd made the change in (6), this was no longer problematic. Why sh= ould this have any effect? No idea, but it works :-/ (NB: there are many other cases of referencing "sub-grammar" from inside an "", and they all seem to work just fine; possibly in this case it was problematic because the sub-grammar a) also contained an "", b) had an "" at its toplevel, or c) had multiple ""s.) (inexplicably (to me) at one point during my experimentation, I tried reordering the references to "clock", "resources", "features", and "events", and that *also* made it legal to put a element in between the elements:-O) Since I was no longer able to reproduce the error described in (c) once I had made mod (6) (move all of "ids" directly into "domaincontent", I decided it was pointless for me to spend any more time randomly poking and just add that to the new test case for that in case some other random change to the RNG causes it to start failing again. (I thought of writing a test program that would try all possible orderings of the subelements of , but since doing that for even 10 subelements would mean testing > 3.2 million different XML documents, I decided we could continue in this adhoc manner, just adding a single new test case if/when a new validation failure is found.) Signed-off-by: Laine Stump --- src/conf/schemas/domaincommon.rng | 53 +++++++--------- ...rder-domain-subelements.x86_64-latest.args | 40 ++++++++++++ ...order-domain-subelements.x86_64-latest.xml | 62 +++++++++++++++++++ .../schema-reorder-domain-subelements.xml | 62 +++++++++++++++++++ tests/qemuxmlconftest.c | 2 + 5 files changed, 187 insertions(+), 32 deletions(-) create mode 100644 tests/qemuxmlconfdata/schema-reorder-domain-subelements= .x86_64-latest.args create mode 100644 tests/qemuxmlconfdata/schema-reorder-domain-subelements= .x86_64-latest.xml create mode 100644 tests/qemuxmlconfdata/schema-reorder-domain-subelements= .xml diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 3328a63205..002ac72ba5 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -32,8 +32,28 @@ =20 + + + + + - + + + + + + + + + + + + + + + + @@ -679,37 +699,6 @@ =20 - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_64= -latest.args b/tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_= 64-latest.args new file mode 100644 index 0000000000..d27dd77d9f --- /dev/null +++ b/tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_64-latest= .args @@ -0,0 +1,40 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-passtvhostuu \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-passtvhostuu/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-passtvhostuu/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-passtvhostuu/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dpasstvhostuu,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-passtvhostuu/master-key.aes"}' \ +-machine pc-i440fx-7.2,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc= .ram,acpi=3Don \ +-accel kvm \ +-cpu qemu64 \ +-m size=3D16777216k \ +-object '{"qom-type":"memory-backend-file","id":"pc.ram","mem-path":"/var/= lib/libvirt/qemu/ram/-1-passtvhostuu/pc.ram","share":true,"x-use-canonical-= path-for-ramblock-id":false,"size":17179869184}' \ +-overcommit mem-lock=3Doff \ +-smp 16,sockets=3D16,cores=3D1,threads=3D1 \ +-uuid d79698e0-46b2-4459-87ee-7c762990dd6e \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-blockdev '{"driver":"file","filename":"/home/laine/libvirt/images/fedora-= 34.img","node-name":"libvirt-1-storage","read-only":false}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","multifunction":true,"ad= dr":"0x3","drive":"libvirt-1-storage","id":"virtio-disk0","bootindex":1}' \ +-chardev socket,id=3Dcharnet0,path=3D/var/run/libvirt/qemu/passt/-1-passtv= hostuu-net0.socket \ +-netdev '{"type":"vhost-user","chardev":"charnet0","id":"hostnet0"}' \ +-device '{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":= "52:54:00:21:de:6c","bus":"pci.0","addr":"0x2"}' \ +-chardev pty,id=3Dcharserial0 \ +-device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0","in= dex":0}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x4"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_64= -latest.xml b/tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_6= 4-latest.xml new file mode 100644 index 0000000000..b1ef798384 --- /dev/null +++ b/tests/qemuxmlconfdata/schema-reorder-domain-subelements.x86_64-latest= .xml @@ -0,0 +1,62 @@ + + passtvhostuu + d79698e0-46b2-4459-87ee-7c762990dd6e + 16777216 + 16777216 + + + + 16 + + /machine + + + hvm + + + + + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + +
+ + + + + + +
+ + + + + + + + + + + +