[PATCH for 10.10.0 0/5] Fix broken XML schemas and 'virschematest'

'virschematest' didn't test the majority of files for some time so some schema problems snuck in. Peter Krempa (5): schemas: domain: Make <identity> subelement of NFS disk source optional schemas: domaincaps: Add schema for 'panic' device schemas: domaincaps: Add schema for 'canonical' cpu model name schemas: domaincaps: Add schema for CPU 'blockers' virschematest: Don't skip all "directory" tests src/conf/schemas/domaincaps.rng | 29 +++++++++++++++++++++++++++++ src/conf/schemas/domaincommon.rng | 26 ++++++++++++++------------ tests/virschematest.c | 9 +++++---- 3 files changed, 48 insertions(+), 16 deletions(-) -- 2.47.0

Both the 'user' and 'group' attribute are optional so <identity> can be empty. Allow it to be omitted completely. The parser and qemu code can handle that. The schema was introduced in 943871f971d680f72726a9d6e9330eec264f6588 and in d018c8dc9ebcd0496c7a564bc2e8b1c9cbd8d96f an offending test was added. Fixes: 943871f971d680f72726a9d6e9330eec264f6588 Fixes: d018c8dc9ebcd0496c7a564bc2e8b1c9cbd8d96f Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincommon.rng | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 7415c37b65..b3fdbf7ffb 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -2010,18 +2010,20 @@ </define> <define name="diskSourceNetworkNFS"> - <element name="identity"> - <optional> - <attribute name="user"> - <ref name="genericName"/> - </attribute> - </optional> - <optional> - <attribute name="group"> - <ref name="genericName"/> - </attribute> - </optional> - </element> + <optional> + <element name="identity"> + <optional> + <attribute name="user"> + <ref name="genericName"/> + </attribute> + </optional> + <optional> + <attribute name="group"> + <ref name="genericName"/> + </attribute> + </optional> + </element> + </optional> </define> <define name="diskSourceNetworkProtocolRBD"> -- 2.47.0

Due to 'virschematest' being broken commit a52cd504b3618c67abf3a07c669 introduced a new element to the domain caps but didn't add schema for it. Fixes: a52cd504b3618c67abf3a07c669fd5e5ab18aa50 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincaps.rng | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/conf/schemas/domaincaps.rng b/src/conf/schemas/domaincaps.rng index f9b87c8a59..142a54d1d7 100644 --- a/src/conf/schemas/domaincaps.rng +++ b/src/conf/schemas/domaincaps.rng @@ -215,6 +215,9 @@ <optional> <ref name="interface"/> </optional> + <optional> + <ref name="panic"/> + </optional> </element> </define> @@ -288,6 +291,13 @@ </element> </define> + <define name="panic"> + <element name="panic"> + <ref name="supported"/> + <ref name="enum"/> + </element> + </define> + <define name="interface"> <element name="interface"> <ref name="supported"/> -- 2.47.0

Due to 'virschematest' being broken commit fff2bbee7feb0fdfbf40aac4fe9 forgot to add schema for the new attribute. Fixes: fff2bbee7feb0fdfbf40aac4fe9efd070f72ce9e Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincaps.rng | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/conf/schemas/domaincaps.rng b/src/conf/schemas/domaincaps.rng index 142a54d1d7..40bae6e578 100644 --- a/src/conf/schemas/domaincaps.rng +++ b/src/conf/schemas/domaincaps.rng @@ -164,6 +164,11 @@ <ref name="virYesNo"/> </attribute> </optional> + <optional> + <attribute name="canonical"> + <text/> + </attribute> + </optional> <attribute name='vendor'> <text/> </attribute> -- 2.47.0

Due to broken 'virschematest' commit f4dc248a952aaebcc793c7809c6c083d9 forgot to introduce schema for the new element. Fixes: f4dc248a952aaebcc793c7809c6c083d9cc30d0c Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincaps.rng | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/conf/schemas/domaincaps.rng b/src/conf/schemas/domaincaps.rng index 40bae6e578..3559d2ae05 100644 --- a/src/conf/schemas/domaincaps.rng +++ b/src/conf/schemas/domaincaps.rng @@ -174,6 +174,20 @@ </attribute> <text/> </element> + <optional> + <element name="blockers"> + <attribute name="model"> + <text/> + </attribute> + <oneOrMore> + <element name="feature"> + <attribute name="name"> + <text/> + </attribute> + </element> + </oneOrMore> + </element> + </optional> </zeroOrMore> </element> </define> -- 2.47.0

Due to a bug in the optimization to avoid testing symlinked tests multiple times all tests were skipped. In commit f997fcca71a16b102e6ee663 I made an attempt to optimize the tests by avoiding testing symlinks. This optimization was buggy as I've passed the 'd_name' field of 'struct dirent' which is just the filename to 'g_lstat()'. 'g_lstat()' obviously always failed with ENOENT. As the logic checked only for successful return of 'g_lstat()' the optimizatio was a dud. Now in 4d8ebbfee83edb2 the 'g_lstat()' call was replaced by 'virFileIsLink()' checking all non-zero values. This meant that if 'virFileIsLink()' failed the test was skipped. Now since a bad argument was passed this failed always and thus was always skipped making 'virschematest' useless. Fix it by passing the full path of the test and also explicitly check for '1' return value instead of any non-zero. Fixes: f997fcca71a16b102e6ee663a3fb86bed8de9d7d Fixes: 4d8ebbfee83edb26b19a62465b9f98d0126db991 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virschematest.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/virschematest.c b/tests/virschematest.c index 5d3fa32de4..e08ae21738 100644 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -124,8 +124,6 @@ testSchemaDir(const char *schema, continue; if (ent->d_name[0] == '.') continue; - if (virFileIsLink(ent->d_name)) - continue; if (filter && !g_regex_match(filter, ent->d_name, 0, NULL)) continue; @@ -134,11 +132,14 @@ testSchemaDir(const char *schema, g_strv_contains(entry->skip, ent->d_name)) continue; + xml_path = g_strdup_printf("%s/%s", dir_path, ent->d_name); + + if (virFileIsLink(xml_path) == 1) + continue; + if (entry->exceptions) exception = g_strv_contains(entry->exceptions, ent->d_name); - xml_path = g_strdup_printf("%s/%s", dir_path, ent->d_name); - if (testSchemaFile(schema, validator, xml_path, exception) < 0) ret = -1; } -- 2.47.0

On 11/28/24 09:32, Peter Krempa wrote:
Due to a bug in the optimization to avoid testing symlinked tests multiple times all tests were skipped.
In commit f997fcca71a16b102e6ee663 I made an attempt to optimize the tests by avoiding testing symlinks. This optimization was buggy as I've passed the 'd_name' field of 'struct dirent' which is just the filename to 'g_lstat()'. 'g_lstat()' obviously always failed with ENOENT. As the logic checked only for successful return of 'g_lstat()' the optimizatio was a dud.
Now in 4d8ebbfee83edb2 the 'g_lstat()' call was replaced by 'virFileIsLink()' checking all non-zero values. This meant that if 'virFileIsLink()' failed the test was skipped. Now since a bad argument was passed this failed always and thus was always skipped making 'virschematest' useless.
Fix it by passing the full path of the test and also explicitly check for '1' return value instead of any non-zero.
Fixes: f997fcca71a16b102e6ee663a3fb86bed8de9d7d Fixes: 4d8ebbfee83edb26b19a62465b9f98d0126db991
Collaboration works! :-D Michal

On 11/28/24 09:32, Peter Krempa wrote:
'virschematest' didn't test the majority of files for some time so some schema problems snuck in.
Peter Krempa (5): schemas: domain: Make <identity> subelement of NFS disk source optional schemas: domaincaps: Add schema for 'panic' device schemas: domaincaps: Add schema for 'canonical' cpu model name schemas: domaincaps: Add schema for CPU 'blockers' virschematest: Don't skip all "directory" tests
src/conf/schemas/domaincaps.rng | 29 +++++++++++++++++++++++++++++ src/conf/schemas/domaincommon.rng | 26 ++++++++++++++------------ tests/virschematest.c | 9 +++++---- 3 files changed, 48 insertions(+), 16 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Michal Prívozník
-
Peter Krempa