Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:FrontRunner
libvirt
95c95f1b-virml-Introduce-VIR_XML_PROP_NONNEGATI...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 95c95f1b-virml-Introduce-VIR_XML_PROP_NONNEGATIVE-flag.patch of Package libvirt
From 65c77b0d8e7a47926641d3d32c83cd076960ef9b Mon Sep 17 00:00:00 2001 From: Michal Privoznik <mprivozn@redhat.com> Date: Mon, 7 Mar 2022 16:44:46 +0100 Subject: [PATCH 1/9] virml: Introduce VIR_XML_PROP_NONNEGATIVE flag For easier attribute parsing we have virXMLProp*() family of functions. These accept flags through which a caller can pose some conditions onto the attribute value, for instance: VIR_XML_PROP_NONZERO when the attribute may not be zero, etc. What we are missing is VIR_XML_PROP_NONNEGATIVE when the attribute value may be non-negative. Obviously, this flag makes sense only for some members of the virXMLProp*() family. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> (cherry picked from commit 95c95f1b756b92db4ceb4ba4446330126a7d7e1e) --- src/util/virxml.c | 7 +++++++ src/util/virxml.h | 3 +++ 2 files changed, 10 insertions(+) Index: libvirt-8.0.0/src/util/virxml.c =================================================================== --- libvirt-8.0.0.orig/src/util/virxml.c +++ libvirt-8.0.0/src/util/virxml.c @@ -625,6 +625,13 @@ virXMLPropInt(xmlNodePtr node, return -1; } + if ((flags & VIR_XML_PROP_NONNEGATIVE) && (val < 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid value for attribute '%s' in element '%s': '%s'. Expected non-negative value"), + name, node->name, tmp); + return -1; + } + if ((flags & VIR_XML_PROP_NONZERO) && (val == 0)) { virReportError(VIR_ERR_XML_ERROR, _("Invalid value for attribute '%s' in element '%s': Zero is not permitted"), Index: libvirt-8.0.0/src/util/virxml.h =================================================================== --- libvirt-8.0.0.orig/src/util/virxml.h +++ libvirt-8.0.0/src/util/virxml.h @@ -38,6 +38,9 @@ typedef enum { VIR_XML_PROP_NONE = 0, VIR_XML_PROP_REQUIRED = 1 << 0, /* Attribute may not be absent */ VIR_XML_PROP_NONZERO = 1 << 1, /* Attribute may not be zero */ + VIR_XML_PROP_NONNEGATIVE = 1 << 2, /* Attribute may not be negative, makes + sense only for some virXMLProp*() + functions. */ } virXMLPropFlags;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor