[libvirt PATCH 0/2] Always validate XML for (hypervisor-)cpu-compare

Tim Wiederhake posted 2 patches 3 years ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20210415084054.9971-1-twiederh@redhat.com
src/conf/cpu_conf.c | 16 +++++++---------
src/util/virxml.c   | 13 ++++++-------
src/util/virxml.h   |  1 -
3 files changed, 13 insertions(+), 17 deletions(-)
[libvirt PATCH 0/2] Always validate XML for (hypervisor-)cpu-compare
Posted by Tim Wiederhake 3 years ago
XML schema validation for `virsh (hypervisor-)cpu-compare` has to be
enabled explicitly by passing the `--validate` flag. Having invalid
XML domain / cpu specification that appear to work can lead to hard
to find problems down the line, when e.g. migration of VMs does not
work as expected.

This series fixes a bug in the validation code and logs the schema
validation error to libvirtd's log file. User facing behaviour stays
unchanged.

See this conversation for more background:
https://listman.redhat.com/archives/libvir-list/2021-March/msg01214.html

Tim Wiederhake (2):
  virxml: Fix schema validation of individual nodes
  virCPUDefParseXML: Log schema validation errors

 src/conf/cpu_conf.c | 16 +++++++---------
 src/util/virxml.c   | 13 ++++++-------
 src/util/virxml.h   |  1 -
 3 files changed, 13 insertions(+), 17 deletions(-)

-- 
2.26.2


Re: [libvirt PATCH 0/2] Always validate XML for (hypervisor-)cpu-compare
Posted by Daniel P. Berrangé 3 years ago
On Thu, Apr 15, 2021 at 10:40:52AM +0200, Tim Wiederhake wrote:
> XML schema validation for `virsh (hypervisor-)cpu-compare` has to be
> enabled explicitly by passing the `--validate` flag. Having invalid
> XML domain / cpu specification that appear to work can lead to hard
> to find problems down the line, when e.g. migration of VMs does not
> work as expected.
> 
> This series fixes a bug in the validation code and logs the schema
> validation error to libvirtd's log file. User facing behaviour stays
> unchanged.

I'm sceptical this is going to be beneficial. RNG validation error
messages can be obscure at the best of times. I almost always need
to look at the original input XML to understand what the RNG error
really means. IOW just having the RNG error logged is unlikely to
be enough to help people see what went wrong, assuming anyone even
pays attention to the log.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [libvirt PATCH 0/2] Always validate XML for (hypervisor-)cpu-compare
Posted by Peter Krempa 3 years ago
On Thu, Apr 15, 2021 at 10:14:02 +0100, Daniel P. Berrangé wrote:
> On Thu, Apr 15, 2021 at 10:40:52AM +0200, Tim Wiederhake wrote:
> > XML schema validation for `virsh (hypervisor-)cpu-compare` has to be
> > enabled explicitly by passing the `--validate` flag. Having invalid
> > XML domain / cpu specification that appear to work can lead to hard
> > to find problems down the line, when e.g. migration of VMs does not
> > work as expected.
> > 
> > This series fixes a bug in the validation code and logs the schema
> > validation error to libvirtd's log file. User facing behaviour stays
> > unchanged.
> 
> I'm sceptical this is going to be beneficial. RNG validation error
> messages can be obscure at the best of times. I almost always need
> to look at the original input XML to understand what the RNG error
> really means. IOW just having the RNG error logged is unlikely to
> be enough to help people see what went wrong, assuming anyone even
> pays attention to the log.

And in addition to that (now speaking generally about also other APIs
which take XML and have voluntary validation) users can have a working
XML for their use case which may be invalid.

Spamming the logs in such case may be a double edged sword; in some
cases users might fix the XML if they notice something's wrong or in
other cases they may get their logs spammed with a irrelevant error.